Friday, December 7, 2007

Ubuntu 6.06 Server LTS Part II - Configure The Network with Static IP

By default, the Ubuntu installer has configured our system to get its IP address and other network settings via DHCP. This is not what we want so we have to change the server to have a static IP address. Edit /etc/network/interfaces and adjust it per your requirements. For this example we are using an IP address of 192.168.167.210 for this server.


Now, there are a myriad of examples on the web and I am including a few links to them for convenience sake in case they explain this better. (they probably do) ;o)

vi /etc/network/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.167.210
netmask 255.255.255.0
network 192.168.167.0
broadcast 192.168.167.255
gateway 192.168.167.1

Now, restart your network:

/etc/init.d/networking restart

Then edit /etc/hosts. We are telling the server what names it is going to answer to and to which IP addresses those names belong. This is somewhat analogous to the Windows hosts file if you are familiar with Windows:

vi /etc/hosts

127.0.0.1       localhost.localdomain localhost
192.168.0.100 server1.example.com server1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Now execute the following commands.

hostname
hostname -f

The results from both commands should show server1.example.com. If they do not, reboot the system:

shutdown -r now

Log back into your server and try the hostname commands again.

hostname
hostname -f

They should show server1.example.com.

Now for those links I promised:

Link 1 on cyberciti.biz
Link 2 on howtogeek.com
Link 3 on howtoforge.com

Blessings

No comments: