ifconfig - configure a network interface
ifconfig [interface] ifconfig interface [aftype] options | address ...
TAG | DESCRIPTION |
---|---|
interface | The name of the interface. This is usually a driver name followed by a unit number, for example eth0 for the first Ethernet interface. |
down | This flag causes the driver for this interface to be shut down. |
[-]arp | Enable or disable the use of the ARP protocol on this interface. |
[-]promisc | Enable or disable the promiscuous mode of the interface. If selected, all packets on the network will be received by the interface. |
[-]allmulti | Enable or disable all-multicast mode. If selected, all multicast packets on the network will be received by the interface. |
metric N | This parameter sets the interface metric. It is not available under GNU/Linux. |
mtu N | This parameter sets the Maximum Transfer Unit (MTU) of an interface. |
dstaddr addr | Set the remote IP address for a point-to-point link (such as PPP). This keyword is now obsolete; use the pointopoint keyword instead. |
netmask addr | Set the IP network mask for this interface. This value defaults to the usual class A, B or C network mask (as derived from the interface IP address), but it can be set to any value. . |
add addr/prefixlen | Add an IPv6 address to an interface. |
del addr/prefixlen | Remove an IPv6 address from an interface. |
tunnel ::aa.bb.cc.dd | Create a new SIT (IPv6-in-IPv4) device, tunnelling to the given destination. |
irq addr | Set the interrupt line used by this device. Not all devices can dynamically change their IRQ setting.. |
io_addr addr | Set the start address in I/O space for this device.. |
mem_start addr | TSet the start address for shared memory used by this device. Only a few devices need this.. |
[-]broadcast [addr] | If the address argument is given, set the protocol broadcast address for this interface. Otherwise, set (or clear) the IFF_BROADCAST flag for the interface.. |
[-]pointopoint [addr] | This keyword enables the point-to-point mode of an interface, meaning that it is a direct link between two machines with nobody else listening on it. |
hw class address | Set the hardware address of this interface, if the device driver supports this operation. The keyword must be followed by the name of the hardware class and the printable ASCII equivalent of the hardware address. Hardware classes currently supported include ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom (AMPR NET/ROM). |
multicast | Set the multicast flag on the interface. This should not normally be needed as the drivers set the flag correctly themselves.. |
address | The IP address to be assigned to this interface. |
txqueuelen length | Set the length of the transmit queue of the device. It is useful to set this to small values for slower devices with a high latency (modem links, ISDN) to prevent fast bulk transfers from disturbing interactive traffic like telnet too much |
EXAMPLE-1:
The “ifconfig” command with no arguments will display all the active interfaces details. The ifconfig command also used to check the assigned IP address of an server.
# ifconfig
output:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.128 Bcast:192.168.134.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
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:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
virbr0 Link encap:Ethernet HWaddr 3a:bf:4c:fb:90:b6
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
EXAMPLE-2:
To Display Information of All Network Interfaces:
# ifconfig -a
output:
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.128 Bcast:192.168.134.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
eth1 Link encap:Ethernet HWaddr 00:0c:29:8b:89:bc
inet addr: Bcast: Mask:
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
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:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
virbr0 Link encap:Ethernet HWaddr 3a:bf:4c:fb:90:b6
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
EXAMPLE-3:
To View Network Settings of Specific Interface:
# ifconfig eth0
output:
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.128 Bcast:192.168.134.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11696 errors:0 dropped:0 overruns:0 frame:0
TX packets:6223 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:933886 (933.8 KB) TX bytes:1720687 (1.7 MB)
EXAMPLE-4:
The “up” or “ifup” flag with interface name (eth1) activates an network interface:
# ifconfig eth1 up OR # ifup eth1
output:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.128 Bcast:192.168.134.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
eth1 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.129 Bcast:192.168.134.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
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:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
virbr0 Link encap:Ethernet HWaddr 3a:bf:4c:fb:90:b6
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
EXAMPLE-5:
The “down” or “ifdown” flag with interface name (eth1) deactivates the specified network interface:
# ifconfig eth1 down OR # ifdown eth1
output:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.128 Bcast:192.168.134.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
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:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
virbr0 Link encap:Ethernet HWaddr 3a:bf:4c:fb:90:b6
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
EXAMPLE-6:
To assign an IP address to an specific interface:
# ifconfig eth1 192.168.134.129
output:
# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.129 Bcast:192.168.134.255 Mask:255.255.255.0EXAMPLE-7:
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
To Assign a Netmask to Network Interface:
# ifconfig eth0 netmask 255.255.255.224
output:
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.128 Bcast:192.168.134.255 Mask:255.255.255.224
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
EXAMPLE-8:
* To Assign a IP, Netmask and Broadcast to Network Interface:
# ifconfig eth0 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63
output:
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.128 Bcast:192.168.134.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)
EXAMPLE-9:
To Change MTU for an Network Interface:
# ifconfig eth0 mtu 1000
output:
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0c:29:9b:49:bc
inet addr:192.168.134.128 Bcast:192.168.134.255 Mask:255.255.255.0Print
inet6 addr: fe80::20c:29ff:fe9b:49bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1000 Metric:1
RX packets:11545 errors:0 dropped:0 overruns:0 frame:0
TX packets:6177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:923360 (923.3 KB) TX bytes:1712607 (1.7 MB)