# 端口及配置文件说明 ``` # 交换机端口 tg1/0/49 10G端口 fg1/0/53 40G端口 mg1/0/0 10-1000M自适应管理端口 #路由器端口 g0/0/1 #查看接口信息 [H3C]dis interface Vlan-interface 1 brief [H3C]dis interface g1/0/1 brief #查看当前生效配置 display current-configuration #查看下次启动使用的配置文件 display saved-configuration #查看最近配置变化 display configuration changes # 查看系统时间 display clock ``` # 远程超时时间配置 ``` #设置cli或vty连接超时时间600分钟 sys [H3C]user-interface vty 0 4 [H3C-line-vty0-4]idle-timeout 600 [H3C-line-vty0-4]quit #设置ssh和telnet超时时间600分钟 sys [H3C]user-interface vty 0 4 [H3C-line-vty0-4]protocol inbound telnet [H3C-line-vty0-4]idle-timeout 600 [H3C-line-vty0-4]protocol inbound ssh [H3C-line-vty0-4]idle-timeout 600 [H3C-line-vty0-4]quit #设置console接口超时时间600分钟 sys [H3C]user-interface console 0 [H3C-line-console0]idle-timeout 600 [H3C-line-console0]quit ``` # 堆叠交换机 ``` sys int range FortyGigE 1/0/53 to FortyGigE 1/0/54 #进入堆叠端口 shutdown #关闭端口 irf member 1 priority 32 #配置优先级 irf-port 1/1 #配置irf端口 irf-port-configuration active #激活irf端口配置 irf-port 1/1 #配置irf端口 port group interface FortyGigE 1/0/53 port group interface FortyGigE 1/0/54 quit dis irf #显示irf相关信息 dis irf link #显示irf链路信息 dis irf conf #显示irf重启后生效的irf配置 ``` # 端口聚合 ``` sys [H3C]int bridge-agg 1 link-aggregation mode dynamic # 切换为动态速率模式 quit int range g1/0/1 to g1/0/4 port link-aggregation group 1 将端口加入聚合组 display link-aggregation verbose # 查看端口聚合信息 ``` # 二三层口切换 ``` sys [H3C]int GigabitEthernet1/0/48 [H3C-GigabitEthernet1/0/48]port link-mode { bridge | route } #bridge是二层,route是三层 ``` # vlan配置 ``` [H3C]vlan 253 #创建vlan253 [H3C-vlan253]port GigabitEthernet 1/0/48 #在vlan模式下将端口加入vlan253 [H3C-GigabitEthernet1/0/48]port access vlan 253 #在接口模式下将端口加入vlan [H3C-GigabitEthernet1/0/48]port link-type trunk #配置接口为trunk类型 [H3C-GigabitEthernet1/0/48]port trunk permit vlan all #允许所有vlan通过 [H3C-GigabitEthernet1/0/48]port trunk permit vlan 10 20 #允许指定vlan通过 [H3C]dis interface Vlan-interface brief #查看所有vlanif接口配置 [H3C]dis vlan #显示所有打开的vlan ``` # dhcp服务 ``` [H3C]dhcp enable [H3C]dhcp server ip-pool manage #创建名为mange的ip地址池 [H3C-dhcp-pool-manage]network 10.0.1.0 24 #设置地址池 [H3C-dhcp-pool-manage]forbidden-ip 10.0.1.1 10.0.1.254 #设置保留ip [H3C-dhcp-pool-manage]gateway-list 10.0.1.254 #分配dhcp网关 [H3C-dhcp-pool-manage]dns-list 223.5.5.5 #分配dns地址 [H3C-dhcp-pool-manage]quit [H3C]int vlan 1 #进入对应的vlanif接口 [H3C-Vlan-interface1]ip address 10.0.1.254 24 #设置ip地址 # 配置dhcp中继,只能在vlanif接口下配置 [H3C]int vlan 1 #进入vlan1 [H3C-Vlan-interface1]dhcp select relay [H3C-Vlan-interface1]ip address 10.0.1.1 24 #设置ip地址 [H3C]quit [H3C]display dhcp server pool ip池名字 #查看dhcp池1配置信息 [H3C]display dhcp relay #查看dhcp中继配置 display dhcp server lease #查看dhcp租约 ``` # stp生成树 ``` stp模式有stp,rstp,pstp,mstp [H3C]stp mode mstp #配置stp模式 [H3C]dis stp root #显示生成树根桥信息 ``` # 静态路由 ``` sys [H3C]ip route-static 目的ip 子网掩码 下一跳ip #添加一条静态路由 [H3C]delete static-routes all #删除所有静态路由 [H3C]undo ip route-static 目的ip #删除一条静态路由 [H3C]ip route-static fast-reroute auto #配置静态路由快速重路由 # 配置静态路由快速重路由支持BFD检测功能 [H3C]bfd echo-source-ip 自定义ip #配置echo报文源ip [H3C]ip route-static primary-path-detect bfd echo #使能静态路由中主用链路的BFD(Echo方式)检测功能 [H3C]dis ip routing-table protocol static verbose #查看静态路由表信息 [H3C]dis ip routing-table protocol direct #查看直连路由信息表 # window添加静态路由 [H3C]route add -p 192.168.2.0 mask 255.255.255.0 192.168.1.1 metric 1 #-p代表永久,metric表示路由跃点数 [H3C]route delete [目的ip] #删除静态路由 ``` # VRRP协议 ``` # 三层接口创建vrrp [H3C]int g1/0/48 #进入三层接口 [H3C-GigabitEthernet1/0/48]vrrp vrid 1 virtual-ip 10.10.0.1 #创建备份组1,并配置虚拟ip # 二层接口通过vlanif创建vrrp [H3C]vlan 10 #创建vlan10 [H3C]quit [H3C]int vlan 10 #进入vlanif10接口 [H1-Vlan-interface10]vrrp vrid 1 virtual-ip 10.10.10.1 #创建备份组 # 其他配置 [H1-Vlan-interface10]vrrp vrid 1 priority 150 #设置备份组优先级,值越大优先级越高 ``` # OSPF协议 ``` sys [hx1-1]ospf 1 router-id 1.1.1.1 #打开ospf进程1,设置routerid为1.1.1.1 [hx1-1-ospf-1]area 0 # 进入区域0 [hx1-1-ospf-1-area-0.0.0.0]network 10.1.0.0 0.0.3.255 #添加设备下的网络,采用反掩码 [hx1-1-ospf-1-area-0.0.0.0]authentication-mode md5 1 plain 123456 #设置ospf明文认证密码 [hx1-1-ospf-1-area-0.0.0.0]dis ospf peer #查看ospf的邻居关系 [hx1-1-ospf-1]preference 1 #修改路由优先级 [H3C]dis ospf interface #查看ospf接口信息 [H3C]dis ospf routing #查看ospf路由表信息 [H3C]dis ospf peer statistics #显示本地路由器所有ospf邻居统计信息 [H3C]undo ospf 进程号 #关闭ospf ``` # 命令大全 ## ping ``` -c 指定ping次数 -a 指定源IP地址 -f 指定不分段的数据包 -h 指定TTL值 -i 指定传出接口 -m 指定发送回显请求的间隔,单位:毫秒 -n 仅数字输出。不会尝试查找主机 ```