Linux Network Interface Configuration tool - ifconfig
The Linux computer's network interface TCP/IP settings can be configured from the command line, using the Linux ifconfig command.
If no argument is given, ifconfig displays the status of active interfaces.
[root@RHEL03 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:DB:54:D8
inet addr:192.168.1.110 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedb:54d8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:93 errors:0 dropped:0 overruns:0 frame:0
TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15519 (15.1 KiB) TX bytes:8138 (7.9 KiB)
Interrupt:169 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1545 errors:0 dropped:0 overruns:0 frame:0
TX packets:1545 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2357260 (2.2 MiB) TX bytes:2357260 (2.2 MiB)
The following are the main entries in the output.
• inet : displays the IP address for the interface.
• UP : shows that the interface is ready for use
• BROADCAST: denotes that the interface is connected to a network that supports broadcast messaging (ethernet)
• RUNNING: shows that the interface is operating
• LOOPBACK shows which device (lo) is the loopback address.
• MTU (Maximum Transmission Unit) on eth0 is 1500 bytes. This determines the size of the largest packet that can be transmitted over this interface.
• Metric: This metric is used by the Routing Information Protocol (RIP) to build routing tables for the network.
To deactivate the first ethernet device on a host, use the following command.
[root@RHEL03 ~]# ifconfig eth0 down
To activate the first ethernet device on a host, use the following command.
[root@RHEL03 ~]# ifconfig eth0 up
An interface can be configured and activated by specifying an IP address and network information. For example, to configure and activate (“bring up”) the eth0 interface with a specific IP address, use the ifconfig command like this:
[root@RHEL03 ~]# ifconfig eth0 10.10.10.5 netmask 255.255.255.0 up
If a host entry is defined in the hosts (/etc/hosts) file you can activate the interface by using the defined hostname.
[root@RHEL03 ~]# ifconfig eth0 RHEL03.omnisecu.com up
The following table lists the important switches of ifconfig command.
Parameter |
Description |
up |
Activates the specified adapter. |
down |
Deactivates the specified adapter. |
netmask <address> |
Assigns the address subnet mask. |
broadcast <address> |
Assigns the address as the broadcast address. Rarely used. |
metric <value> |
Metric Value |
mtu <value> |
MTU value |
-arp |
Deactivates the Address Resolution Protocol |
promisc |
Activates promiscuous mode. This allows the network adapter to read all packets to all hosts on the LAN. |
-promisc |
Deactivates promiscuous mode. |
IP aliasing using ifconfig command
IP aliasing is the process of adding more than one IP address to a network interface. When you set up a Linux system's network, you typically assign one IP address per network interface card (NIC). But in some situations you require more ip addresses for an interface.
The following commands shows how to set multiple ip addresses for an interface and make it up.
[root@RHEL03 ~]# ifconfig eth0:1 192.168.1.222 netmask 255.255.255.0
[root@RHEL03 ~]# ifconfig eth0:1 10.10.10.10 netmask 255.255.255.0