HowTo Configure Inter-VLAN Routing on Mellanox Switches

Version 5

    This post presents an example of configuring inter-VLAN routing on Mellanox switches without enabling routing protocols.

     

    References

     

    Setup

     

    1.png

    This setup example features three servers and a switch, with each server being part part of a different network (VLAN).

    These are the link parameters for this example:

     

    ServerVLANServer IP AddressSwitch port mode
    Switch port
    Switch IP Interface
    Switch IP
    S1111.11.11.1/24access (untagged)1/2Interface VLAN 111.11.11.5/24
    S2212.12.12.1/24trunk (tagged)1/2Interface VLAN 212.12.12.5/24
    S3313.13.13.1/24no switchport (router port)1/3Router port

    13.13.13.5/24

     

    Router port or VLAN interface have similar usage, but are different:

    • Router port
      • Router port is enabled on Ethernet interface using the command "no switchport"
      • Traffic to and from the router port can egress only one interface
      • There is an option to add VLAN tag for the router port
    • VLAN interface
      • VLAN interface is enabled using the command "interface vlan <id>"
      • Traffic to and from the VLAN interface can egress all ports to which this VLAN is assigned

     

    Switch Configuration

    1. Create the three VLANs. Run:

    switch(config) # vlan 1-3

    switch(config) vlan 1-3 # exit

     

    2. Enable IP routing. Run:

    switch (config) # ip routing

     

    3. Configure the switch port mode per interface. Run:

    switch (config) # interface ethernet 1/1 switchport mode access

    switch (config) # interface ethernet 1/1 switchport access vlan 1

    switch (config) # interface ethernet 1/2 switchport mode trunk

    switch (config) # interface ethernet 1/2 switchport trunk allowed-vlan 2     ;  it is also possible to "allowed-vlan all" to allow all VLANs on this interface

    switch (config) # interface ethernet 1/3 no switchport force

     

    4. Create VLAN interfaces 1 and 2, and assign an IP address to the three IP interfaces. Run:

    switch (config) # interface vlan 1

    switch (config)  interface vlan 1 # ip address 11.11.11.5 /24

    switch (config)  interface vlan 1 # no shutdown

    switch (config)  interface vlan 1 # exit

    switch (config) # interface vlan 2

    switch (config)  interface vlan 2 # ip address 12.12.12.5 /24

    switch (config)  interface vlan 2 # no shutdown

    switch (config)  interface vlan 2 # exit

    switch (config) # interface ethernet 1/3 ip address 13.13.13.5/24

     

    5. In order to be able to ping one server from the other, make sure to set the default gateway per network. There are different ways to do so. Here is one example for server S1:

    # ifconfig eth2 11.11.11.1/24 up

    # route add -net 12.12.12.0 -gw 11.11.11.5

    # route add -net 13.13.13.0 -gw 11.11.11.5

     

    6. Display IP route on the switch. Run:

    switch (config)  # show ip route

    ...

    11.11.11.0        255.255.255.0     0.0.0.0           vlan1             direct            0/0  

    12.12.12.0        255.255.255.0     0.0.0.0           vlan2             direct            0/0     

    13.13.13.0        255.255.255.0     0.0.0.0           eth1/3            direct            0/0     

     

     

    7. Make sure you can ping each server.