Copied to clipboard

ifconfig

The ifconfig command line is used to display and configure network interfaces, including IP addresses, subnet masks, broadcast addresses, and MAC addresses, etc.

Example

  1. Display all interface information:

    ifconfig -a
    
  2. Display information for a specified interface:

    ifconfig eth0
    
  3. Display the IP address for a specified interface:

    ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'
    
  4. Display the MAC address for a specified interface:

    ifconfig eth0 | grep 'HWaddr' | awk '{print $5}'
    
  5. Display all socket information:

    ifconfig -S
    
  6. Display statistics for a specified interface:

    ifconfig eth0 -s
    
  7. Display all protocol information:

    ifconfig -x
    
  8. Display version information:

    ifconfig -v
    
  9. Display interface flags:

    ifconfig -l
    
  10. Display all supported AF_FAMILY:

    ifconfig -L