Debian and Ubuntu Networking Configuration /etc/network/interfaces with a Static IP Address

This is easy to find anywhere, and it’s here too. This one includes the dns-* lines that will be read by resolvconf(8).

root@server:/etc/network# cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.251
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
dns-nameservers 192.168.1.250
dns-search mydomain.local

Also, here’s a cheatsheet for setting that netmask:

255.255.255.252  /30    2  nodes
255.255.255.248  /29    6  nodes
255.255.255.240  /28   14  nodes
255.255.255.224  /27   30  nodes
255.255.255.192  /26   62  nodes
255.255.255.128  /25  126  nodes
255.255.255.0    /24 "Class C" 254 nodes

Note that the number of nodes is the total number of addresses, less two. It’s less two because the lowest value is the address of the entire network. The highest value is the broadcast address. So if the netmask is 0, then the lowest value is 0, and that’s the address of the network, and the highest value is 255, which is the broadcast address.

Was this helpful?

0 / 0

Leave a Reply