vlan和trunk配置实验
实验拓扑图
实验需求
1.配置pc的IP地址
2.在sw1和sw2上分别创建vlan10和vlan20,要求pc3和pc5输入vlan10,pc4和pc6属于vlan20
3.sw1和sw2相连的接口配置为trunk类型,运行vlan10和vlan20通过
4.测试效果,同一vlan的设备可以互通,不同vlan无法互通
实验配置
1.pc配置IP地址
pc3
pc4
pc5
pc6
此时在pc3上测试发现都可以互通
[H3C]ping 192.168.1.2 Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL_C to break 56 bytes from 192.168.1.2: icmp_seq=0 ttl=255 time=1.558 ms 56 bytes from 192.168.1.2: icmp_seq=1 ttl=255 time=1.223 ms 56 bytes from 192.168.1.2: icmp_seq=2 ttl=255 time=1.262 ms 56 bytes from 192.168.1.2: icmp_seq=3 ttl=255 time=0.782 ms 56 bytes from 192.168.1.2: icmp_seq=4 ttl=255 time=0.881 ms --- Ping statistics for 192.168.1.2 --- 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss round-trip min/avg/max/std-dev = 0.782/1.141/1.558/0.280 ms [H3C]%Oct 28 09:40:06:313 2024 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.1.2: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 0.782/1.141/1.558/0.280 ms. ping 192.168.1.3 Ping 192.168.1.3 (192.168.1.3): 56 data bytes, press CTRL_C to break 56 bytes from 192.168.1.3: icmp_seq=0 ttl=255 time=2.652 ms 56 bytes from 192.168.1.3: icmp_seq=1 ttl=255 time=1.327 ms 56 bytes from 192.168.1.3: icmp_seq=2 ttl=255 time=1.620 ms 56 bytes from 192.168.1.3: icmp_seq=3 ttl=255 time=1.613 ms 56 bytes from 192.168.1.3: icmp_seq=4 ttl=255 time=1.599 ms --- Ping statistics for 192.168.1.3 --- 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss round-trip min/avg/max/std-dev = 1.327/1.762/2.652/0.458 ms [H3C]%Oct 28 09:40:13:650 2024 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.1.3: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 1.327/1.762/2.652/0.458 ms. ping 192.168.1.4 Ping 192.168.1.4 (192.168.1.4): 56 data bytes, press CTRL_C to break 56 bytes from 192.168.1.4: icmp_seq=0 ttl=255 time=2.925 ms 56 bytes from 192.168.1.4: icmp_seq=1 ttl=255 time=1.097 ms 56 bytes from 192.168.1.4: icmp_seq=2 ttl=255 time=1.724 ms 56 bytes from 192.168.1.4: icmp_seq=3 ttl=255 time=1.552 ms 56 bytes from 192.168.1.4: icmp_seq=4 ttl=255 time=1.180 ms --- Ping statistics for 192.168.1.4 --- 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss round-trip min/avg/max/std-dev = 1.097/1.696/2.925/0.657 ms [H3C]%Oct 28 09:40:20:535 2024 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.1.4: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 1.097/1.696/2.925/0.657 ms.
2.在sw1和sw2上分别创建vlan10和vlan20
<H3C>system-view System View: return to User View with Ctrl+Z. [H3C]sysname sw1 [sw1]vlan 10 [sw1-vlan10]vlan 20 [sw1-vlan20] <H3C>system-view System View: return to User View with Ctrl+Z. [H3C]sysname sw2 [sw2]vlan 10 [sw2-vlan10]vlan 20 [sw2-vlan20]
3.将对应接口加入vlan
[sw1]vlan 10 [sw1-vlan10]port GigabitEthernet 1/0/1 [sw1-vlan10]vlan 20 [sw1-vlan20]port GigabitEthernet 1/0/2 [sw1-vlan20]
[sw2-vlan20]quit [sw2]vlan 10 [sw2-vlan10]port GigabitEthernet 1/0/1 [sw2-vlan10]vlan 20 [sw2-vlan20]port GigabitEthernet 1/0/2 [sw2-vlan20]
4.配置trunk端口
[sw1]interface GigabitEthernet 1/0/3 [sw1-GigabitEthernet1/0/3]port link-type trunk [sw1-GigabitEthernet1/0/3]port trunk permit vlan 10 20
[sw2]interface GigabitEthernet 1/0/3 [sw2-GigabitEthernet1/0/3]port link-type trunk [sw2-GigabitEthernet1/0/3]port trunk permit vlan 10 20
5.测试结果
在pc3上ping其他pc
[H3C]ping 192.168.1.2 Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out --- Ping statistics for 192.168.1.2 --- 5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss [H3C]%Oct 28 09:49:58:254 2024 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.1.2: 5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss. [H3C] [H3C]192.168.1.3 ^ % Unrecognized command found at '^' position. [H3C]ping 192.168.1.3 Ping 192.168.1.3 (192.168.1.3): 56 data bytes, press CTRL_C to break 56 bytes from 192.168.1.3: icmp_seq=0 ttl=255 time=1.579 ms 56 bytes from 192.168.1.3: icmp_seq=1 ttl=255 time=1.443 ms 56 bytes from 192.168.1.3: icmp_seq=2 ttl=255 time=1.402 ms 56 bytes from 192.168.1.3: icmp_seq=3 ttl=255 time=1.266 ms 56 bytes from 192.168.1.3: icmp_seq=4 ttl=255 time=1.816 ms --- Ping statistics for 192.168.1.3 --- 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss round-trip min/avg/max/std-dev = 1.266/1.501/1.816/0.186 ms [H3C]%Oct 28 09:50:12:310 2024 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.1.3: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 1.266/1.501/1.816/0.186 ms. [H3C]ping 192.168.1.4 Ping 192.168.1.4 (192.168.1.4): 56 data bytes, press CTRL_C to break Request time out Request time out --- Ping statistics for 192.168.1.4 --- 3 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss [H3C]%Oct 28 09:50:28:816 2024 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.1.4: 3 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss.