Linux ifconfig Command
The Linux ifconfig command is used to display or configure network devices.
ifconfig can set the state of network devices or display the current settings.
Syntax
ifconfig [network device][down up -allmulti -arp -promisc][add<address>][del<address>][<hw<network device type><hardware address>][io_addr<I/O address>][irq<IRQ address>][media<network media type>][mem_start<memory address>][metric<number>][mtu<bytes>][netmask<subnet mask>][tunnel<address>][-broadcast<address>][-pointopoint<address>][IP address]
Parameter Description:
add<address> Set the IPv6 IP address for the network device.
del<address> Delete the IPv6 IP address for the network device.
down Shut down the specified network device.
<hw<network device type><hardware address> Set the type and hardware address of the network device.
io_addr<I/O address> Set the I/O address for the network device.
irq<IRQ address> Set the IRQ for the network device.
media<network media type> Set the media type for the network device.
mem_start<memory address> Set the starting address in main memory for the network device.
metric<number> Specify the number to add when calculating the forwarding count of data packets.
mtu<bytes> Set the MTU for the network device.
netmask<subnet mask> Set the subnet mask for the network device.
tunnel<address> Establish a tunnel communication address between IPv4 and IPv6.
up Start the specified network device.
-broadcast<address> Treat data packets destined for the specified address as broadcast packets.
-pointopoint<address> Establish a direct connection with the network device at the specified address, this mode is secure.
-promisc Turn off or on the promiscuous mode for the specified network device.
[IP address] Specify the IP address for the network device.
[network device] Specify the name of the network device.
Examples
Display network device information
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:0A:0B:0C
inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe0a:b0c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:172220 errors:0 dropped:0 overruns:0 frame:0
TX packets:132379 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:87101880 (83.0 MiB) TX bytes:41576123 (39.6 MiB)
Interrupt:185 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:2022 errors:0 dropped:0 overruns:0 frame:0
TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2459063 (2.3 MiB) TX bytes:2459063 (2.3 MiB)
Start and stop a specified network interface
# ifconfig eth0 down
# ifconfig eth0 up
Configure and remove an IPv6 address for a network interface
# ifconfig eth0 add 33ffe:3240:800:1005::2/ 64 //Set IPv6 address for the network interface
# ifconfig eth0 del 33ffe:3240:800:1005::2/ 64 //Remove IPv6 address for the network interface
# ifconfig eth0 down // Turn off the network card
# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE // Modify the MAC address
# ifconfig eth0 up // Start the network card
# ifconfig eth1 hw ether 00:1D:1C:1D:1E // Turn off the network card and modify the MAC address
# ifconfig eth1 up // Start the network card
Configure IP address
# ifconfig eth0 192.168.1.56
// Configure the IP address for eth0 network card
# ifconfig eth0 192.168.1.56 netmask 255.255.255.0
// Configure the IP address for eth0 network card, and add the subnet mask
# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255
// Configure the IP address for eth0 network card, add the subnet mask, and add the broadcast address
Enable and disable ARP protocol
# ifconfig eth0 arp // Enable
# ifconfig eth0 -arp // Disable
Set the maximum transmission unit
# ifconfig eth0 mtu 1500
// Set the maximum packet size to 1500 bytes