华为网工组网技术的常用命令
华为交换机基本配置
//用户视图
system-view //进入系统视图配置
[Huawei] //系统视图
[Huawei]quit/return //退出系统视图模式
[Huawei]sysname R1 //设置主机别名
[Huawei]user-interface console 0 //进入控制台
[Huawei-ui-consloe0]authentication-mode password
[Huawei-ui-consloe0]set authentication password cipher huawei //设置密文密码
配置交换机的远程管理IP
[Huawei]interface Vlanif 1 //进入VLAN1
[Huawei-Vlanif1]ip add 192.168.1.254 24 //配置IP
[Huawei-Vlanif1] undo shutdown //开启接口
[Huawei] dns domain xxxxx.com //设置域名
[Huawei]dns server 192.168.254.254 //设置域名IP
dis vlan 显示vlan save保存配置
dis curr显示当前配置 reboot重启设备
undo terminal monitor //取消提示消息
配置交换机端口速率,双工,ARP:
[Huawei]int g0/0/1 //进入接口
[Huawei-g0/0/1]description xxxxx //端口描述
[Huawei-g0/0/1]undo negotiation auto //取消协商
[Huawei-GigabitEthernet0/0/1]duplex full //全双工
[Huawei-GigabitEthernet0/0/1]auto duplex full //自动
[Huawei-GigabitEthernet0/0/1]speed 10 //速率10
[Huawei-GigabitEthernet0/0/1]auto speed 10 //自动速率10
[Huawei]arp static 192.168.1.8 5489-98cf-2603 //绑定
[Huaweidis arp [Huawei]dis arp all //查看arp
配置路由器接口IP和静态路由
[Huawei]int g0/0/1 //进入接口
[Huawei-g0/0/1]ip add 192.168.1.6 24 //配置IP地址
[Huawei-GigabitEthernet0/0/1]undo shutdown //开启
dis cur //查看
[Huawei]ip route-static 192.168.20.0 24 10.0.12.2
[Huawei]ip route-static 192.168.20.0 24 serial 0/0/1
[Huawei]ip route-static 0.0.0.0 0 192.168.1.5 //默认
[Huawei]display ip routing-table //查看路由表
交换机VLAN配置
[Huawei]vlan 10 或 [Huawei]vlan 20 //创建VLAN
[Huawei-vlan 10]description xxxxx //VLAN描述
[Huawei]vlan batch 30 40 //创建多个VLAN
[Huawei]vlan batch 50 to 60 //连续创建多个VLAN
[Huawei]int g0/0/1 //进入接口
[Huawei]int g0/0/1port link-type access //访问接口
[Huawei-g0/0/1]port default vlan 10 //加入VLAN
[Huawei-g0/0/1]port link-type trunk //干道口
[Huawei-g0/0/2]port trunk allow-pass vlan 10 20 //允许
[Huawei-g0/0/2]port trunk allow-pass vlan all //允许所有
[Huawei]int e0/0/2 //进入接口
[Huawei-E0/0/2]port link-type hybrid //混合口模式
[Huawei-E0/0/2]undo port default vlan //删除默认vlan
[Huawei-E0/0/2]port hybrid untagged vlan 20 //去标签
[Huawei-E0/0/2]port hybrid pvid vlan 2 //设置默认vlan
[Huawei-E0/0/2]port trunk allow-pass vlan 10 to 100 允许
[Huawei]dis port vlan //查看vlan
[Huawei]display vlan //查看vlan
路由器RIP协议配置
[Huawei]rip //启用RIP默认v1
[Huawei-rip-1]network 192.168.1.0 //发布直连网段
[Huawei-rip-1]version 2 //配置v2版本
[Huawei]dis rip //查看rip
[Huawei]dis rip database //查看rip数据库
[Huawei]dis ip routing-table //查看路由表
路由器OSPF协议配置
[Huawei]ospf 1 //启用OSPF默认是进程1
[Huawei-ospf-1]area 0 //进入区域0
[Huawei-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255 //发布直连网段
[Huawei-ospf-1]silent-interface g0/0/2 //被动接口
[Huawei]dis ospf interface //查看ospf通告
[Huawei]dis ospf peer //查看ospf邻居
[Huawei]dis ip routing-table //查看路由表
[Huawei]dis ospf routing //查看OSPF路由表
[Huawei]
路由器DHCP协议配置
[Huawei]dhcp enable //开启DHCP
[Huawei]ip pool xxxxx //地址池名
[Huawei-ip-pool-xxxxx]network 192.168.1.0 //地址池
[Huawei-ip-pool-xxxxx]lease day 2 //租约默认1
[Huawei-ip-pool-xxxxx]gateway-list 192.168.1.254 //网关
[Huawei-ip-pool-xxxxx]excluded-ip-address 192.168.1.250 192.168.1.253 //排除IP范围
[Huawei-ip-pool-xxxxx]dns-list 8.8.8.8 //DNS服务器
[Huawei-g0/0/0]dhcp select global //基于全局
基于接口的DHCP协议配置
[Huawei]dhcp enable //开启DHCP
[Huawei] int g0/0/1 //进入接口
[Huawei-G0/0/1]dhcp select interface //选择接口
[Huawei-G0/0/1]dhcp server lease day 2 //租约
[Huawei-G0/0/1]dhcp server excluded-ip-address 192.168.1.1 192.168.1.10 排除IP范
[Huawei-G0/0/1]dhcp server dns-list 8.8.8.8 //DNS服务器
[Huawei]dis ip pool //查看DHCP
路由器ACL协议配置
配置路由器基本ACL:2000-29999
[Huawei]acl 2000 //配置基本acl
[Huawei-acl-basic-2000]rule 5 permit source 1.1.1.1 0 //允许源IP(注意反掩码0,默认步长5)
[Huawei-acl-basic-2000]rule 10 deny any //拒绝任意
[Huawei]user-interface vty 0 4 //进入接口
[Huawei-ui-vty0-4]acl 2000 inbound //应用ACL
[Huawei]dis acl all //查看所有ACL
[Huawei]dis acl 2000 //查看ACL2000
高级ACL:3000-3999
[Huawei]acl 3000 //配置高级ACL
[Huawei-acl-adv-3000]rule permit ip source 1.1.1.1 0 destination 4.4.4.4 0 //允许访问
[Huawei]user-interface vty 0 4 //进入虚拟接口
[Huawei-ui-vty0-4]acl 3000 outbound //应用acl
[Huawei]int g0/0/1 //进入接口
[Huawei-G0/0/1]tracffic-filter inbound acl 3000 //应用
[Huawei]dis acl all //查看所有ACL
路由器NAT协议配置
多对少
[Huawei]acl 2001 //配置ACL
[Huawei-acl-basic-2001]rule 5 permit source 172.17.1.0 0.0.0.255 //内部IP
[Huawei]int g0/0/1 //进入接口
[Huawei-GigabitEthernet0/0/0]nat outbound 2001 address-group 1 no-pat //应用NAT
[Huawei]dis nat outbound //查看NAT
一对一
[Huawei]int g0/0/1 //进入接口
[Huawei-GigabitEthernet0/0/0]nat static global 202.169.10.5 inside 172.16.1.1 //一对一转化
多对一:
[Huawei]int g0/0/1 //进入接口
[Huawei-GigabitEthernet0/0/0]nat outbound 2001 //多对一转换
[Huawei]dis nat static //查看静态NAT
三层交换VLAN路由
[Huawei] int vlanif 10 //进入接口
[Huawei-Vlanif10]ip add 192.168.1.254 24 //配IP
[Huawei]int vlanif 20 //进入接口
[Huawei-Vlanif20]ip add 192.168.2.254 24 //配IP
[Huawei]dis ip interface brief //接口简略信息
[Huawei]dis port vlan //接口VLAN信息
[Huawei]dis vlan //查看VLAN信息
单臂路由VLAN通信
[Huawei-G0/0/1.1]ip add 192.168.1.254 24 //配IP
[Huawei-G0/0/1.1]dot1q terminnation vid 10 //封装
[Huawei-G0/0/1.1]arp broadcast enable //开启ARP
[Huawei]dis ip interface brief //查看接口
[Huawei]dis ip routing-table //查看路由器
[Huawei]display current-configuration //查看配置