Friday, January 4, 2008

Static IP address in Linux

There are many occasions in which you might like to have a static ip address for you machine instead of the one generated dynamically by the router.. Maybe you want to run a webserver, or ftp server, or maybe want to SSH to your machine from any place.. Then you need to now the IP address of the machine, which is not very easy if you are not in the local network... i'm bored of reasons.. let's get to the point:

To assign ur machine a static ip address do this:

Edit /etc/network/interfaces
to have this:

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.10
network 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255

Then, restart networking

sudo /etc/init.d/networking restart

And check the new address by

ifconfig eth0 | grep "inet addr"


Done!!

No comments: