跳转至

思科路由交换指令

Cisco路由器DHCP配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
R1#config t
R1(config)#interface FastEthernet0/1 //进入接口模式
R1(config-if)#ip address 192.168.1.1 255.255.255.0 //配置接口F0/1的IP地址
R1(config-if)#no shutdown //激活接口
R1(config-if)#exit
R1(config)#ip dhcp pool vlan 3 //添加地址池vlan3
R1(dhcp-config)#network 192.168.3.0 255.255.255.0 //指定地址池范围
R1(dhcp-config)#default-router 192.168.3.254 255.255.255.0 //指定地址池vlan 3中网关地址
R1(dhcp-config)#dns-server 192.168.2.1 //指定地址池vlan 3中DNS服务器地址
R1(dhcp-config)#lease 0 8 0 //指定地址池vlan 3地址租约时间为8小时(格式:lease days hours minites) 
R1(dhcp-config)#exit
R1(config)#ip dhcp pool vlan 4
R1(dhcp-config)#network 192.168.4.0 255.255.255.0
R1(dhcp-config)#default-router 192.168.4.254 255.255.255.0
R1(dhcp-config)#dns-server 192.168.2.1
R1(dhcp-config)#lease 0 8 0
R1(dhcp-config)#exit //地址池vlan4相关命令的解析与vlan3的解析类似,此处不赘述
R1(config)#ip dhcp excluded-address 192.168.3.1 192.168.3.10
R1(config)#ip dhcp excluded-address 192.168.3.254 // 排除掉不能分配的IP地址
R1(config)#ip dhcp excluded-address 192.168.4.254
R1(config)#ip route 192.168.3.0 255.255.255.0 FastEthernet0/1 //在以太网接口和VLAN3间建立一条静态路由

注意:无论思科还是华为设备,只有在ACL配置的时候使用到反码,其他时候都使用正常的掩码。

Cisco交换机VLAN配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
S1#config t
S1(config)#interface vlan2 //接入vlan2接口
S1(config-if)#ip address 192.168.2.254 255.255.255.0 //配置vlan2接口IP地址(此处配置可以得知,192.168.2.0/24隶属于vlan2,以及服务器vlan是vlan2)
S1(config-if)#no shutdown
S1(config)#interface vlan3
S1(config-if)#ip address 192.168.3.254 255.255.255.0
S1(config-if)#ip helper-address 192.168.1.1 //指定DHCP服务器IP地址
S1(config-if)# no shutdown
S1(config)#interface vlan4
……
S1(config)#interface f1/1
S1(config-if)#switchport mode trunk //开启端口模式为trunk
S1(config-if)#switchport trunk allowed vlan all //trunk链路允许所有vlan 流量通过
S1(config-if)#exit
S1(config)#interface f1/2
S1(config-if)#switchport mode access //指定接口为接入(access)模式
S1(config-if)#switchport access vlan 2 //指定接口隶属于vlan2
S1(config-if)#exit
S1(config)#interface f1/5
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 4 //指定接口隶属于vlan4
S1(config-if)#exit
S1(config)#interface f1/9
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 3 //指定接口隶属于vlan3
S1(config-if)#exit

捐赠本站(Donate)

weixin_pay
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))