华为交换机、路由器 配置命令总结

配置交换机的CONSOLE口登录口令为123456

[S1]user-interface console 0 [S1-ui-console0]authentication-mode password [S1-ui-console0]set authentication password cipher 123456 [S1-ui-console0]q

配置aaa认证,telnet认证,权限等级为3

[R1]aaa
[R1-aaa]local-user huawei password cipher 123456
Info: Add a new user.
[R1-aaa]local-user shangwen privilege level 3
Info: Add a new user.
[R1-aaa]local-user shangwen service-type telnet
[R1-aaa]user-interface vty 0 4
[R1-ui-vty0-4]authentication-mode aaa
[R1-ui-vty0-4]quit

配置单臂路由

[R1]int  g0/0/1.1
[R1-GigabitEthernet0/0/1.1]ip add 192.168.10.62 26
[R1-GigabitEthernet0/0/1.1]dot1q termination vid 10
[R1-GigabitEthernet0/0/1.1]arp broadcast enable

配置easy-ip和NAT-server

[R1]acl 2000
[R1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R1-acl-basic-2000]q
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]nat outbound 2000
[R1-GigabitEthernet0/0/1]nat server global 202.11.1.5 inside 192.168.1.65 description ftp Server-Intra

ACL,禁止网段访问Internet

acl number 2001  
 rule 5 deny source 192.168.10.192 0.0.0.63 
 rule 10 deny source 192.168.10.128 0.0.0.1 
 rule 15 permit 
int g0/0/1
traffic-filter inbound acl 2001

配置OSPF路由协议,使得OSPF区域为0

[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]net 1.1.1.0 0.0.0.3
[R1-ospf-1-area-0.0.0.0]net 1.1.1.4 0.0.0.3
[R1-ospf-1-area-0.0.0.0]q

配置RIP协议,版本配置为2。关闭路由自动汇总功能

rip 1
 undo summary
 version 2
 network 192.168.1.0
 network 10.0.0.0

配置VLAN,Trunk、access

interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 10
interface GigabitEthernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan all

 
 

启用STP协议,配置LSW1为生成树的主根桥,LSW3为备份根桥。

[LSW1]stp enable
[LSW1]stp mode stp
[LSW1]stp root primary
[S3]stp enable
[S3]stp mode stp
[S3]stp root secondary

 
 

配置MSTP,域名为RG1

[SWITCH_A]stp mode mstp
[SWITCH_A]stp region-configuration
[SWITCH_A-mst-region]region-name RG1
 
 

VLAN10,VLAN20属于实例1,VLAN30,VLAN40属于实例2

[SWITCH_A-mst-region]instance 1 vlan 10 20
[SWITCH_A-mst-region]instance 2 vlan 30 40
[SWITCH_A-mst-region]active region-configuration 

实例1的根桥为LSW1;并在LSW1相应接口应用根保护功能

[SWITCH_A]stp instance 1 priority 0
[SWITCH_A]int g0/0/1
[SWITCH_A-GigabitEthernet0/0/1]stp root-protection

设备终端接口为边缘端口

int e0/0/1
stp edged-port enable
 
 

应用BPDU保护功能

stp bpdu-protection

创建聚合端口eth-trunk 1

interface Eth-Trunk 1
 port link-type trunk
 port trunk allow-pass vlan 100 200 300
interface GigabitEthernet0/0/1
 eth-trunk 1

 
 

配置DHCP服务器

首先开启DHCP服务,LSW1和LSW2上都要执行

dhcp enable

接口模式DHCP

LSW2

1、进vlanif(路由器就进接口) 2、配置接口模式 3、配置排除地址(192.168.20.200-210) 4、配置DNS服务器地址

特点:无需配置地址范围和网关(自动使用当前接口地址是掩码范围和将接口的IP设置成网关)

int vlanif 20
dhcp select int        
dhcp server excluded-ip-add 192.168.20.200 192.168.20.210
dhcp server dns-list 8.8.8.8

全局地址模式DHCP

LSW2

1、创建地址池bmA 2、配置分配的网关 3、配置分配的IP地址范围 4、配置DNS服务器 5、进vlanIF(如果是路由器,就进接口) 6、启用全局地址池

ip pool bmA
 gateway-list 192.168.10.254
 network 192.168.10.0 mask 255.255.255.0
 dns-list 192.168.10.254 8.8.8.8

interface Vlanif 1    //如果是在LSW1上配置(没有跨网段),直接vlanif 10配置即可,就能分配地址了
 dhcp select global

DHCP中继

设置成DHCP转发模式,指定DHCP服务器的地址(注意不要忘记启动dhcp enable了)

int vlanif 10
dhcp select relay
dhcp relay server-ip 192.168.2.2

DHCP的更多扩展

如果我们需要将LSW2的地址通过AC分配给AP下连接的设备,该如何操作?答:你需要在地址池中设置sub 43,然后指定AC的地址即可

ip pool bmA
option 43 sub-option 2 ip-add 192.168.10.253

 
 

配置VRRP

[R1]int g0/0/0	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 virtual-ip 192.168.1.254
[R1-GigabitEthernet0/0/0]vrrp vrid 10 priority 150
[R1-GigabitEthernet0/0/0]q
 
 

BFD配置浮动路由

[R1]ip route-static 192.168.23.0 24 192.168.12.2 
[R1]bfd
[R1-bfd]q
[R1]bfd 13 bind peer-ip 192.168.23.3 source-ip 192.168.12.1
[R1-bfd-session-13]discriminator local 1
[R1-bfd-session-13]discriminator remote 3
[R1-bfd-session-13]commit 
[R1]ip route-static 192.168.10.0 24 192.168.12.2 track bfd 13

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值