Network Computing   «Prev  Next»
Lesson 4 Troubleshooting TCP/IP with ifconfig
Objective Use ifconfig Command to resolve Problems

Use ifconfig Command to resolve TCP/IP Problems on Linux

The ifconfig command has not been completely removed from the Red Hat Linux operating system. However, it has been deprecated and is no longer the preferred way to manage network interfaces. The ip command is now the preferred command for managing network interfaces in Red Hat Linux.
If you try to run the ifconfig command in Red Hat Linux, you will receive a warning message that the command is deprecated. You can still use the ifconfig command, but it is not recommended.
Here are some of the reasons why the ifconfig command has been deprecated:
  1. It is not as powerful or flexible as the ip command.
  2. It does not support some of the newer features of Linux networking.
  3. It is not consistent with the other networking commands in Linux.

Use the IP Command

If you are using Red Hat Linux, you should use the ip command instead of the ifconfig command. The ip command is a more modern command that provides a wider range of features for managing network interfaces. It is also more consistent with the other networking commands in Linux. Here are some examples of how to use the ip command to manage network interfaces:
  1. To display information about all network interfaces, use the following command:
    ip addr
    
  2. To set the IP address of an interface, use the following command:
    ip addr add 192.168.1.100/24 dev eth0
    
  3. To enable an interface, use the following command:
    ip link set eth0 up
    
  4. To disable an interface, use the following command:
    ip link set eth0 down
    

ifconfig's default action displays data on each active interface. If /sbin is not in your PATH variable, you must type the command's entire path,
/sbin/ifconfig

to display the data. To see the status of just the eth0 interface, tell ifconfig to display this interface by typing ifconfig eth0 at a command prompt. ifconfig's -a option shows all interfaces, whether they are active or not. View the carousel below to view a typical output from ifconfig -a.

Correcting network parameters

If ifconfig indicates that some parameter is configured incorrectly, you can fix the problem by editing the interface's network script. Network scripts are located in the /etc/sysconfig/network-scripts directory. The first Ethernet interface's script is called ifcfg-eth0, and the second is called ifcfg-eth1. The following image shows an ifcfg-eth0 file that has the same IP address and netmask as the interface.

ifconfig output

1) This is the loopback, or lo, interface. It is the computer's reference to itself. The block of text below this line gives detailed information on the lo interface.
1) This is the loopback, or "lo interface". It is the computer's reference to itself. The block of text below this line gives detailed information on the lo interface.

2) This line shows the IP address (inet), the broadcast address, and the netmask associated with the lo interface.
2) This line shows the IP address (inet), the broadcast address, and the netmask associated with the lo interface.

3) This line describes the current state of the interface, most notably that it is UP or enabled.
3) This line describes the current state of the interface, most notably that it is UP or enabled.

Red Hat Linux Certification
4) This line starts the eth0 interface section.
4) This line starts the eth0 interface section.

5) The eth0 interface is assigned the IP address 208.194.157.3 and the netmask 255.255.255.0.
5) The eth0 interface is assigned the IP address 208.194.157.3 and the netmask 255.255.255.0.

6) These lines indicate the number of data packets that have been transmitted (TX) and received (RX) by the interface.
6) These lines indicate the number of data packets that have been transmitted (TX) and received (RX) by the interface.


Device, USERCTL, ONBOOT, BOOTPROTO, NETWORK, NETMASK
Device, USERCTL, ONBOOT, BOOTPROTO, NETWORK, NETMASK

To make a change, edit the file to update, or correct the network information;, executing ifup eth0 will bring up the eth0 interface, and load the new parameters. If the interface is already activated, then precede this command with "ifdown eth0". In the next lesson, you will learn how to troubleshoot TCP/IP with arp.