Unofficial Azure ClubAn independent cloud journal Search

Field Notes D02

Configure Ubuntu to Support Multiple NICs in Azure

Configure Ubuntu to Support Multiple NICs in Azure

By default, in Linux, if multiple NICs are in the same subnet, all traffic will route through the default NIC, which is usually eth0. If multiple NICs are added, and you need to route traffic back through the NIC that received it, you need to create a routing table for that NIC. Refer to How to create a Linux virtual machine in Azure with multiple network interface cards.

The /etc/sysconfig/network-scripts path used in older RHEL/CentOS guidance does not apply to Ubuntu. The example below uses Ubuntu’s older ifupdown configuration; newer installations commonly use Netplan. Replace the interface name, subnet, private IP, and gateway with your VM’s values, and use the equivalent policy-routing configuration for your network manager.

sudo -i
bash -c "echo '200 eth1-rt' >> /etc/iproute2/rt_tables"
vi /etc/network/interfaces.d/eth1.cfg
# Configure second NIC and populate new routing table 
auto eth1
iface eth1 inet dhcp
    post-up ip route add 10.0.1.0/24 dev eth1 src 10.0.1.5 table eth1-rt
    post-up ip route add default via 10.0.1.1 dev eth1 table eth1-rt
    post-up ip rule add from 10.0.1.5/32 table eth1-rt
    post-up ip rule add to 10.0.1.5/32 table eth1-rt