# H3C配置经典全面教程,非常适合初学者
第一次使用H3C系列路由器时,只能通过配置口(Console)进行配置。 1.打开电脑调试软件(CRT、Xshell或MobaXterm等);2.设置终端参数a、命名此终端 H3C或者自己想命的名;4.当路由器启动完毕后,回车几下,当出现<H3C>时即可配置路由器。\[H3C\]telnet server enable 打开路由器的telnet功能\[H3C\]configure-user count 5 设置允许同时配置路由器的用户数\[H3C\]local-user telnet 添加本地用户(此处为telnet用户登陆时使用的用户名)\[H3C-luser-telnet\]password simple h3c 设置telnet用户登陆时所使用的密码\[H3C-luser-telnet\]service-type telnet 设置本地用户的服务类型(此处为telnet)\[H3C-luser-telnet\]level 3 设置本地用户的服务级别\[H3C-luser-telnet\]quit 退出本地用户视图\[H3C\]\[H3C\]user-interface vty 0 4 进入用户视图 \[H3C-ui-vty0-4\]authentication-mode scheme 选择“scheme”认证方式\[H3C\] interface serial 3/0 进入某个端口\[H3C-Serial3/0\] ip address 200.1.1.1 255.255.255.0 为该端口设置ip地址\[H3C-Serial3/0\] undo shutdown 对该端口进行复位\[H3C-Serial3/0\] quit 退回到系统视图\[H3C\]ip route-static 192.168.1.0 255.255.255.0 192.168.0.1 添加一条静态路由\[H3C\]ip route-static 0.0.0.0 0.0.0.0 192.168.0.1 添加一条默认路由display current-configuration 显示当前的配置文件display interface GigabitEthernet 0/0 查看某端口的状态\[H3C-vlan100\]port ethernet 0/1 将某个端口加入到vlan中\[H3C-vlan100\]quit 退出到系统\[H3C\]interface vlan-interface 1 创建vlan虚接口\[H3C-Vlan-interface100\] ip address 192.168.1.1 255.255.255.0 配置ip地址备\[H3C\] interface vlan-interface 1\[H3C-Vlan-interface10\] ip address 192.168.1.1 255.255.255.0\[H3C-Vlan-interface10\] quit\[H3C\] ip route-static 0.0.0.0 0.0.0.0 192.168.1.2 配置缺省路由 \[H3C\]interface ethernet 0/1\[H3C\]port link-type trunk 将端口类型设置为trunk\[H3C\]port trunk permit vlan all trunk端口允许所有vlan通过\[H3C\]saveTrunk可以收发多个vlan的报文,用于交换机与交换机之间的互连\[H3C\]local-user telnet 添加本地用户(此处为telnet用户登陆时使用的用户名)\[H3C-luser-telnet\]password simple h3c 设置telnet用户登陆时所使用的密码\[H3C-luser-telnet\]service-type telnet 设置本地用户的服务类型(此处为telnet)\[H3C-luser-telnet\]level 3 设置本地用户的服务级别\[H3C-luser-telnet\]quit 退出本地用户视图\[H3C\]\[H3C\]user-interface vty 0 4 进入用户视图 \[H3C-ui-vty0-4\]authentication-mode scheme 选择“scheme”认证方式<Quidway>system-view----进入系统配置模式\[Quidway\] interface Vlan-interface 1---交换机出厂默认VLAN-1\[Quidway-Vlan-interface1\]ip add 192.168.X.254 255.255.255.0–配置IP地址\[Quidway-Vlan-interface1\]quit\[Quidway\] ip route-static 0.0.0.0 0.0.0.0 192.168.0.33-配置静态路由(网关)<Quidway>system-view----进入系统配置模式\[Quidway\] user-interface vty 0 4\[Quidway-ui-vty0-4\] user privilege level 3—管理权限配置\[Quidway-ui-vty0-4\] set authentication password cipher 123456 (cipher为密文密码)<Quidway>system-view----进入系统配置模式\[Quidway\]interface Ethernet 1/0/1---进入的端口\[Quidway-Ethernet1/0/1\] duplex full—配置端口为“全双工状态”\[Quidway-Ethernet1/0/1\] speed 100---配置端口为“100M”如果是千兆端口可以配置成1000M。<Quidway>system-view----进入系统配置模式\[Quidway\]VLAN 100---创建VLAN---ID为:100\[Quidway\]VLAN 101---创建VLAN---ID为:101\[Quidway-vlan100\] port Ethernet 1/0/1 to Ethernet 1/0/10----从第1口到第10口添加到VLAN 100\[Quidway-vlan101\] port Ethernet 1/0/11 to Ethernet 1/0/24----从第11口到第24口添加到VLAN 101比如一栋宿舍楼需要两个网段,划分了两个VLAN为100和101,VLAN 100作为管理VLAN<Quidway>system-view----进入系统配置模式\[Quidway\]VLAN 100 ---创建VLAN---ID为:100\[Quidway\]VLAN 101 ---创建VLAN---ID为:101\[Quidway-vlan100\] port Ethernet 1/0/1 to Ethernet 1/0/10\[Quidway-vlan101\] port Ethernet 1/0/11 to Ethernet 1/0/24\[Quidway\] interface Vlan-interface 100\[Quidway-Vlan-interface100\]ip address 192.168.100.254 255.255.255.0\[Quidway-Vlan-interface100\]quit\[Quidway\]ip route-static 0.0.0.0 0.0.0.0 192.168.100.33 配置静态路由(网关)上联端口为千兆端口GigabitEthernet1/1/1\[Quidway\] interface GigabitEthernet 1/1/1 --进入上联端口\[Quidway-GigabitEthernet1/1/1\] port link-type trunk --TRUNK是端口汇聚的意思\[Quidway-GigabitEthernet1/1/1\] port trunk permit(允许)vlan all \[Quidway-GigabitEthernet1/1/1\] duplex full—配置端口为“全双工状态”\[Quidway-GigabitEthernet1/1/1\] speed 1000---配置端口为“1000M”\[Quidway\]snmp-agent community read 1234---SNMP读的密码\[Quidway\]snmp-agent community write 4567—SNMP写的密码\[Quidway\]snmp-agent sys-info version all --SNMP软件版本有V1、V2c、V3这里配置的是允许所有版本。\[Quidway\]dhcp-snooping --开启交换机DHCP Snooping 功能。开启VLAN 1 内所有端口的ARP 入侵检测功能。\[Quidway\]vlan 1\[Quidway-vlan1\]arp detection enable设置上联端口Ethernet1/0/1 为DHCP Snooping 信任端口,ARP 信任端口。\[Quidway\]interface Ethernet1/0/1\[Quidway-Ethernet1/0/1\]dhcp-snooping trust\[Quidway-Ethernet1/0/1\]arp detection trust\[Quidway-Ethernet1/0/1\]quit开启端口Ethernet1/0/2 上的ARP 报文限速功能,设置ARP 报文通过的最大速率为20pps。--目的是针对用户接入口,除上联端口外,下联用户端口建议都设置该命令。\[Quidway\]interface Ethernet1/0/2\[Quidway-Ethernet1/0/2\]arp rate-limit enable\[Quidway-Ethernet1/0/2\]arp rate-limit 20\[Quidway-Ethernet1/0/2\]quit配置端口状态自动恢复功能,恢复时间间隔为30 秒。\[Quidway\] arp protective-down recover enable\[Quidway\] arp protective-down recover interval 30