English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux ifconfig command

Linux Command大全

Linux ifconfig command is used to display or set network devices.

ifconfig can set the status of the network device 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 IPv of the network device.6IP address.
  • del<address> Delete the IPv of the network device.6IP address.
  • down Close 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.
  • irq<IRQ address> Set the IRQ of the network device.
  • media<network medium type> Set the medium type of the network device.
  • mem_start<memory address> Set the starting address occupied by the network device in the main memory.
  • metric<number> Specify the number to be added when calculating the number of packet transmissions.
  • mtu<bytes> Set the MTU of the network device.
  • netmask<subnet mask> Set the subnet mask of the network device.
  • tunnel<address> Establish IPv4and IPv6Tunnel communication address between.
  • up Start the specified network device.
  • -broadcast<address> Treat the packets to be sent to the specified address as broadcast packets.
  • -pointopoint<address> Establish a direct connection with the network device at the specified address, this mode has confidentiality features.
  • -promisc Turn on or off the promiscuous mode of the specified network device.
  • [IP Address] Specify the IP address of the network device.
  • [Network Device] Specify the name of the network device.

Online example

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 specified network card

# ifconfig eth0 down
# ifconfig eth0 up

Configure and delete IPv for network card6Address

# ifconfig eth0 add 33ffe:3240:800:1005::2/ 64 //Set IPv for network card6Address
# ifconfig eth0 del 33ffe:3240:800:1005::2/ 64 //Delete IPv for network card6Address

Modify MAC address using ifconfig

# ifconfig eth0 down //Close network card
# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //Modify MAC Address
# ifconfig eth0 up //Start network card
# ifconfig eth1 hw ether 00:1D:1C:1D:1E //Close network card and modify MAC address 
# ifconfig eth1 up //Start network card

Configure IP Address

# ifconfig eth0 192.168.1.56 
//Configure IP address for eth0 network card
# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 
// Configure IP address for eth0 network card, and add subnet mask
# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255
// Configure IP address for eth0 network card, add subnet mask, and add a broadcast address

Enable and Disable ARP Protocol

# ifconfig eth0 arp  //Open
# ifconfig eth0 -arp  //Close

Set the Maximum Transmission Unit

# ifconfig eth0 mtu 1500 
//Set the maximum packet size that can be passed through 1500 bytes

Linux Command大全