例图:
需求:
1、PC1、PC3属于VLAN 2
2、PC2、PC4属于VLAN 3
3、通过DHCP使得pc获取IP地址信息
4.全网可达
分析:
1.vlan配置
2.ip配置
3.DHCP
4.检验
过程:
1.vlan配置
[lsw1]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[lsw1]int g 0/0/3
[lsw1-GigabitEthernet0/0/3]port link-type access
[lsw1-GigabitEthernet0/0/3]port default vlan 2
[lsw1-GigabitEthernet0/0/3]q
[lsw1]int g 0/0/4
[lsw1-GigabitEthernet0/0/4]port link-type acc
[lsw1-GigabitEthernet0/0/4]port link-type access
[lsw1-GigabitEthernet0/0/4]port default vlan 3
[lsw1-GigabitEthernet0/0/4]int g 0/0/2
[lsw1-GigabitEthernet0/0/2]port li t
[lsw1-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 3
[lsw1-GigabitEthernet0/0/2]int g 0/0/1
[lsw1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[lsw2]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[lsw2]int GigabitEthernet 0/0/2
[lsw2-GigabitEthernet0/0/2]port link-type access
[lsw2-GigabitEthernet0/0/2]port default vlan 2
[lsw2-GigabitEthernet0/0/2]int g 0/0/3
[lsw2-GigabitEthernet0/0/3]port link-type access
[lsw2-GigabitEthernet0/0/3]port li t
[lsw2-GigabitEthernet0/0/3]port link-type access
[lsw2-GigabitEthernet0/0/3]port default vlan 3
[lsw2-GigabitEthernet0/0/3]int g 0/0/1
[lsw2-GigabitEthernet0/0/1]port link-type trunk
[lsw2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
2.ip配置和DHCP
[r1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[r1]ip pool vlan2
Info: It's successful to create an IP address pool.
[r1-ip-pool-vlan2]network 192.168.2.0 mask 24
[r1-ip-pool-vlan2]gateway-list 192.168.2.254
[r1-ip-pool-vlan2]dns-list 8.8.8.8
[r1-ip-pool-vlan2]q
[r1]ip pool vlan3
Info: It's successful to create an IP address pool.
[r1-ip-pool-vlan3]network 192.168.3.0 mask 24
[r1-ip-pool-vlan3]gateway-list 192.168.3.254
[r1-ip-pool-vlan3]dns-list 8.8.8.8
[r1-ip-pool-vlan3]q
[r1]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip add 192.168.2.254 24
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
Error: This interface is not a termination interface.
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
Jul 27 2024 18:43:36-08:00 r1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0.1 has entered the UP state.
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1-GigabitEthernet0/0/0.1]dhcp select global
[r1-GigabitEthernet0/0/0.1]q
[r1]int g 0/0/0.2
[r1-GigabitEthernet0/0/0.2]ip address 192.168.3.254 24
[r1-GigabitEthernet0/0/0.2]dot1q termination vid 3
Jul 27 2024 18:45:42-08:00 r1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/0.2 has entered the UP state.
[r1-GigabitEthernet0/0/0.2]arp broadcast enable
[r1-GigabitEthernet0/0/0.2]dhcp select global
3.检验