One of the most precious commands I ever learned to use in Linux is ifconfig and route .
They have saved my life in configuring the static IP based internet of numerous Desktop Linux computers & notebooks.
Though the usage is very much known by most of the people who are into Linux, I believe it’s likely that the newer people who entered the world of Linux or some Unix system administrators are still lacking the knowledge on how to manually configure their eth0 lan card, thus I thought it might be handy for someone to share it, I know that for most unix users & admins especially the advanced ones this post might be funny, so if you’re an advanced administrator just skip the post and don’t laught at it 😉
Now the universal commands (works on each and every Linux host) to configure manually static IP internet connection on Linux are:
linux:~# /sbin/ifconfig eth0 192.168.0.3 netmask 255.255.255.0
linux:~# /sbin/route add default gw 192.168.0.1
linux:~# echo 'nameserver 192.168.0.1' >> /etc/resolv.conf
I’ve used this simple commands on thousands ot Linux hosts and it’s still handy 🙂
In above example 192.168.0.3 is the static IP address provided by the ISP, netmask is the netmask and the second /sbin/route add default gw would set the default gateway to the example ip 192.168.0.1
The third final line would add up a resolver nameserver the Linux host would use.