Search this site

Wednesday, February 22, 2012

Ubuntu Linux: Network configuration from command Line! Setting IP address, default gateways, and DNS servers for accessing Internet/network on a LAN.

Here is an easy sample for configuring Network Settings in Ubuntu Linux:

Assumptions: You want to set IP address of your system as at eth0 interface (ethernet or LAN, RJ-45 Cable port), with default gateway as and DNS servers as and
  • To check existing network settings
$ ifconfig -a

  • Setting IP address and netmask:
    To activate network interface eth0 with IP address ( ) and netmask (
$ sudo ifconfig eth0 netmask 

         Shutting down eth0:

sudo ifconfig eth0 down

       Bring up eth0:

sudo ifconfig eth0 up

  • To see the existing routing table
$ route –n
  • Setting default gateway(
$ sudo route add default gw
  • Setting DNS servers
Open the file: /etc/resolv.conf

$ sudo vi /etc/resolv.conf

Write DNS Servers:



No comments:

Post a Comment