ifconfig – configure network interfaces (legacy)

ifconfig command
ifconfig command

ifconfig displays and configures network interfaces. On modern Linux, use ip instead; ifconfig remains common on macOS and BSD.

Synopsis

ifconfig [INTERFACE] [OPTIONS]

Examples

Show all interfaces

$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 52:54:00:12:34:56  txqueuelen 1000  (Ethernet)
        RX packets 12345  bytes 1234567 (1.2 MB)
        TX packets 6789  bytes 567890 (567.8 KB)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0

Show specific interface

$ ifconfig eth0
$ ifconfig en0    # macOS

Show all including down

$ ifconfig -a

Configuration (require root)

Assign IP address

$ sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0

Bring interface up/down

$ sudo ifconfig eth0 up
$ sudo ifconfig eth0 down

Set MTU

$ sudo ifconfig eth0 mtu 9000

Enable promiscuous mode

$ sudo ifconfig eth0 promisc
$ sudo ifconfig eth0 -promisc

Common Output Fields

FieldMeaning
inetIPv4 address
inet6IPv6 address
netmaskSubnet mask
broadcastBroadcast address
etherMAC address
RX/TXReceived/transmitted packets
mtuMaximum transmission unit

ifconfig vs ip

On Linux, prefer ip:

# Show addresses
ifconfig           → ip addr
ifconfig eth0      → ip addr show eth0

# Set address
ifconfig eth0 192.168.1.100  → ip addr add 192.168.1.100/24 dev eth0

# Interface up
ifconfig eth0 up   → ip link set eth0 up

Tips

  • Not installed by default: On minimal Linux, install net-tools
  • Use ip on Linux: ifconfig is deprecated
  • macOS/BSD: ifconfig is still standard
  • Changes are temporary: Use system network config for permanent changes

See Also

  • ip — Modern Linux network config
  • netstat — Network statistics
  • route — Routing table

Tutorials