Linux Server Diary

The trials and tribulations of a Linux newbie trying to setup a home server.

Friday, November 03, 2006

Assign a Static IP

To assign a static IP in Ubuntu, modify the file /etc/network/interfaces.

But first, pick an address that is not in the pool used for your DHCP server (probably in your router - the user manual should help you with this). The gateway should be set to the router's internal network address. It is likely that your settings will differ from mine.
Get the current settings
ifconfig eth0 (Note the Mask setting)
Open the file with VI
sudo vi etc/network/interfaces
Find the primary network interface configuration
auto eth0
iface eth0 inet dhcp
Change to the static settings
auto eth0
iface eth0 inet static
address 192.168.254.1
netmask 255.255.255.0
gateway 192.168.254.254
Save the file
Restart the network interface
sudo /etc/init.d/networking restart
Check the interface by pinging your router
ping 192.168.254.254 (use your gateway address here - CTRL-C to stop the ping)
Alternatively, you can ping a public server, such as Google
ping www.google.com

Now that a static IP is assigned, add a line to the hosts file on the client machines to assign a name to the server. (If you are using a local DNS, you're way beyond my level!)

NOTE: I should note that I really hate the editor VI. As soon as learn about another command line editor, I'll never use it again. Until then, I'm using this cheatsheet page of commands.

Labels:

0 Comments:

Post a Comment

<< Home