Vlanif综合案例

拓扑:

  • 需求

    1.如图配置IP地址和设备互联

    2.实现不同VLAN之间的PC互通

 

  • 思路

    1.配置终端设备

    -IP/掩码/网关

    2.配置网络设备

    -交换机:vlan/trunk/access

    -多层交换机:网关接口(vlanif)、路由

    3.验证与测试

 

PC1:
192.168.10.1
255.255.255.0
192.168.10.254

PC2:
192.168.20.2
255.255.255.0
192.168.20.254

PC3:
192.168.10.3
255.255.255.0
192.168.10.254

PC4:
192.168.30.4
255.255.255.0
192.168.30.254

PC5:
192.168.40.5
255.255.255.0
192.168.40.254

SW1:
undo terminal monitor
system-view
sysname SW1 
vlan batch 10 20 30 40 

interface gi0/0/12
port link-type trunk 
port trunk allow-pass vlan all 
quit 

interface gi0/0/21
port link-type trunk 
port trunk allow-pass vlan all 
quit 

interface gi0/0/1
port link-type access
port default vlan 10 
quit


SW2:
undo terminal monitor
system-view
sysname SW2
vlan batch 10 20 30 40 

interface gi0/0/12
port link-type trunk 
port trunk allow-pass vlan all 
quit 

interface gi0/0/21
port link-type trunk 
port trunk allow-pass vlan all 
quit 

interface gi0/0/22
port link-type trunk 
port trunk allow-pass vlan all 
quit 

interface gi0/0/23
port link-type trunk 
port trunk allow-pass vlan all 
quit 

SW3:
undo terminal monitor
system-view
sysname SW3
vlan batch 10 20 30 40 

interface gi0/0/23
port link-type trunk 
port trunk allow-pass vlan all 
quit 

interface gi0/0/5
port link-type access
port default vlan 40 
quit


SW4:
undo terminal monitor
system-view
sysname SW4
vlan batch 10 20 30 40 

interface gi0/0/1
port link-type trunk 
port trunk allow-pass vlan all 
quit

interface gi0/0/2
port link-type trunk 
port trunk allow-pass vlan all 
quit

interface eth0/0/22
port link-type trunk 
port trunk allow-pass vlan all 
quit

interface eth0/0/2
port link-type access
port default vlan 20 
quit

interface eth0/0/3
port link-type access
port default vlan 10 
quit


SW5:
undo terminal monitor
system-view
sysname SW5
vlan batch 10 20 30 40 

interface gi0/0/1
port link-type trunk 
port trunk allow-pass vlan all 
quit

interface eth0/0/22
port link-type trunk 
port trunk allow-pass vlan all 
quit

interface eth0/0/4
port link-type access
port default vlan 30 
quit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SW1:
interface vlanif 10
ip address 192.168.10.254 24
quit 


SW2:
interface vlanif 20
ip address 192.168.20.254 24
quit 

SW3:
interface vlanif 30
ip address 192.168.30.254 24
quit 
interface vlanif 40
ip address 192.168.40.254 24
quit 
-------------------------------网关之间,添加路由------------------------------

@为了实现VLAN 10 和 VLAN 20 互通,我们在 SW1/2 之间,添加一个 VLAN 12(192.168.12.0/24)

SW1:
vlan 12
quit 
interface vlanif 12
ip address 192.168.12.1 24
quit 

ip route-static  192.168.20.0  24  192.168.12.2

SW2:
vlan 12
quit 
interface vlanif 12
ip address 192.168.12.2 24
quit 

ip route-static  192.168.10.0  24  192.168.12.1

并且,此时我们直接测试 VLAN30/40 ,他们之间本来就是互通的:因为两个VLAN的网关都在SW3上。

@为了实现 VLAN10/20 与 VLAN30/40 之间互通,所以在SW2/3 之间添加一个VLAN 23(192.168.23.0/24)

SW2:
vlan 23
quit
interface vlanif 23
ip address 192.168.23.2 24 
quit 


SW3:
vlan 23
quit
interface vlanif 23
ip address 192.168.23.3 24 
quit 

-------------------在网关设备上添加彼此的路由,实现每个VLAN互通----------

SW1:
ip route-static  192.168.30.0 24  192.168.12.2
ip route-static  192.168.40.0 24  192.168.12.2
SW2:
ip route-static  192.168.30.0 24  192.168.23.3
ip route-static  192.168.40.0 24  192.168.23.3
SW3:
ip route-static  192.168.10.0 24  192.168.23.2
ip route-static  192.168.20.0 24  192.168.23.2

总结:
   想要实现全网的所有的 VLAN 的互通,必须达到一个结果 - 网络收敛。
   即:网络中的每个网关设备上,都得有整个网络中的所有的网段的路由条目。
   
注意: 【创建/添加 新的 VLAN 时,应该在所有交换机上操作。确保所有交换机的VLAN信息,一致】

   之前我们在 SW1/2 之间,添加另一个 VLAN 12 ; 
   之前我们在 SW2/3 之间,添加了一个 VLAN 23 ; 
   并且需要确保:同一个网段的两个IP地址互通(即下一跳IP必须通)。
   
   但是,你在做实验的时候,作为同网段的2个IP地址,不一定互通!!!!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值