adding static ip and routes to /etc/interface in debian 10 “buster”

“The times they are a-changing” – Bob Dylan

however grave the problems were that dylan addressed in his song and 1963 album, he certainly didn’t envision how linux distributions like debian are a-changing the way in which we have to configure our network settings. if we look at how we define static ip addresses, we can see quite some dylan-esque transitions. and when you need to persistently define static routes, keeping up-to-date can be at least hard.

it’s been hardly nine months since my post about static routes in debian 9 when that method has been marked as “deprecated” and won’t actually work anymore in debian 10 “buster”. So here’s how to do both static ip and static routes in buster:

the good thing is, it’s now all in one file. just edit /etc/network/interfaces. for the not-so daring types, make a backup before the edit:

> sudo cp /etc/network/interfaces /etc/network/interfaces.orig

> sudo vi /etc/network/interfaces

an out-of-the-box install will most certainly have dhcp configured. So for static ip, we comment out (or delete) these lines:

# allow-hotplug ens18
# iface ens18 inet dhcp

ens18 is the interface name in this example. that can be eth0 or en0 or something else in your case.

In order to set the static ipv4 address for the machine, insert this:

# static ip address on interface ens18 (or whatever the name):
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-domain fritz.box
dns-nameservers 192.168.1.1 8.8.8.8

…of course you have to adapt the adress scheme to your network setup.

right after this we’ll add the static route which has been moved from the route system command to the more general ip tool:

# for a network route:
up /bin/ip route add 192.168.10.0/24 via 192.168.1.10

# and for a host route:
up /bin/ip route add 192.168.10.10/32 via 192.168.1.10

of course you know that the latter – a host route – is merely a special case of the more general classless routing notation above…

ok, my little furry creatures. till next time in our series “fun with the a-changing linux concept of static routes”.

Leave a Reply

Your email address will not be published.

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