VLAN实验拓扑图
实验需求
1.PC1、PC2属于VLAN 2
2.PC2、PC4属于VLAN 3
3.通过DHCP使得PC获取IP地址信息
4.全网可达
基本配置
AR1
[R1]dhcp enable
[R1]ip pool vlan2
[R1-ip-pool-vlan2]network 192.168.2.0 mask 24
[R1-ip-pool-vlan2]gateway-list 192.168.2.254
[R1-ip-pool-vlan2]dns-list 8.8.8.8
[R1]ip pool vlan3
[R1-ip-pool-vlan3]network 192.168.3.0 mask 24
[R1-ip-pool-vlan3]gateway-list 192.168.3.254
[R1-ip-pool-vlan3]dns-list 8.8.8.8
[R1]int g 0/0/0.1
[R1-GigabitEthernet0/0/0.1]ip add 192.168.2.254 24
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[R1-GigabitEthernet0/0/0.1]arp broadcast enable
[R1-GigabitEthernet0/0/0.1]dhcp select global
[R1]int g 0/0/0.2
[R1-GigabitEthernet0/0/0.2]ip address 192.168.3.254 24
[R1-GigabitEthernet0/0/0.2]dot1q termination vid 3
[R1-GigabitEthernet0/0/0.2]arp broadcast enable
[R1-GigabitEthernet0/0/0.2]dhcp select global
LSW1
[sw1]vlan batch 2 3
[sw1]interface GigabitEthernet 0/0/3
[sw1-GigabitEthernet0/0/3]port link-type access
[sw1-GigabitEthernet0/0/3]port default vlan 2
[sw1]interface GigabitEthernet 0/0/4
[sw1-GigabitEthernet0/0/4]port link-type access
[sw1-GigabitEthernet0/0/4]port default vlan 3
[sw1]interface GigabitEthernet 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type trunk
[sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 3
[sw1]interface GigabitEthernet 0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
LSW2
[sw2]vlan batch 2 3
[sw2]interface GigabitEthernet 0/0/2
[sw2-GigabitEthernet0/0/2]port link-type access
[sw2-GigabitEthernet0/0/2]port default vlan 2
[sw2]interface GigabitEthernet 0/0/3
[sw2-GigabitEthernet0/0/3]port link-type access
[sw2-GigabitEthernet0/0/3]port default vlan 3
[sw2]interface GigabitEthernet 0/0/1
[sw2-GigabitEthernet0/0/1]port link-type trunk
[sw2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
pc端通过DHCP获得IP地址
PC1
PC2
PC3![](https://i-blog.csdnimg.cn/direct/3f2f8a8fc5384cd8ad7fd28619539537.png)
PC4
全网可达
PC1
PC>ping 192.168.2.252
Ping 192.168.2.252: 32 data bytes, Press Ctrl_C to break
From 192.168.2.252: bytes=32 seq=1 ttl=128 time=63 ms
From 192.168.2.252: bytes=32 seq=2 ttl=128 time=62 ms
From 192.168.2.252: bytes=32 seq=3 ttl=128 time=63 ms
From 192.168.2.252: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.2.252: bytes=32 seq=5 ttl=128 time=47 ms
--- 192.168.2.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/56/63 ms
PC>ping 192.168.3.252
Ping 192.168.3.252: 32 data bytes, Press Ctrl_C to break
From 192.168.3.252: bytes=32 seq=1 ttl=127 time=94 ms
From 192.168.3.252: bytes=32 seq=2 ttl=127 time=94 ms
From 192.168.3.252: bytes=32 seq=3 ttl=127 time=93 ms
From 192.168.3.252: bytes=32 seq=4 ttl=127 time=94 ms
From 192.168.3.252: bytes=32 seq=5 ttl=127 time=110 ms
--- 192.168.3.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 93/97/110 ms
PC>ping 192.168.3.253
Ping 192.168.3.253: 32 data bytes, Press Ctrl_C to break
From 192.168.3.253: bytes=32 seq=1 ttl=127 time=93 ms
From 192.168.3.253: bytes=32 seq=2 ttl=127 time=63 ms
From 192.168.3.253: bytes=32 seq=3 ttl=127 time=78 ms
From 192.168.3.253: bytes=32 seq=4 ttl=127 time=62 ms
From 192.168.3.253: bytes=32 seq=5 ttl=127 time=79 ms
--- 192.168.3.253 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 62/75/93 ms
PC2
PC>ping 192.168.2.253
Ping 192.168.2.253: 32 data bytes, Press Ctrl_C to break
From 192.168.2.253: bytes=32 seq=1 ttl=127 time=93 ms
From 192.168.2.253: bytes=32 seq=2 ttl=127 time=63 ms
From 192.168.2.253: bytes=32 seq=3 ttl=127 time=78 ms
From 192.168.2.253: bytes=32 seq=4 ttl=127 time=78 ms
From 192.168.2.253: bytes=32 seq=5 ttl=127 time=78 ms
--- 192.168.2.253 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 63/78/93 ms
PC>ping 192.168.2.252
Ping 192.168.2.252: 32 data bytes, Press Ctrl_C to break
From 192.168.2.252: bytes=32 seq=1 ttl=127 time=109 ms
From 192.168.2.252: bytes=32 seq=2 ttl=127 time=94 ms
From 192.168.2.252: bytes=32 seq=3 ttl=127 time=94 ms
From 192.168.2.252: bytes=32 seq=4 ttl=127 time=93 ms
From 192.168.2.252: bytes=32 seq=5 ttl=127 time=110 ms
--- 192.168.2.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 93/100/110 ms
PC>ping 192.168.3.252
Ping 192.168.3.252: 32 data bytes, Press Ctrl_C to break
From 192.168.3.252: bytes=32 seq=1 ttl=128 time=63 ms
From 192.168.3.252: bytes=32 seq=2 ttl=128 time=62 ms
From 192.168.3.252: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.3.252: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.3.252: bytes=32 seq=5 ttl=128 time=47 ms
--- 192.168.3.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/53/63 ms