May the source be with you, but remember the KISS principle ;-)
Contents Bulletin Scripting in shell and Perl Network troubleshooting History Humor

Linux ifconfig

News See Also Recommended Links Reference ping hostname
Linux route command Traceroute Tcpdump netstat host  
ethtool ip command Netcat  Nmap Humor Etc

The "if" in ifconfig, and also in ifup, ifdown, and ifstatus, is an abbreviation of "interface". This command is located in the /usr/sbin directory. The ifconfig command commonly used to display information about the configuration of the network interface specified:

ifconfig eth01

To examine the status of all network interfaces, type:

	ifconfig -a

If used by the superuser, the ifconfig command can configure all network interface parameters. The ifconfig command can also be used to redefine an interface's IP address or parameters.

A number of options can be specified with the ifconfig  command to change its behavior: You can also configure network card by editing text files stored in /etc/sysconfig/network-scripts/ directory. First change directory to /etc/sysconfig/network-scripts/. You need to create or edit one file for each interface. Names of interfaces depend on type of cards. Often they are eth0, eth1, etc:

To set IP IP address and network mask: /sbin/ifconfig -a eth0 netmask

Verify the settings with /sbin/ifconfig eth0.

Add the default gateway: /sbin/route add default gw

Verify the gateway setting: /sbin/route. The line beginning with default should have your gateway under the gateway column.

Alternately, you can edit the file /etc/sysconfig/network-scripts/ifcfg-eth0 to look like (replace with your network numbers)


and the file /etc/sysconfig/network to look like (replace with your network numbers and hostname)


Generally if you have single default gateway you should define it and hostname in /etc/sysconfig/network  file:


Alternative place to define default gateway is /etc/sysconfig/network/route  See Linux route command for more details.

As you can see there are three places to define default gateway in Red Hat and the whole thing looks like ad hoc design. 

To make changes you made in files active you need to restart networking:

/etc/init.d/network restart

You also need to define DNS  in /etc/resolv.conf file

Ping the gateway and a few other computers on the network to verify your settings are correct before and after the reboot.

A couple of commands are used to configure the network interfaces and initialize the routing table. These tasks are usually performed from the network initialization script each time you boot the system. The basic tools for this process are called ifconfig  (where "if" stands for interface) and route.

ifconfig  is used to make an interface accessible to the kernel networking layer. This involves the assignment of an IP address and other parameters, and activation of the interface, also known as "bringing up" the interface. Being active here means that the kernel will send and receive IP datagrams through the interface. The simplest way to invoke it is with:

ifconfig interface ip-address

This command assigns ip-address  to interface  and activates it. All other parameters are set to default values. For instance, the default network mask is derived from the network class of the IP address, such as  for a class B address. ifconfig  is described in detail in the section "All About ifconfig".

To configure speed of the the interface  one can use ethtool. It also provide important information about the interface such as speed

# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: g
        Link detected: yes
Here full duplex, half duplex and auto-negotiation have the following meanings.

Configuring the Loopback Interface

The very first interface to be activated is the loopback interface. You need to be root

ifconfig lo

Occasionally, you will see the dummy hostname localhost  being used instead of the IP address. ifconfig  will look up the name in the hosts  file, where an entry should declare it as the hostname for

# Sample /etc/hosts entry for localhost

To view the configuration of an interface, you invoke ifconfig, giving it only the interface name as argument:

$ ifconfig lo
lo        Link encap:Local Loopback  
          inet addr:  Mask:
          UP LOOPBACK RUNNING  MTU:3924  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

As you can see, the loopback interface has been assigned a netmask of, since  is a class A address.

Now you can almost start playing with your mini-network. What is still missing is an entry in the routing table that tells IP that it may use this interface as a route to destination This is accomplished by using:

# route add

Again, you can use the name localhost  instead of the IP address, if it is defined in  /etc/hosts.

Next, you should check that everything works fine, for example by using ping.

# ping localhost
PING localhost ( 56 data bytes
64 bytes from icmp_seq=0 ttl=255 time=0.4 ms
64 bytes from icmp_seq=1 ttl=255 time=0.4 ms
64 bytes from icmp_seq=2 ttl=255 time=0.4 ms
--- localhost ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.4/0.4/0.4 ms

When you invoke ping  as shown here, it will continue emitting packets forever, unless interrupted by the user. The ^C marks the place where we pressed Ctrl-C.

The previous example shows that packets for  are properly delivered and a reply is returned to ping  almost instantaneously. This shows that you have successfully set up your first network interface.

If the output you get from ping  does not resemble that shown in the previous example, you are in trouble. Check any errors if they indicate that some file hasn't been installed properly. Check that the ifconfig  and route  binaries you use are compatible with the kernel release you run, and above all, that the kernel has been compiled with networking enabled (you see this from the presence of the /proc/net  directory). If you get an error message saying "Network unreachable," you probably got the route  command wrong. Make sure you use the same address you gave to ifconfig.

The steps previously described are enough to use networking applications on a standalone host. After adding the lines mentioned earlier to your network initialization script and making sure it will be executed at boot time, you may reboot your machine and try out various applications. For instance, telnet localhost  should establish a telnet  connection to your host, giving you a login: prompt.

However, the loopback interface is useful not only as an example in networking books, or as a test bed during development, but is actually used by some applications during normal operation. Therefore, you always have to configure it, regardless of whether your machine is attached to a network or not: all applications based on RPC use the loopback interface to register themselves with the portmapper  daemon at startup. These applications include NIS and NFS.

Configuring Ethernet Interfaces

Configuring an Ethernet interface is pretty much the same as the loopback interface; it just requires a few more parameters when you are using subnetting.

Let's assume that we have subnetted the IP network, which was originally a class B network, into class C subnetworks. To make the interface recognize this, the ifconfig  incantation would look like this:

ifconfig eth0 netmask

This command assigns the eth0  interface the IP address If we omitted the netmask, ifconfig  would deduce the netmask from the IP network class, which can result in an incorrect netmask.

To check the results type ipconfig:

eth1      Link encap:Ethernet  HWaddr 00:18:8B:49:8F:78
          inet addr:  Bcast:  Mask:
          RX packets:11973 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4883 errors:13 dropped:0 overruns:0 carrier:13
          collisions:13 txqueuelen:1000
          RX bytes:966692 (944.0 KiB)  TX bytes:1019655 (995.7 KiB)
          Interrupt:16 Memory:f4000000-f4012800

lo        Link encap:Local Loopback
          inet addr:  Mask:
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:5642 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5642 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4658535 (4.4 MiB)  TX bytes:4658535 (4.4 MiB)

You can see that ifconfig  automatically sets the broadcast address (the Bcast  field) to the usual value, which is the host's network number with all the host bits set. Also, the maximum transmission unit (the maximum size of IP datagrams the kernel will generate for this interface) has been set to the maximum size of Ethernet packets: 1,500 bytes. The defaults are usually what you will use, but all these values can be modified if required.

Routing Through a Gateway

Typically hosts on the network are connected via routers (gateways). For example in a home network router can provide a link to the Internet. In order to use a gateway, you have to provide additional routing information to the networking layer. To defult default gateway you need to type route command. For example 

#route add default gw

The network name default  is a shorthand for, which denotes the default route. The default route matches every destination and will be used if there is no more specific route that matches. You do not have to add this name to /etc/networks  because it is built into route.

Top Visited
Past week
Past month


Old News ;-)

[Feb 25, 2013] Linux MTU Change Size

... ... ...

Changing the MTU size with ifconfig command

In order to change the MTU size, use /sbin/ifconfig command as follows:

ifconfig ${Interface} mtu ${SIZE} up
ifconfig eth1 mtu 9000 up

Note this will only work if supported by both the network interface card and the network components such as switch.

Changing the MTU size permanently under CentOS / RHEL / Fedora Linux

Edit /etc/sysconfig/network-scripts/ifcfg-eth0, enter
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Add MTU, settings:
Save and close the file. Restart networking:
# service network restart
... ... ...

[Jun 12, 2010] Troubleshooting Networking

Occasionally, you find yourself without a working network. This article is designed to guide you through the basic steps to work out what is wrong. Hopefully, from there you will be able to find out how to resolve your problem.


This guide was written based on an Ubuntu setup, using commands that are installed by default. It should apply to any system that has iproute and mtr installed. The article also assumes you are only dealing with a wired connection. It will mostly apply to a wireless network, but there may be additional steps you need to investigate.


The first thing to do is check that your network card has been detected.

Run "ip link"

% ip link
1: lo: <LOOPBACK,UP,10000> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:a0:c9:92:9c:c0 brd ff:ff:ff:ff:ff:ff
3: sit0: <NOARP> mtu 1480 qdisc noop 
    link/sit brd

You should see eth0. If this is the case, then your network card was detected correctly.

Lets make sure we have a cable plugged in correctly by checking the link status using mii-tool.

% sudo mii-tool 
eth0: negotiated 100baseTx-FD flow-control, link ok

If you see "link ok" then you have a working ethernet connection. If you don't you should check your network cable is plugged in securely and that it is wired correctly and your switch is working correctly.

IP networking

The next thing to do is to check that you have got an IP address for that network device. You can do that by running "ip addr show dev eth0"

2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:a0:c9:92:9c:c0 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
    inet6 2002:8b0:ed:2:2a0:c9ff:fe92:9cc0/64 scope global dynamic 
       valid_lft 2591991sec preferred_lft 604791sec
    inet6 fe80::2a0:c9ff:fe92:9cc0/64 scope link 
       valid_lft forever preferred_lft forever

The line you're interested in here is the line that starts inet. If you don't or it starts 169.254 then you don't have an ip address assigned.

You can either get this dynamically via something called DHCP, or you can configure it statically. We'll try dhcp first by running "sudo dhclient eth0"

% sudo dhclient eth0
Internet Systems Consortium DHCP Client V3.0.4
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit

Listening on LPF/eth0/00:a0:c9:92:9c:c0
Sending on   LPF/eth0/00:a0:c9:92:9c:c0
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to port 67 interval 4
DHCPREQUEST on eth0 to port 67
bound to -- renewal in 38436 seconds.

If you keep seeing DHCPDISCOVER lines over and over, then it means your router is not providing addresses via DHCP, although I find this quite unlikely.

If you repeat the "ip addr show eth0" line again you should see that you now have a new "inet" line.

Lets see if our networking is working. Let's ping the machine that gave us an IP address. If you take the IP address from the DHCPOFFER line and try to ping it using "ping <ipaddress>". Press Ctrl-C to stop it.

% ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.364 ms
64 bytes from icmp_seq=2 ttl=64 time=0.274 ms
64 bytes from icmp_seq=3 ttl=64 time=0.286 ms

--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2006ms
rtt min/avg/max/mdev = 0.274/0.308/0.364/0.039 ms

If you get lines like this, then you have working IP networking.

So we've been given an IP address from somewhere. Let's see if they have given us a default route. We can do this by running "ip route"

% ip route dev eth0  proto kernel  scope link  src 
default via dev eth0 

From this we can see that our default route is to using eth0 network device. Lets try pinging that:

% ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.317 ms
64 bytes from icmp_seq=2 ttl=64 time=0.291 ms
64 bytes from icmp_seq=3 ttl=64 time=0.224 ms

--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.224/0.277/0.317/0.041 ms

So we know we can at least reach the router.


Now, lets see if we can get any further than this. Lets try pinging Ubuntu's webserver.

% ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=52 time=30.5 ms
64 bytes from icmp_seq=2 ttl=52 time=30.8 ms
64 bytes from icmp_seq=3 ttl=52 time=30.2 ms

--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2006ms
rtt min/avg/max/mdev = 30.232/30.532/30.836/0.318 ms

If this works, then we have working networking and can move on to checking DNS.

If this doesn't work, we need to find out where the problem lies using mtr (I'd normally suggest traceroute here, but it doesn't look like it's a part of the standard Ubuntu install). We will trace the route to ubuntu's webserver again.

% mtr -r -c 1
HOST: mojo-jojo                   Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.           0.0%     1    0.4   0.4   0.4   0.4   0.0
  2.                0.0%     1    1.1   1.1   1.1   1.1   0.0
  3.         0.0%     1   30.2  30.2  30.2  30.2   0.0
  4.         0.0%     1   28.7  28.7  28.7  28.7   0.0
  5. ge-2-0-216.ipcolo2.London1.L  0.0%     1   30.2  30.2  30.2  30.2   0.0
  6. ae-0-55.bbr1.London1.Level3.  0.0%     1   30.2  30.2  30.2  30.2   0.0
  7. as-0-0.bbr2.London2.Level3.n  0.0%     1   30.3  30.3  30.3  30.3   0.0
  8. ge-3-0-0-55.gar1.London2.Lev  0.0%     1   30.2  30.2  30.2  30.2   0.0
  9.                 0.0%     1   30.4  30.4  30.4  30.4   0.0
 10. vlan102.core-l-1.lon2.mnet.n  0.0%     1   29.6  29.6  29.6  29.6   0.0
 11.                 0.0%     1   31.7  31.7  31.7  31.7   0.0
 12.                  0.0%     1   30.0  30.0  30.0  30.0   0.0
 13.             0.0%     1   29.9  29.9  29.9  29.9   0.0

This shows us every router between us and the remote machine. The first line will show your ADSL router. The line after that will be the remote end of your ADSL line. If your adsl is not connected you won't be able to reach the second hop. Anything beyond this is nothing you can control, but considering it works in Windows it's unlikely that this is the case.

There is another possibility why you can't reach the second hop and that is that the default route isn't correct, but this address should have been given to you via DHCP like your IP address.

If this is all working, we can check DNS.


Try looking up a host by name using the host command:

% host has address

If this works, then your networking should be working fine. If not, then we need to check /etc/resolv.conf. It should look something like:

% cat /etc/resolv.conf 

Here we list DNS name servers. You should edit this file to use the name servers that you were given by your ISP.

Further Reading

Recommended Links

ifconfig - Wikipedia, the free encyclopedia


ifconfig examples


Other networking utilities of note include:

See the manpages for any of these utilities to get more information by entering "man utilityname" at the command line. For instance, the manpage for the arp utility is accessed by entering man arp. You can get more information about the man utility by entering man man.


FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit exclusivly for research and educational purposes.   If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner. 

ABUSE: IPs or network segments from which we detect a stream of probes might be blocked for no less then 90 days. Multiple types of probes increase this period.  


Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy


War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes


Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law


Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least

Copyright © 1996-2016 by Dr. Nikolai Bezroukov. was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License.

The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case is down you can use the at


The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: September 12, 2017