1.vlan的创建
[LSW1]vlan batch 2 to 6
[LSW2]vlan batch 2 to 6
2.接口划分vlan
1.SW1接口划分
[LSW1]int Ethernet0/0/1
[LSW1-Ethernet0/0/1]port link-type access
[LSW1-Ethernet0/0/1]port default vlan 2
[LSW1]interface Ethernet0/0/2
[LSW1-Ethernet0/0/2]port link-type hybrid
[LSW1-Ethernet0/0/2]port hybrid pvid vlan 3
[LSW1-Ethernet0/0/2]port hybrid untagged vlan 3 4 5 6
[LSW1]interface Ethernet0/0/3
[LSW1-Ethernet0/0/3]port link-type access
[LSW1-Ethernet0/0/3]port default vlan 2
[LSW1]interface Ethernet0/0/4
[LSW1-Ethernet0/0/4]port link-type hybrid
[LSW1-Ethernet0/0/4]port hybrid pvid vlan 4
[LSW1-Ethernet0/0/4]port hybrid untagged vlan 3 4
[LSW1]interface Ethernet0/0/6
[LSW1-Ethernet0/0/6]port link-type hybrid
[LSW1-Ethernet0/0/6]port hybrid untagged vlan 3 4 5 6
[LSW1-Ethernet0/0/6]port hybrid tagged vlan 2
2.SW2接口划分
[LSW2]interface Ethernet0/0/2
[LSW2-Ethernet0/0/2]port link-type hybrid
[LSW2-Ethernet0/0/2]port hybrid pvid vlan 5
[LSW2-Ethernet0/0/2]port hybrid untagged vlan 3 5
[LSW2]interface Ethernet0/0/3
[LSW2-Ethernet0/0/3]port link-type hybrid
[LSW2-Ethernet0/0/3]port hybrid pvid vlan 6
[LSW2-Ethernet0/0/3]port hybrid untagged vlan 3 6
3.配置trunk干道
[LSW1]interface Ethernet0/0/5
[LSW1-Ethernet0/0/5]port link-type trunk
[LSW1-Ethernet0/0/5]port trunk allow-pass vlan all
[LSW2]interface Ethernet0/0/1
[LSW2-Ethernet0/0/1]port link-type trunk
[LSW2-Ethernet0/0/1]port trunk allow-pass vlan all
4.配置子接口
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.1.1 24
[r1-GigabitEthernet0/0/0]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip add 192.168.2.1 24
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
5.DHCP
[r1]ip pool 1
[r1-ip-pool-1]network 192.168.1.0 mask 24
[r1-ip-pool-1]gateway-list 192.168.1.1
[r1-ip-pool-1]dns-list 114.114.114.114
[r1-ip-pool-1]q
[r1]ip pool 2
[r1-ip-pool-2]network 192.168.2.0 mask 24
[r1-ip-pool-2]gateway-list 192.168.2.1
[r1-ip-pool-2]dns-list 114.114.114.114
[r1-ip-pool-2]q
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]dhcp select global
[r1-GigabitEthernet0/0/0]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
6.检测
1.PC1可以访问PC2/4/5/6
PC>ping 192.168.2.251
Ping 192.168.2.251: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.251: bytes=32 seq=2 ttl=127 time=94 ms
From 192.168.2.251: bytes=32 seq=3 ttl=127 time=46 ms
From 192.168.2.251: bytes=32 seq=4 ttl=127 time=79 ms
From 192.168.2.251: bytes=32 seq=5 ttl=127 time=78 ms
PC>ping 192.168.2.253
Ping 192.168.2.253: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.253: bytes=32 seq=2 ttl=127 time=78 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
PC>ping 192.168.2.252
Ping 192.168.2.252: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.252: bytes=32 seq=2 ttl=127 time=125 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=94 ms
From 192.168.2.252: bytes=32 seq=5 ttl=127 time=94 ms
PC>ping 192.168.2.254
Ping 192.168.2.254: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.254: bytes=32 seq=2 ttl=127 time=78 ms
From 192.168.2.254: bytes=32 seq=3 ttl=127 time=94 ms
From 192.168.2.254: bytes=32 seq=4 ttl=127 time=78 ms
From 192.168.2.254: bytes=32 seq=5 ttl=127 time=109 ms
2.PC2可以访问4/5/6
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=128 time=47 ms
From 192.168.2.253: bytes=32 seq=2 ttl=128 time=31 ms
From 192.168.2.253: bytes=32 seq=3 ttl=128 time=32 ms
From 192.168.2.253: bytes=32 seq=4 ttl=128 time=31 ms
From 192.168.2.253: bytes=32 seq=5 ttl=128 time=31 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=128 time=47 ms
From 192.168.2.252: bytes=32 seq=2 ttl=128 time=47 ms
From 192.168.2.252: bytes=32 seq=3 ttl=128 time=62 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=78 ms
PC>ping 192.168.2.254
Ping 192.168.2.254: 32 data bytes, Press Ctrl_C to break
From 192.168.2.254: bytes=32 seq=1 ttl=128 time=62 ms
From 192.168.2.254: bytes=32 seq=2 ttl=128 time=63 ms
From 192.168.2.254: bytes=32 seq=3 ttl=128 time=62 ms
From 192.168.2.254: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.2.254: bytes=32 seq=5 ttl=128 time=63 ms
3.PC4不能访问5
PC>ping 192.168.2.252
Ping 192.168.2.252: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
4.PC5不能访问PC6
PC>ping 192.168.2.254
Ping 192.168.2.254: 32 data bytes, Press Ctrl_C to break
From 192.168.2.252: Destination host unreachable
From 192.168.2.252: Destination host unreachable
From 192.168.2.252: Destination host unreachable
From 192.168.2.252: Destination host unreachable
From 192.168.2.252: Destination host unreachable