Static Network configuration in Ubuntu Linux using systemd

With Ubuntu 15.04 Vivid Vervet,  systemd has replaced Upstart as the standard boot and service manager.   Personally, I like to set my my network interfaces up statically, and usually uninstall network manager completely.

Prior to Vived Vervet, static network configuration took place in the /etc/network/interfaces file.  However upon upgrading, I noticed my interfaces would stop and fail to restart due  (i believe) to systemd. So I decided to switch to a pure systemd static network configuration. This configuration has been rock solid for me every since, and hopefully it will help you.

In systemd you create init scripts in the /etc/systemd folder (and its subfolders). In particular, static network configuration scripts are created in the /etc/systemd/network folder.

The most common type of script is the .network script.  For example, if your network interface is called eth0, and you want it to connect via DHCP client to obtain a lease, you may create a the file /etc/systemd/network/eth0.network with the following contents:


[Match]
Name=eth10

[Network]
DHCP=ipv4

[DHCPv4]
UseRoutes=true
UseHostname=false
UseDNS=true

 

 

 

Once a configuration script is created, you enable it by running:

systemctl enable (initscriptname)

In the case of

 

Bookmark the permalink.

Leave a Reply

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