How to have permanent, custom network settings on Ubuntu 17.10 on GCE.

1,035 views
Skip to first unread message

Nick Kakouros

unread,
Feb 10, 2018, 8:15:43 AM2/10/18
to gce-discussion
Until recently, I was using Ubuntu 16.04. There I had set a custom dns server and a secondary ip address.

The custom dns server was added through resolvconf/resolv.conf.d/head and it got prepended over GCE's dns server in /etc/resolv.conf. Just to be sure, I also added a 'prepend-domain-name-servers' in /etc/dhcp/dhclient.conf.

The secondary ip address was totally arbitrary and added through dchclient.conf using an alias for the 'ens4' interface.

Today, I updated my images to Ubuntu 17.10. And the above stopped working. I managed to get the custom dns server in place, by adding a 'DNS=' line in /etc/systemd/resolved.conf. But I cannot add a secondary ip address properly. I have the same alias in dhclient.conf and after I edit the file I use 'dhclient -r; dhclient' to renew the lease and have my alias enforced. But if I reboot, the secondary ip is gone from the interface.

The last thing I tried was to edit /etc/netplan/50-cloud-init.yml, set the static configuration there and also add custom ip routes. But I haven't found a way to make the routes persist reboot.

Could someone help me and tell me if the above approach is the right one and how I could have a static, custom secondary ip address on Ubuntu 17.10 that survives reboots?

Nick Kakouros

unread,
Feb 10, 2018, 9:07:29 AM2/10/18
to gce-discussion
Also, setting a route in the netplan yml file does not work:


            dhcp4
: no
            addresses
:
             
- 10.254.0.6/32
            gateway4
: 10.254.0.1
            nameservers
:
              search
:
               
- "c.en2720-2017.internal."
               
- "google.internal."
              addresses
:
               
- 169.254.169.254
            match
:
                macaddress
: 42:01:0a:fe:00:06
           
set-name: ens4
            routes
:
             
- to: 0.0.0.0/0
                via
: 10.254.0.1
                metric
: 1

This will complain that the network is unreachable when adding the route. (In the excerpt above, I just try to have a working static configuration without any secondary ip addresses).

Nick Kakouros

unread,
Feb 10, 2018, 10:27:46 AM2/10/18
to gce-discussion
I managed to make it work. The issue with the routes was that I was adding the IP address of the interface with a /32 subnet as defined by GCE's dhcp lease. But then no default route to the specified gateway was created by netplan as the gateway was out of the 1-host subnet the /32 mask implied. I changed the mask to /20 and it worked! No additional routes needed. However, I don't know if the /20 mask will create any problem (as opposed to the /32 mask that GCE uses), I guess not, but it would be nice to have confirmation from someone.

Carlos (Cloud Platform Support)

unread,
Feb 10, 2018, 7:08:00 PM2/10/18
to gce-dis...@googlegroups.com
I am glad you found a workaround. 

There is an old discussion in serverfault  where changing the mask on Centos 7 did not work. In any case there is a request to further explain on the documentation the DHCP behaviour. 

Mathieu Trudel-Lapierre

unread,
Feb 12, 2018, 9:50:37 AM2/12/18
to gce-discussion
On Saturday, February 10, 2018 at 10:27:46 AM UTC-5, Nick Kakouros wrote:
I managed to make it work. The issue with the routes was that I was adding the IP address of the interface with a /32 subnet as defined by GCE's dhcp lease. But then no default route to the specified gateway was created by netplan as the gateway was out of the 1-host subnet the /32 mask implied. I changed the mask to /20 and it worked! No additional routes needed. However, I don't know if the /20 

Right, this is a known shortcoming (the lack on "onlink" routes) of netplan for now. I've already started working on fixing that.


Don't hesitate to join #netplan on irc.freenode.org when you have issues or questions with netplan.

Whatever is in /etc/netplan directory as .yaml files will persist across reboots, the configs get regenerated and applied at early boot, and then systemd-networkd will attempt to bring up the network.

Nick Kakouros

unread,
Feb 12, 2018, 12:50:47 PM2/12/18
to gce-discussion
Alright, thank you for the link!
Reply all
Reply to author
Forward
0 new messages