ifconfig

Syntax:

  • ifconfig [-v] [-a] [-s] interface
  • ifconfig [-v] interface [aftype] options | address …

Options:

  • -a - display all interfaces that are available, even if down
  • -s [interface] - display a short list (similar to netstat -i)
  • <interface> - display details of interface
  • <interface> up - activate an interface
  • <interface> down - deactivate an interface
  • <interface> <address> - set the IP address to this value
  • <interface> broadcast <address> - set the protocol broadcast address
  • <interface> netmask <address> - set the IP network mask
  • <interface> hw <class> <address> - set the hardware address

Display all interfaces that are active

This does not necessarily mean that an interface has any addresses attached to it. Only that it is available and able to set something.

ifconfig

Bring an interface online

ifconfig eth0 up

Display information about the interface

ifconfig eth0

Set the IP address of an interface

ifconfig eth0 192.168.1.1

Note that if you don't set a broadcast or netmask address when setting the ip (fex: ifconfig eth0 192.168.1.1), then ifconfig will set them to the default values. Broadcast would be 192.168.1.255 and netmask would be 255.255.255.0.

Remove the IP address of an interface

ifconfig eth0 0.0.0.0

You can run ifconfig eth0 0 as well.

Set the IP address and broadcast of an interface

ifconfig eth0 192.168.1.1 broadcast 192.168.1.255

Set the IP address, broadcast and netmask of an interface

ifconfig eth0 192.168.1.1 broadcast 192.168.1.255 netmask 255.255.255.0

Set the MAC address of an interface

ifconfig eth0 hw ether 00:16:3E:24:13:59