Tuesday, 12 January 2010

configure IP adress with Linux

Well windows is quite straightforward when it comes to fixing up an ip address ... Linux is even more :)

open the file /etc/network/interfaces with sudo privileges in text editor and then edit accordingly

$ sudo gedit /etc/network/interfaces

Now copy paste the following :


# 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
allow-hotplug eth0
iface eth0 inet static # (specify the interface, eth0 is the default ethernet, static tells that the ip address is static)
address 10.108.10.131 #(ip address you want to configure)
netmask 255.255.255.0 #(the subnet mask if any)
network 10.108.10.0 #(the network mask, optional)
broadcast 10.108.10.255 #(the broadcast adress, optional )
gateway 10.108.10.2 #( the default gateway )
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 144.16.192.55 # (the dns server address)



Now this configuration can be done for iface wlan0 in case of a wireless connection...

Now issue the following commands at terminal :

$ sudo ifdown eth0
$ sudo ifup eth0

$sudo ifconfig :
to check the new ip address

this resets the ethernet and sets the static ip specified.

for Dynamic ip setting via DHCP, just give the command :

$ sudo dhclient

This would search for DHCP servers on all configured interfaces and set the ip addresses automatically if any found.

No comments: