This tutorial is for anyone who wants to use a static ip instead of dhcp. Let’s face it, having a server using dhcp is a bad idea.
First we need to edit
$ sudo nano /etc/network/interfaces
Typically if you’re using dhcp, your file would look something like the below. Keep in mind the interfaces may be different. For example if you’re using wireless you may see
ath0; we’re primarily just looking for the interface you want to change
# 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
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp
In this case, we want to change
eth0. Simply change
static and append some additional network info.
We’re going to need the IP address of that we want to use, the network mask which is typically
255.255.255.0, the network id, broadcast ip, and your gateway – which is typically your router's IP. All of which can be found using any other machine on your network: using
ipconfig /all on any windows box or
ifconfig on any *nix machine.
iface eth0 inet static
Once you’ve made the proper changes and saved the file, can you either reboot or restart your nic
sudo /etc/init.d/networking restart
Originally published at seanwragg.com on March 18, 2008.