华为交换机基本配置命令华为交换机基本配置命令一、单交换机VLAN划分命令命令解释system进入系统视图system-view进入系统视图quit退到系统视图undovlan20删除vlan20sysname交换机命名dispvlan显示vlanvlan20创建vlan(也可进入vlan20)porte1/0/1toe1/0/5把端口1-5放入VLAN20中dispvlan20显示vlan里的端口20inte1/0/24进入端口24portaccessvlan20把当前端口放入vlan20undoporte1/0/10表示删除当前VLAN端口10dispcurr显示当前配置二、配置交换机支持TELNETsystem进入系统视图sysname交换机命名intvlan1进入VLAN1ipaddress192.168.3.100255.255.255.0配置IP地址user-intvty04进入虚拟终端authentication-modepassword(autpassword)设置口令模式setauthenticationpasswordsimple222(setautpasssim222)设置口令userprivilegelevel3(useprivlev3)配置用户级别dispcurrent-configuration(dispcur)查看当前配置dispipint查看交换机VLANIP配置删除配置必须退到用户模式resetsaved-configuration(resetsaved)删除配置reboot重启交换机三、跨交换机VLAN的通讯在sw1上:vlan10建立VLAN10inte1/0/5进入端口5portaccessvlan10把端口5加入vlan10vlan20建立VLAN20inte1/0/15进入端口15portaccessvlan20把端口15加入VLAN20inte1/0/24进入端口24portlink-typetrunk把24端口设为TRUNK端口porttrunkpermitvlanall同上在SW2上:vlan10建立VLAN10inte1/0/20进入端口20portaccessvlan10把端口20放入VLAN10inte1/0/24进入端口24portlink-typetrunk把24端口设为TRUNK端口porttrunkpermitvlanall(porttrunkpermitvlan10只能为vlan10使用)24端口为所有VLAN使用dispinte1/0/24查看端口24是否为TRUNKundoporttrunkpermitvlanall删除该句四、路由的配置命令system进入系统模式sysname命名inte1/0进入端口ipaddress192.168.3.100255.255.255.0设置IPundoshutdown打开端口dispipinte1/0查看IP接口情况dispipintbrief查看IP接口情况user-intvty04进入口令模式authentication-modepassword(authpass)进入口令模式setauthenticationpasswordsimple22237设置口令userprivilegelevel3进入3级特权save保存配置resetsaved-configuration删除配置(用户模式下运行)undoshutdown配置远程登陆密码inte1/4iproute192.168.3.0(目标网段)255.255.255.0192.168.12.1(下一跳:下一路由器的接口)静态路由iproute0.0.0.00.0.0.0192.168.12.1默认路由dispiprout显示路由列表华3CAR-18E1/0(lan1-lan4)E2/0(wan0)E3/0(WAN1)路由器连接使用直通线。wan0接wan0或wan1接wan1计算机的网关应设为路由器的接口地址。五、三层交换机配置VLAN-VLAN通讯sw1(三层交换机):system进入视图sysname命名vlan10建立VLAN10vlan20建立VLAN20inte1/0/20进入端口20portaccessvlan10把端口20放入VLAN10inte1/0/24进入24端口portlink-typetrunk把24端口设为TRUNK端口porttrunkpermitvlanall(porttrunkpermitvlan10只能为vlan10使用)24端口为所有VLAN使用sw2:vlan10inte1/0/5portaccessvlan10inte1/0/24portlink-typetrunk把24端口设为TRUNK端口porttrunkpermitvlanall(porttrunkpermitvlan10只能为vlan10使用)24端口为所有VLAN使用sw1(三层交换机):intvlan10创建虚拟接口VLAN10ipaddress192.168.10.254255.255.255.0设置虚拟接口VLAN10的地址intvlan20创建虚拟接口VLAN20ipaddress192.168.20.254255.255.255.0设置虚拟接口IPVLAN20的地址注意:vlan10里的计算机的网关设为192.168.10.254vlan20里的计算机的网关设为192.168.20.254六、动态路由RIPR1:inte1/0进入e1/0端口ipaddress192.168.3.1255.255.255.0设置IPinte2/0进入e2/0端口ipadress192.168.5.1255.255.255.0设置IPrip设置动态路由network192.168.5.0定义IPnetwork192.168.3.0定义IPdispiprout查看路由接口R2:inte1/0进入e1/0端口ipaddress192.168.4.1255.255.255.0设置IPinte2/0进入e2/0端口ipadress192.168.5.2255.255.255.0设置IPrip设置动态路由network192.168.5.0定义IPnetwork192.168.4.0定义IPdispiprout查看路由接口(注意:两台PC机的网关设置PC1IP:192.168.3.1PC2IP:192.168.4.1)七、IP访问列表inte1/0ipaddress192.168.3.1255.255.255.0inte2/0ipaddress192.168.1.1255.255.255.0inte3/0ipaddress192.168.2.1255.255.255.0aclnumber2001(2001-2999属于基本的访问列表)rule1denysource192.168.1.00.0.0.255(拒绝地址192.168.1.0网段的数据通过)rule2permitsource192.168.3.00.0.0.255(允许地址192.168.3.0网段的数据通过)以下是把访问控制列表在接口下应用:firewallenablefirewalldefaultpermitinte3/0firewallpacket-filter2001outbounddispacl2001显示信息undoaclnumber2001删除2001控制列表扩展访问控制列表aclnumber3001ruledenytcpsource192.168.3.00.0.0.255destination192.168.2.00.0.0.255destination-porteqftp必须在[r-acl-adv-3001]下才能执行rulepermitipsourceandestinationany(rulepermitip)inte3/0firewallenable开启防火墙firewallpacket-filter3001inbound必须在端口E3/0下才能执行八、命令的标准访问IP列表(三层交换机):允许A组机器访问服务器内资料,不允许访问B组机器(服务器没有限制)sysvlan10nameservervlan20nameteachervlan30namestudentinte1/0/5portaccessvlan10inte1/0/10portaccessvlan20inte1/0/15portaccessvlan30intvlan10ipaddress192.168.10.1255.255.255.0undoshintvlan20ipaddress192.168.20.1255.255.255.0intvlan30ipaddress192.168.30.1255.255.255.0aclnumber2001rule1denysource192.168.30.00.0.0.255rule2permitsourceanydispacl2001查看2001列表inte1/0/10portaccessvlan20packet-filteroutboundip-group2001rule1出口九、允许A机器访问B机器的FTP但不允许访问,C机器没有任何限制。vlan10vlan20vlan30inte1/0/5portaccessvlan10inte1/0/10portaccessvlan20inte1/0/15portaccessvlan30intvlan10ipaddress192.168.10.1255.255.255.0undoshintvlan20ipaddress192.168.20.1255.255.255.0intvlan30ipaddress192.168.30.1255.255.255.0aclnumber3001rule1denytcpsource192.168.30.00.0.0.255destination192.168.10.00.0.0.255destination-porteq进口十、NAT地址转换(单一静态一对一地址转换)R1:syssysnameR1inte1/0ipaddress192.168.3.1255.255.255.0inte2/0ipaddress192.1.1.1255.255.255.0R2:syssysnameR2inte2/0ipaddress192.1.1.2255.255.255.0inte1/0ipaddress10.80.1.1255.255.255.0回到R1:natstatic192.168.3.1192.1.1.1inte2/0natoutboundstaticiproute0.0.0.00.0.0.0192.1.1.2十一、NAT内部整网段地址转换R1:syssysnameR1inte1/0ipaddress192.168.3.1255.255.255.0inte2/0ipaddress192.1.1.1255.255.255.0aclnumber2008rule0permitsource192.168.3.00.0.0.255rule1denyquitinte2/0natoutbound2008quitiproute-static0.0.0.00.0.0.0192.1.1.2preference60↑下一个路由接口地址R2:syssysnameR2inte2/0ipaddress192.1.1.2255.255.255.0inte1/0ipaddress10.80.1.1255.255.255.0NAT地址池配置:R1:syssysnameR1inte1/0ipaddress192.168.3.1255.255.255.0inte2/0ipaddress192.1.1.1255.255.255.0nataddress-group1