vlan实验

vlan实验_第1张图片​​​​​​​

 

1.PC1和pC3所在接口为access;属于 vlan2;
  pc2/4/5/6处于同一网段;其中pc2可以访问pc4/5/6;但p4可以访问pc5,不能访问pc6
2.PC5不能访问pc6
3.PC1/3与PC2/4/5/6不在同一个网段
4.所有pc通过DHCP获取IP地址,且pC1/3可以正常访问pc2/4/5/6

配置vlan

[sw1]vlan batch 2 to 5

[sw1-GigabitEthernet0/0/1]port link-type t-----定义sw1链接路由器的接口为trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass  vlan 2 3----允许携带2和3的标签的数据传送


 [sw1-GigabitEthernet0/0/1]int g 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type hybrid 
[sw1-GigabitEthernet0/0/2]port hybrid pvid vlan 3--- 接口PVID为3
[sw1-GigabitEthernet0/0/2]port hybrid tagged vlan 2
[sw1-GigabitEthernet0/0/2]port hybrid untagged vlan 1 3


[sw1-GigabitEthernet0/0/3]port link-type access 
[sw1-GigabitEthernet0/0/3]port default vlan 2

[sw1-GigabitEthernet0/0/4]port link-type access 
[sw1-GigabitEthernet0/0/4]port default vlan 2

[sw2-GigabitEthernet0/0/1]port link-type hybrid 
[sw2-GigabitEthernet0/0/1]port hybrid  pvid  vlan 1	
[sw2-GigabitEthernet0/0/1]port hybrid  tagged  vlan 2
[sw2-GigabitEthernet0/0/1]port hybrid  untagged  vlan 1 4 5



[sw2-GigabitEthernet0/0/2]port link-type trunk 
[sw2-GigabitEthernet0/0/2]port trunk allow-pass vlan 4 5


[sw2-GigabitEthernet0/0/3]port link-type access 
[sw2-GigabitEthernet0/0/3]port default  vlan  2


[sw2-GigabitEthernet0/0/4]port link-type hybrid 
[sw2-GigabitEthernet0/0/4]port hybrid  pvid  vlan  4
[sw2-GigabitEthernet0/0/4]port hybrid untagged vlan 1 4
[sw2-GigabitEthernet0/0/4]
[sw3-GigabitEthernet0/0/1]port link-type trunk 
[sw3-GigabitEthernet0/0/1]port trunk allow-pass  vlan 4 5



[sw3-GigabitEthernet0/0/2]port link-type hybrid 
[sw3-GigabitEthernet0/0/2]port hybrid  pvid  vlan  4
[sw3-GigabitEthernet0/0/2]port hybrid  untagged vlan 1 4



[sw3-GigabitEthernet0/0/3]port link-type hybrid 
[sw3-GigabitEthernet0/0/3]port hybrid pvid  vlan 5
[sw3-GigabitEthernet0/0/3]port hybrid  untagged vlan 1 5

配置R1,并开启DHCP

[r1-GigabitEthernet0/0/0]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip add 12.1.1.1 24
[r1-GigabitEthernet0/0/0.1]dot1q termination  vid 2
[r1-GigabitEthernet0/0/0.1]arp broadcast enable 



[r1-GigabitEthernet0/0/0.1]int g 0/0/0.2
[r1-GigabitEthernet0/0/0.2]ip add 13.1.1.1 24
[r1-GigabitEthernet0/0/0.2]dot1q  termination vid 3
[r1-GigabitEthernet0/0/0.2]arp broadcast  enable 


启动DHCP服务并配置
[r1]dhcp enable 
[r1]ip pool one
[r1-ip-pool-one]network 12.1.1.0 mask 24
[r1-ip-pool-one]gateway-list 12.1.1.1
[r1-ip-pool-one]dns-list 114.114.114.114


[r1]ip pool two
[r1-ip-pool-two]network 13.1.1.0 mask 24
[r1-ip-pool-two]gateway-list 13.1.1.1
[r1-ip-pool-two]dns-list 8.8.8.8



接口调用
[r1-GigabitEthernet0/0/0.1]dhcp  select global 

[r1-GigabitEthernet0/0/0.2]dhcp select global 

PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fed8:7c97
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 12.1.1.254
Subnet mask.......................: 255.255.255.0
Gateway...........................: 12.1.1.1
Physical address..................: 54-89-98-D8-7C-97
DNS server........................: 114.114.114.114


PC>
ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fe02:7305
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 13.1.1.254
Subnet mask.......................: 255.255.255.0
Gateway...........................: 13.1.1.1
Physical address..................: 54-89-98-02-73-05
DNS server........................: 8.8.8.8


PC>

PC>
ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fefb:75b8
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 12.1.1.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 12.1.1.1
Physical address..................: 54-89-98-FB-75-B8
DNS server........................: 114.114.114.114


PC>
PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fef5:2b6e
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 13.1.1.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 13.1.1.1
Physical address..................: 54-89-98-F5-2B-6E
DNS server........................: 8.8.8.8


PC>
PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fe54:7761
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 13.1.1.252
Subnet mask.......................: 255.255.255.0
Gateway...........................: 13.1.1.1
Physical address..................: 54-89-98-54-77-61
DNS server........................: 8.8.8.8


PC>
PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fe84:29c
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 13.1.1.251
Subnet mask.......................: 255.255.255.0
Gateway...........................: 13.1.1.1
Physical address..................: 54-89-98-84-02-9C
DNS server........................: 8.8.8.8


PC>

测试网络是否通畅

在R1上测试


Ping 13.1.1.254: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 13.1.1.254: bytes=32 seq=2 ttl=127 time=63 ms
From 13.1.1.254: bytes=32 seq=3 ttl=127 time=78 ms
From 13.1.1.254: bytes=32 seq=4 ttl=127 time=94 ms
From 13.1.1.254: bytes=32 seq=5 ttl=127 time=62 ms

--- 13.1.1.254 ping statistics ---
  5 packet(s) transmitted
  4 packet(s) received
  20.00% packet loss
  round-trip min/avg/max = 0/74/94 ms

PC>ping -c 3 13.1.1.253 
Bad argument: 3

PC>ping 13.1.1.253 -c 3

Ping 13.1.1.253: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 13.1.1.253: bytes=32 seq=2 ttl=127 time=109 ms
From 13.1.1.253: bytes=32 seq=3 ttl=127 time=125 ms

--- 13.1.1.253 ping statistics ---
  3 packet(s) transmitted
  2 packet(s) received
  33.33% packet loss
  round-trip min/avg/max = 0/117/125 ms

PC>ping 13.1.1.251 -c 3

Ping 13.1.1.251: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 13.1.1.251: bytes=32 seq=2 ttl=127 time=125 ms
From 13.1.1.251: bytes=32 seq=3 ttl=127 time=94 ms

--- 13.1.1.251 ping statistics ---
  3 packet(s) transmitted
  2 packet(s) received
  33.33% packet loss
  round-trip min/avg/max = 0/109/125 ms

PC>

在R2上测试

PC>ping 13.1.1.253 -c 3

Ping 13.1.1.253: 32 data bytes, Press Ctrl_C to break
From 13.1.1.253: bytes=32 seq=1 ttl=128 time=47 ms
From 13.1.1.253: bytes=32 seq=2 ttl=128 time=47 ms
From 13.1.1.253: bytes=32 seq=3 ttl=128 time=47 ms

--- 13.1.1.253 ping statistics ---
  3 packet(s) transmitted
  3 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 47/47/47 ms

PC>ping 13.1.1.252 -c 3

Ping 13.1.1.252: 32 data bytes, Press Ctrl_C to break
From 13.1.1.252: bytes=32 seq=1 ttl=128 time=78 ms
From 13.1.1.252: bytes=32 seq=2 ttl=128 time=79 ms
From 13.1.1.252: bytes=32 seq=3 ttl=128 time=62 ms

--- 13.1.1.252 ping statistics ---
  3 packet(s) transmitted
  3 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 62/73/79 ms

PC>ping 13.1.1.251 -c 3

Ping 13.1.1.251: 32 data bytes, Press Ctrl_C to break
From 13.1.1.251: bytes=32 seq=1 ttl=128 time=78 ms
From 13.1.1.251: bytes=32 seq=2 ttl=128 time=78 ms
From 13.1.1.251: bytes=32 seq=3 ttl=128 time=63 ms

--- 13.1.1.251 ping statistics ---
  3 packet(s) transmitted
  3 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 63/73/78 ms

PC>

在R4上测试

PC>ping 13.1.1.254 -c 3

Ping 13.1.1.254: 32 data bytes, Press Ctrl_C to break
From 13.1.1.254: bytes=32 seq=1 ttl=128 time=62 ms
From 13.1.1.254: bytes=32 seq=2 ttl=128 time=63 ms
From 13.1.1.254: bytes=32 seq=3 ttl=128 time=47 ms

--- 13.1.1.254 ping statistics ---
  3 packet(s) transmitted
  3 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 47/57/63 ms

PC>ping 13.1.1.252 -c 3

Ping 13.1.1.252: 32 data bytes, Press Ctrl_C to break
From 13.1.1.252: bytes=32 seq=1 ttl=128 time=62 ms
From 13.1.1.252: bytes=32 seq=2 ttl=128 time=47 ms
From 13.1.1.252: bytes=32 seq=3 ttl=128 time=47 ms

--- 13.1.1.252 ping statistics ---
  3 packet(s) transmitted
  3 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 47/52/62 ms

PC>ping 13.1.1.251 -c 3

Ping 13.1.1.251: 32 data bytes, Press Ctrl_C to break
From 13.1.1.253: Destination host unreachable
From 13.1.1.253: Destination host unreachable
From 13.1.1.253: Destination host unreachable

--- 13.1.1.251 ping statistics ---
  3 packet(s) transmitted
  0 packet(s) received
  100.00% packet loss

PC>

你可能感兴趣的:(网络)