01 November 2012

HOW TO CONFIGURE NETWORK CONNECTION FROM COMMAND LINE


STEP 1) ASSIGN IP ADDRESS AND GATEWAY

Although, we have got a wonderful tool "NetworkManager" to manage our interface connection from GUI,but when we are using console then how to manage those interfaces and configuring them becomes a headache for a naive linux user.These are the following steps you should follow in order to configure your interface properly.
 

[user@linux:~]$ifconfig eth0 192.168.1.10 netmask 255.255.255.0
To add the default gateway in the routing table type --
[user@linux:~]$route add default gw 192.168.1.254
[user@linux:~]$route -n  (to print the routing info table on terminal)
or we can also use
[user@linux:~]$netstat -anr


STEP 2) ASSIGN DNS SERVER

Here I will use "8.8.8.8" , because it one of the most use public DNS  address.
You are free to choose any.

[user@linux:~]$echo "nameserver 8.8.8.8" > /etc/resolv.conf


Now a little hack, suppose you want to change your Mac Address, then that can be 
done in very easily from command line (not like windows where first you have to find 
some software and then had to pay for it...)

[user@linux ~]$ifconfig eth0 down hw ether 00:11:1a:2b:3c:33
                                       (give the new ethernet address)
[user@linux ~]$ifconfig eth0 up

To restore the original MAC address give the following commands : -

[user@linux ~]$ifconfig eth0 down
[user@linux ~]$ifconfig eth0 up

No comments:

Post a Comment