Score:0

How to configure routing between two network interfaces on Ubuntu

nf flag

I am utilizing Ubuntu 20.04 running on physical standalone system as a virtual router. The device is connected to two separate NIC. One of the NIC is connected to the external network the other one is connected to a switch.

The switch is configured in the following way with 802,1q vlan

VLAN 1 -> Port 2 (untagged)
       -> Port 3 (untagged)
       -> Port 4 (untagged)
       -> Port 5 (untagged)
       -> Port 8 (untagged) [connected to virtual router]

VLAN 2 -> Port 2 (untagged)
       -> Port 3 (untagged)
       -> Port 8 (untagged)   [connected to virtual router]

VLAN 3 -> Port 4 (untagged)
       -> Port 5 (untagged)
       -> Port 8 (untagged)   [connected to virtual router]

The netplan configuration on Ubuntu 20.04

network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0f1:
      dhcp4: no
      addresses: [10.1.1.184/24]
      gateway4: 10.1.1.251
      nameservers:
        addresses: [10.1.1.22, 10.1.1.23]

    enx7cc2c64309df:
      dhcp4: no
      gateway4: 10.2.2.2
      addresses: [10.2.2.1/8]

  vlans:
      vlan.2:
        id: 2
        link: enx7cc2c64309df
      vlan.3:
        id: 3
        link: enx7cc2c64309df

I need to able to access devices running on the external network from the switch. I tried adding the following network interface

auto enx7cc2c64309df
iface enx7cc2c64309df inet static
    address 10.2.2.1
    netmask 255.0.0.0
    gateway 10.2.2.2
    up ip route add 10.1.1.0/24 via 10.1.1.251

Then ran the following command:

sudo ip link set enx7cc2c64309df up

However I am unable to ping devices running on the other device.

I am not sure if I need to setup a DHCP server or not or if my switch configuration is correct.

Any suggestion would be greatly appreciated.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.