Dec 052006

Sponsored Link

You can configure a network interface from the command line using the basic Linux networking utilities. You configure your network client hosts with the command line by using commands to change your current settings or by editing a number of system files. Two commands, ifconfig and route, are used for network configuration. The netstat command displays information about the network connections.

ifconfig Advantages

ifconfig is used to configure your network interface. You can use it to

Activate or deactivate your NIC or change your NIC's mode

Change your machine's IP address, netmask, or broadcast address

Create an IP alias to allow more than one IP address on your NIC

Set a destination address for a point-to-point connection

Using ifconfig with Examples

If you want to find your current ip address you need to enter the following command


Output looks like below

eth0 Link encap:Ethernet HWaddr 00:0F:EA:B2:53:85
inet addr: Bcast: Mask:
inet6 addr: fe80::20f:eaff:feb2:5385/64 Scope:Link
RX packets:471 errors:0 dropped:0 overruns:0 frame:0
TX packets:695 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:160637 (156.8 KiB) TX bytes:86193 (84.1 KiB)
Interrupt:185 Base address:0x6000

Create new network alias to a network card (NIC)


ifconfig [network device]


ifconfig eth0:1

Change IP address

ifconfig eth0

Change Subnetmask


ifconfig netmask [netmask]


ifconfig eth0 netmask

Change broadcast address


ifconfig broadcast [address]


ifconfig eth0 broadcast

Take interface down


ifconfig [network device] down


ifconfig eth0 down

Bring interface up


ifconfig [network device] ipaddress up


ifconfig eth0 up

If you want to know more information about ifconfig check man page

route command

route is used to build the routing tables (in memory) implemented for routing packets as well as displaying the routing information. It is used after ifconfig has initialized the interface. route is normally used to set up static routes to other networks via the gateway or to other hosts.

route Syntax

route [options] [commands] [parameters]


To display the routing table, use the route command with no options.


Kernel IP routing table
default . UG 0 0 0 eth0

Using the -n option to the route command will give the same information, substituting IP addresses for names and asterisks (*), and looks like this

route -n

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface U 0 0 0 eth0 UG 0 0 0 eth0

Add new route

route Syntax

route add default gw ipaddress interface

add a gateway with a specific IP address, you could use the following

route add default gw

If you want to know more information about route check man page

Sponsored Link

 Posted by at 9:20 am

  8 Responses to “Network Interface Configuration Using ifconfig”

  1. Hi,i was installed the debian Etch 4.0, and i have a problem with the “ifconfig” command.
    when i’m use this command the line that i wrote below was shown:
    Bash: ifconfig: command no found
    please help me for this eror.
    thanks for your help.

  2. Hello,

    You may need to be under root, to do so, type su and you’ll be asked for the password.
    Hope it help


  3. if it still doesent work as root try this:


    you can also run this command un-rooted on most systems.

  4. Hi;

    Can someone please tell me how to use ifconfig to set address for eth0 from DHCP?

    I forgot how to do it.
    something like ifconfig eth0 inet dhcp ??
    wont work!

  5. And how to use 2 gateways in the same subnet (with or without failover or/and loadbalance).


    1. Router:

    2. Router:


    And how to use both gateways now on server?

  6. Hi Matey
    [Can someone please tell me how to use ifconfig to set address for eth0 from DHCP?]

    Edit the file /etc/network/interfaces

    # Your primary network interface
    auto eth0
    iface eth0 inet dhcp

  7. Thank You very much Jaelson for the information.

  8. Does anyone know what to do if I’m using a USB ethernet adapter?

 Leave a Reply
