1 实验拓扑
2 交换机配置
Switch>
Switch>en
Switch#sw1
Switch#config t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw1
sw1(config)#vlan 2
sw1(config-vlan)#exit
sw1(config)#vlan 3
sw1(config-vlan)#exit
sw1(config)#int gigabitEthernet 1/0/1
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 2
sw1(config-if)#exit
sw1(config)#int gigabitEthernet 1/0/2
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 3
sw1(config-if)#exit
sw1(config)#int gigabitEthernet 1/0/3
sw1(config-if)#switchport mode trunk
sw1(config-if)#no shut
sw1(config-if)#end
sw1#w
Building configuration...
Compressed configuration from 7383 bytes to 3601 bytes[OK]
3 路由器配置
Router>en
Router#config t
Router(config)#hostname r1
r1(config)#int gigabitEthernet 0/0
r1(config-if)#no ip address
r1(config-if)#no shutdown
r1(config)#int gigabitEthernet 0/0.2
r1(config-subif)#encapsulation dot1Q 2
r1(config-subif)#ip address 192.168.2.1 255.255.255.0
r1(config-subif)#exit
r1(config)#int gigabitEthernet 0/0.3
r1(config-subif)#encapsulation dot1Q 3
r1(config-subif)#ip address 192.168.3.1 255.255.255.0
r1(config-subif)#exit
r1(config)#
r1(config)#service dhcp
r1(config)#ip dhcp pool vlan2
r1(dhcp-config)#network 192.168.2.0 255.255.255.0
r1(dhcp-config)#default-router 192.168.2.1
r1(dhcp-config)#exit
r1(config)#ip dhcp pool vlan3
r1(dhcp-config)#network 192.168.3.0 255.255.255.0
r1(dhcp-config)#default-router 192.168.3.1
r1(dhcp-config)#exit
r1(config)#ip dhcp excluded-address 192.168.2.1
r1(config)#ip dhcp excluded-address 192.168.3.1
r1(config)#end
r1#w
Building configuration...
[OK]
4 pc 配置
5 pc1 ping pc2
标签:8.2,r1,packet,exit,192.168,dhcp,sw1,DHCP,config From: https://blog.csdn.net/tonyhi6/article/details/139722766