Updating Ubuntu Server 17.10 to use Static IP

A recent problem I came across was setting my Nginx server which is running Ubuntu Server 17.10 to use a static IP address. The normal approach of editing /etc/network/interfaces wasn’t working so I gave up on it and let DHCP do its thing, this worked fine until my Hyper-V server rebooted and then Nginx got a different address which broke my port forwarding rules and all sites nginx was hosting. After some digging around it turns out things are different in 17.10 and configuring network interfaces is done by editing  /etc/netplan/01-netcfg.yaml (a different yaml file exists for each interface you have). Once editing in your favourite editor you can set it to something like the following:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
 version: 2
 renderer: networkd
     dhcp4: no
     dhcp6: no
     addresses: []
       addresses: [,]

Then save the file and run the following command to apply the changes

sudo netplan apply


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.