VLAN实验
实验图
需求
判断pc是否在同一网段
划分广播域,全网可达
先配交换机
实验与配置内容
创建VLAN
[sw1]vlan batch 10 20
[sw2]vlan batch 10 20
将接口划入VLAN
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/2]port link-type access
[sw1-GigabitEthernet0/0/1]p d v 10
[sw1-GigabitEthernet0/0/2]p d v 20
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/2]port link-type access
[sw2-GigabitEthernet0/0/1]p d v 10
[sw2-GigabitEthernet0/0/2]p d v 20
配置Trunk干道
[sw1-GigabitEthernet0/0/3]port link-type trunk
[sw1-GigabitEthernet0/0/3]port trunk allow-pass vlan 10 20
[sw2-GigabitEthernet0/0/3]port link-type trunk
[sw2-GigabitEthernet0/0/3]port trunk allow-pass vlan 10 20
路由器配置
[r1]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip a 192.168.1.10 24
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 10 ----声明该子接口所能处理的VLAN标签
[r1-GigabitEthernet0/0/0.1]arp broadcast enable -----开启子接口ARP广播功能
[r1]int g 0/0/0.2
[r1-GigabitEthernet0/0/0.2]ip a 192.168.2.10 24
[r1-GigabitEthernet0/0/0.2]dot1q termination vid 20
[r1-GigabitEthernet0/0/0.2]arp broadcast enable
[r1]int g 0/0/1.1
[r1-GigabitEthernet0/0/1.1]ip a 192.168.3.10 24
[r1-GigabitEthernet0/0/1.1]dot1q termination vid 10
[r1-GigabitEthernet0/0/1.1]arp broadcast enable
[r1]int g 0/0/1.2
[r1-GigabitEthernet0/0/1.2]ip a 192.168.4.10 24
[r1-GigabitEthernet0/0/1.2]dot1q termination vid 20
[r1-GigabitEthernet0/0/1.2]arp broadcast enable
开启DHCP并配置地址池
[r1]dhcp enable
[r1]ip pool 1
[r1-ip-pool-1]network 192.168.1.0 mask 24
[r1-ip-pool-1]gateway-list 192.168.1.10
[r1-ip-pool-1]dns-list 8.8.8.8
[r1]ip pool 2
[r1-ip-pool-2]network 192.168.2.0 mask 24
[r1-ip-pool-2]gateway-list 192.168.2.10
[r1-ip-pool-2]dns-list 8.8.8.8
[r1]ip pool 3
[r1-ip-pool-3]network 192.168.3.0 mask 24
[r1-ip-pool-3]gateway-list 192.168.3.10
[r1-ip-pool-3]dns-list 8.8.8.8
[r1]ip pool 4
[r1-ip-pool-4]network 192.168.4.0 mask 24
[r1-ip-pool-4]gateway-list 192.168.4.10
[r1-ip-pool-4]dns-list 8.8.8.8
[r1]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
[r1-GigabitEthernet0/0/0.1]int g 0/0/0.2
[r1-GigabitEthernet0/0/0.2]dhcp select global
[r1-GigabitEthernet0/0/0.2]int g 0/0/1.1
[r1-GigabitEthernet0/0/1.1]dhcp select global
[r1-GigabitEthernet0/0/1.1]int g 0/0/1.2
[r1-GigabitEthernet0/0/1.2]dhcp select global
pc利用DHCP获取地址
pc1
pc2
pc3
pc4
结果测试
以pc1为例