vlan间路由--三层交换机实现vlan间通信

接上片

三层交换机实现vlan间通信

 LSW1看成是三层交换机

[core_sw]vlan batch 100 200
[core_sw]interface GigabitEthernet 0/0/1
[core_sw-GigabitEthernet0/0/1]port link-type trunk
[core_sw-GigabitEthernet0/0/1]port trunk allow-pass vlan 100 200
[core_sw]interface Vlanif 100 //进入vlanif模式,直接配置ip地址。当然该接口工作的前提是:有接口被划入了该接口vlan或者trunk链路允许了该vlan通过
[core_sw-Vlanif100]ip address 192.168.1.254 24
[core_sw]interface Vlanif 200    
[core_sw-Vlanif200]ip address 192.168.2.254 24
[core_sw]display port vlan active 
T=TAG U=UNTAG
---------------------------------------------------------------------
Port                Link Type    PVID    VLAN List
---------------------------------------------------------------------
GE0/0/1             trunk        1       U: 1
[core_sw]display interface brief                                         T: 100 200
InUti/OutUti: input utility/output utility
Interface                   PHY   Protocol InUti OutUti   inErrors  outErrors
GigabitEthernet0/0/1        up    up          0%     0%          0          0
GigabitEthernet0/0/2        down  down        0%     0%          0          0
MEth0/0/1                   down  down        0%     0%          0          0
NULL0                       up    up(s)       0%     0%          0          0
Vlanif1                     up    down        --     --          0          0
Vlanif100                   up    up          --     --          0          0
Vlanif200                   up    up          --     --          0          0
[core_sw]display ip routing-table 
Route Flags: R - relay, D - download to fib
---------------------------------------------------------------------
Routing Tables: Public
         Destinations : 6        Routes : 6        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    192.168.1.0/24  Direct  0    0           D   192.168.1.254   Vlanif100
  192.168.1.254/32  Direct  0    0           D   127.0.0.1       Vlanif100
    192.168.2.0/24  Direct  0    0           D   192.168.2.254   Vlanif200
  192.168.2.254/32  Direct  0    0           D   127.0.0.1       Vlanif200

查看vlanif配置

[core_sw]display interface Vlanif
Vlanif1 current state : UP
Line protocol current state : DOWN
Description:
Route Port,The Maximum Transmit Unit is 1500
Internet protocol processing : disabled
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cc1d-698d
Current system time: 2020-05-29 15:05:44-08:00
    Input bandwidth utilization  : --
    Output bandwidth utilization : --

Vlanif100 current state : UP
Line protocol current state : UP
Last line protocol up time : 2020-05-29 14:56:00 UTC-08:00
Description:
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.1.254/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cc1d-698d
Current system time: 2020-05-29 15:05:44-08:00
    Input bandwidth utilization  : --
    Output bandwidth utilization : --

Vlanif200 current state : UP
Line protocol current state : UP
Last line protocol up time : 2020-05-29 14:56:00 UTC-08:00
Description:
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.2.254/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cc1d-698d
Current system time: 2020-05-29 15:05:44-08:00
    Input bandwidth utilization  : --
    Output bandwidth utilization : --

二层交换机LSW2配置

[sw1]vlan batch 100 200
[sw1]interface Eth0/0/1
[sw1-Ethernet0/0/1]port link-type trunk//与三层交换机连接,配置trunk模式
[sw1-Ethernet0/0/1]port trunk allow-pass vlan 100 200 //允许vlan 100,200通过
[sw1]interface Eth0/0/2
[sw1-Ethernet0/0/2]port link-type access
[sw1-Ethernet0/0/2]port default vlan 100
[sw1]interface Eth0/0/3
[sw1-Ethernet0/0/3]port link-type access
[sw1-Ethernet0/0/3]port default vlan 200
[sw1]display port vlan active 
T=TAG U=UNTAG
---------------------------------------------------------------------
Port                Link Type    PVID    VLAN List
---------------------------------------------------------------------
Eth0/0/1            trunk        1       U: 1
                                         T: 100 200
Eth0/0/2            access       100     U: 100
Eth0/0/3            access       200     U: 200
Eth0/0/4            hybrid       1       U: 1

Pc1配置,ping网关和pc2

 

 现网应用最多的方案是单臂路由(适合中小型企业网络)和VLANIF(适合于大中型企业网络)

原文地址:https://www.cnblogs.com/yhq1314/p/13071060.html