ifconfig

ifconfig

ifconfig is a command-line utility used to configure network interfaces on Unix-like operating systems, including Linux. It is part of the net-tools package and is used to view and manage network interface configurations.

  1. View All Network Interfaces:

    ifconfig

    This command displays information about all active network interfaces on the system.

  2. View a Specific Network Interface:

    ifconfig eth0

    Replace eth0 with the name of the network interface you want to view. This command displays detailed information about the specified interface.

  3. Bring Up a Network Interface:

    ifconfig eth0 up

    This command activates the eth0 network interface.

  4. Bring Down a Network Interface:

    ifconfig eth0 down

    This command deactivates the eth0 network interface.

  5. Assign an IP Address to a Network Interface:

    ifconfig eth0 192.168.1.10 netmask 255.255.255.0

    This command assigns the IP address 192.168.1.10 with a subnet mask of 255.255.255.0 to the eth0 interface.

  6. Change the MTU of a Network Interface:

    ifconfig eth0 mtu 1500

    This command sets the Maximum Transmission Unit (MTU) of the eth0 interface to 1500 bytes.

  7. Assign an IP Address with Broadcast and Netmask:

    ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255

    This command assigns the IP address 192.168.1.10, subnet mask 255.255.255.0, and broadcast address 192.168.1.255 to the eth0 interface.

  8. Assign a MAC Address to a Network Interface:

    ifconfig eth0 hw ether 00:1A:2B:3C:4D:5E

    This command assigns the MAC address 00:1A:2B:3C:4D:5E to the eth0 interface.

Example of ifconfig Output

When you run ifconfig without any arguments, you might see output similar to this:

eth0      Link encap:Ethernet  HWaddr 00:0c:29:36:bc:91  
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe36:bc91/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12345 errors:0 dropped:0 overruns:0 frame:0
          TX packets:67890 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1048576 (1.0 MB)  TX bytes:524288 (512.0 KB)

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:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:820 (820.0 B)  TX bytes:820 (820.0 B)

Deprecation Notice

While ifconfig is still widely used, it is considered deprecated in favor of the ip command from the iproute2 package. The ip command provides more functionality and better capabilities for modern network configuration.

Basic Usage of ip Command

  1. View All Network Interfaces:

    ip addr
  2. View a Specific Network Interface:

    ip addr show dev eth0
  3. Bring Up a Network Interface:

    ip link set eth0 up
  4. Bring Down a Network Interface:

    ip link set eth0 down
  5. Assign an IP Address to a Network Interface:

    ip addr add 192.168.1.10/24 dev eth0
  6. Change the MTU of a Network Interface:

    ip link set dev eth0 mtu 1500

Conclusion

ifconfig is a powerful and widely used tool for network configuration on Unix-like systems. Despite being deprecated in favor of the ip command, it remains an important utility, especially in legacy systems and for quick network interface management tasks. For modern and more complex networking tasks, transitioning to the ip command is recommended.

help

Usage:
  ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
  [add <address>[/<prefixlen>]]
  [del <address>[/<prefixlen>]]
  [[-]broadcast [<address>]]  [[-]pointopoint [<address>]]
  [netmask <address>]  [dstaddr <address>]  [tunnel <address>]
  [outfill <NN>] [keepalive <NN>]
  [hw <HW> <address>]  [mtu <NN>]
  [[-]trailers]  [[-]arp]  [[-]allmulti]
  [multicast]  [[-]promisc]
  [mem_start <NN>]  [io_addr <NN>]  [irq <NN>]  [media <type>]
  [txqueuelen <NN>]
  [[-]dynamic]
  [up|down] ...

breakdown

-a, --all: This option displays all network interfaces.
-s, --statistics: This option displays statistics for the specified interface.
-v, --verbose: This option displays more information.

Last updated