Ubuntu 18.04 setting up network on secondary interface

Chris asked:

I’ve got a VM running Ubuntu 18.04 – it’s all setup and running on a single public IP and has two interfaces – ens160 (public) & ens192 (private).

My interface ens160 is already fully configured. However, when I try and setup ens192 and apply the settings with netplan apply, ens160 stops pinging externally.

ifconfig –

ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 78.111.203.13  netmask 255.255.255.224  broadcast 78.111.203.31
        inet6 fe80::250:56ff:feb2:ac74  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:b2:ac:74  txqueuelen 1000  (Ethernet)
        RX packets 8761053  bytes 3882588408 (3.8 GB)
        RX errors 0  dropped 242551  overruns 0  frame 0
        TX packets 10449256  bytes 4654699595 (4.6 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::250:56ff:feb2:3d74  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:b2:3d:74  txqueuelen 1000  (Ethernet)
        RX packets 242552  bytes 14553120 (14.5 MB)
        RX errors 0  dropped 227391  overruns 0  frame 0
        TX packets 7256  bytes 2349506 (2.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 9194  bytes 2309681 (2.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9194  bytes 2309681 (2.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Here’s the configuration file 50-cloud-init.yaml I’m attempting below –

network:
    ethernets:
        ens160:
            addresses:
            - 78.111.203.13/27
            gateway4: 78.111.203.1
            nameservers:
                addresses:
                - 8.8.8.8
                - 8.8.4.4
                search: []
            optional: true
        ens192:
            addresses: 
            - 10.0.203.13/27
            gateway4: 10.0.203.1
            optional: true
    version: 2

As soon as I run netplan try, I can no longer ping my external IP 78.111.203.13 until the timeout and the network resets itself. Interestingly though, I can still ping the external IP from other VM’s within the network – I’m not sure if that means anything?

The newly configured internal IP also begins pinging within the network – what I’d expect.

I hope you can help!

Chris.

My answer:


The default gateway is the address of the router which will route packets for which you don’t have routes defined already. About 99% of the time, this is the router which will provide your system access to the Internet. Any host will have exactly one of these (per protocol) in a normal configuration.

You’ve defined two, so one conflicts with and overrides the other. Because it is not your gateway to the Internet, you should remove it again.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.