VLAN实验

例图:

 要求:

1.全网可达

2.PC通过DHCP获取地址

分析:

1.创建vlan

2.配置交换机access和trunk

3.配置路由器子接口

4.开启dhcp

5.全网可达

配置:

SW1:

SW1:
[sw1]vlan 10
[sw1-vlan10]q
[sw1]vlan 20
[sw1-vlan20]q
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-t	
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port de	
[sw1-GigabitEthernet0/0/1]port default vlan 10
[sw1-GigabitEthernet0/0/1]int g 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type access
[sw1-GigabitEthernet0/0/2]port de	
[sw1-GigabitEthernet0/0/2]port default vlan 20

[sw1]int g0/0/3
[sw1-GigabitEthernet0/0/3]port link	
[sw1-GigabitEthernet0/0/3]port link-ty	
[sw1-GigabitEthernet0/0/3]port link-type trunk
[sw1-GigabitEthernet0/0/3]port trunk allow-pass vlan 10 20


 SW2:

[sw2]vlan 10
[sw2-vlan10]q
[sw2]vlan 20
[sw2-vlan20]q
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-t	
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 10
[sw2-GigabitEthernet0/0/1]int g0/0/2
[sw2-GigabitEthernet0/0/2]port link-type access
[sw2-GigabitEthernet0/0/2]port default vlan 20

[sw2-GigabitEthernet0/0/2]int  g0/0/3
[sw2-GigabitEthernet0/0/3]port link-ty	
[sw2-GigabitEthernet0/0/3]port link-type trunk
[sw2-GigabitEthernet0/0/3]port trunk allow-pass vlan 10 to 20
[sw2-GigabitEthernet0/0/3]q

R1:

[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip ad	
[r1-GigabitEthernet0/0/0]ip address 192.168.10.1 24
Aug 18 2022 18:17:14-08:00 r1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip ad	
[r1-GigabitEthernet0/0/1]ip address 192.168.20.1 24
[r1-GigabitEthernet0/0/1]
Aug 18 2022 18:17:47-08:00 r1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 
[r1-GigabitEthernet0/0/1]

[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip ad	
[r1-GigabitEthernet0/0/0.1]ip address 192.168.1.254 24
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 10
Aug 18 2022 18:33:31-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]
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1-GigabitEthernet0/0/0.1]int g0/0/0.2
[r1-GigabitEthernet0/0/0.2]ip ad	
[r1-GigabitEthernet0/0/0.2]ip address 192.168.2.254 24
[r1-GigabitEthernet0/0/0.2]dot1q termination vid 20
Aug 18 2022 18:36:54-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/1.1]int g0/0/1.2
[r1-GigabitEthernet0/0/1.2]ip ad	
[r1-GigabitEthernet0/0/1.2]ip address 192.168.2.253 24
Error: The specified address conflicts with another address.
[r1-GigabitEthernet0/0/1.2]dot1q termination vid 20
[r1-GigabitEthernet0/0/1.2]arp broadcast enable

[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select int	
[r1-GigabitEthernet0/0/0.1]dhcp select interface 
[r1-GigabitEthernet0/0/0.1]dhcp server dns-l	
[r1-GigabitEthernet0/0/0.1]dhcp server dns-list 6.6.6.6
[r1-GigabitEthernet0/0/0.1]int g0/0/0.2 dhcp select int	
[r1-GigabitEthernet0/0/0.1]int g0/0/0.2
[r1-GigabitEthernet0/0/0.2]dhcp select in	
[r1-GigabitEthernet0/0/0.2]dhcp select interface 
[r1-GigabitEthernet0/0/0.2]dhcp server dns-l	
[r1-GigabitEthernet0/0/0.2]dhcp server dns-list 6.6.6.6
[r1-GigabitEthernet0/0/0.2]int g0/0/1.1

结果:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值