When I make a Debian Linux box, I start with it as a DHCP client and let it get the network settings automatically. This tip is to help me remember where to change them when I want to switch to a static IP.
This is for the Debian Linux (Woody and Sarge).
There will be some stuff about
lo (the loopback interface), which should be left alone.
Then there is an
ethn section for each network card (i.e.
eth1 and so on). The examples all use
DHCP network cards will have a line like:
iface eth0 inet dynamic
Statically configured network cards will have a section like:
iface eth0 inet static address local address netmask subnet mask network network address, usually the lowest address on your subnet gateway gateway's IP address, usually the one greater than lowest address on your subnet broadcast network broadcast address, usually the highest address on your subnet dns-nameservers server1 server2 dns-search defaultdomain
Note that the indent is a single tab, not spaces.
Here is an example:
iface eth0 inet static address 192.168.1.101 netmask 255.255.255.0 network 192.168.1.0 gateway 192.168.1.1 broadcast 192.168.1.255 dns-nameservers 18.104.22.168 22.214.171.124 dns-search example.net
After making the change, run
ifdown eth0 and then
To check the current configuration, run
Note that in Ubuntu 12.04, this is configured with the
dns-search lines above. Changes to
be overwritten when you restart.
search default domain name nameserver DNS server ip address
The default domain is used when you only type in one word (i.e. when you try to resolve
mail.example.com, you should use
example.com as the default domain.
You can have multiple
nameserver lines if you have backup name servers. Only one will be used though, it does
not search all of them.
Here is an example (using OpenDNS):
search example.com nameserver 126.96.36.199 nameserver 188.8.131.52