ensp中不同Vlan之间相互ping通

  • 拓扑图

  • 需求:

  pc之间相互ping通

  • vlan划分:
    PC VLAN   IP   网关
    PC1        10     192.168.1.1   192.168.1.254
    PC2 20       192.168.2.2        192.168.2.254
    PC3 50        192.168.5.3      192.168.5.254
    PC4 30   192.168.3.4        192.168.3.254
    PC5 40         192.168.4.5        192.168.4.254
    PC6 50   192.168.5.6    192.168.5.253
  • 配置SW1
    system-view
    sysname SW1
    ///关闭警告信息
    undo info-center enable
    ///创建vlan
    vlan batch 10 20 50
    interface Vlanif10
     ip address 192.168.1.254 255.255.255.0 
    interface Vlanif20
     ip address 192.168.2.254 255.255.255.0 
    interface Vlanif50
     ip address 192.168.5.254 255.255.255.0 
    interface GigabitEthernet0/0/1
    ///access类型
     port link-type access
    ///只放行对应vlan
     port default vlan 10
    interface GigabitEthernet0/0/2
     port link-type access
     port default vlan 20
    interface GigabitEthernet0/0/3
     port link-type access
     port default vlan 50
    interface GigabitEthernet0/0/4
    ///trunk类型
     port link-type trunk
     ///放行所有vlan
     port trunk allow-pass vlan 2 to 4094
  • 左边可以相互ping通

  • 配置SW2
system-view
sysname SW2
undo info-center enable
vlan batch 10 30 40 50
interface Vlanif30
 ip address 192.168.3.254 255.255.255.0 
interface Vlanif40
 ip address 192.168.4.254 255.255.255.0 
interface Vlanif50
//这里不可以再用254,所以使用253
 ip address 192.168.5.253 255.255.255.0 
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 30
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 40
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 50
interface GigabitEthernet0/0/4
 port link-type trunk
 port trunk allow-pass vlan 2 to 4094
  • 右边也可以相互ping通

  • 此时左边仍不能ping通右边,vlan50之间可以相互ping通

  • 需要为SW1和SW2配置ospf

SW1:

ospf 1 router-id 1.1.1.1 
 area 0.0.0.0 
  network 192.168.0.0 0.0.255.255 

SW2:

ospf 1 router-id 2.2.2.2 
 area 0.0.0.0 
  network 192.168.0.0 0.0.255.255
  • PC全部可以相互ping通

posted @ 2022-10-18 00:15  grey-lion  阅读(1563)  评论(0编辑  收藏  举报