要求:
代码:
[sw1-GigabitEthernet0/0/1]port link-type trunk ① 设g0/0/1为 trunk链路
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all 允许所有vlan通过
[sw1-GigabitEthernet0/0/2]port link-type access ②设g0/0/2 为access链路
[sw1-GigabitEthernet0/0/2]port default vlan 2 设该接口属于vlan 2
[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 3
[sw1-GigabitEthernet0/0/5]port link-type access 同②
[sw1-GigabitEthernet0/0/5]port default vlan 3
[sw1-GigabitEthernet0/0/6]port link-type trunk 同①
[sw1-GigabitEthernet0/0/6]port trunk allow-pass vlan all
(g0/0/0.2和g0/0/0.3配置与下方g0/0/0.1相同)
[r1]interface g0/0/0.1 进入g0/0/0.1虚拟接口
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2 接口使用802.1q帧且属于vlan 2
[r1-GigabitEthernet0/0/0.1]ip address 192.168.1.1 24 设置接口ip(网关)
[r1-GigabitEthernet0/0/0.1]arp broadcast enable 开启arp
[r1]dhcp enable 开启DHCP
[r1]ip pool aa 创ip 池 aa池
[r1-ip-pool-aa]network 192.168.1.0 mask 24 宣告网段在aa池
[r1-ip-pool-aa]gateway-list 192.168.1.1 网关再设了一遍
[r1-ip-pool-aa]dns-list 8.8.8.8 设根服务器
[r1]interface g0/0/0.1 进入g0/0/0.1虚拟接口
[r1-GigabitEthernet0/0/0.1]dhcp select global 接口开启DHCP服务
[r1]interface g0/0/0.2 同上
[r1-GigabitEthernet0/0/0.2]dhcp select global
[r1]interface g0/0/0.3 同上
[r1-GigabitEthernet0/0/0.3]dhcp select global
同上(发现PC3,4,5没有自动配置ip,于是多添加2个ip池)感觉是因为之前配置了接口ip的问题
[r1]ip pool bb
[r1-ip-pool-bb]network 192.168.2.0 mask 24
[r1-ip-pool-bb]gateway-list 192.168.2.1
[r1]ip pool cc 同上
[r1-ip-pool-cc]network 192.168.3.0 mask 24
[r1-ip-pool-cc]gateway-list 192.168.3.1
ping通: