ifconfig is the command most people learned first for looking at network interfaces on Linux. It still works wherever the net-tools package is installed — but it has been deprecated since 2009, Debian, Ubuntu, RHEL and their derivatives no longer install it by default, and it cannot show or configure several things modern kernels do (multiple addresses per interface, routing policy, VLANs, namespaces). Its replacement is ip from iproute2, which is on every Linux system.
This guide covers each common ifconfig task with the ip command that does the same thing, so you can use whichever is in front of you. It also covers the part the old tutorials skip: changes made with either tool disappear at reboot unless you also update the network configuration your distribution actually uses.
If ifconfig is missing
-bash: ifconfig: command not found
Install net-tools if you want it:
# Debian / Ubuntu
sudo apt install -y net-tools
# RHEL, AlmaLinux, Rocky, Fedora
sudo dnf install -y net-tools
# Alpine
sudo apk add net-tools
Or skip it and use ip, which is already there. The rest of this guide shows both.
View interfaces
ifconfig # all *active* interfaces
ifconfig -a # all interfaces, including ones that are down
ifconfig eth0 # one interface
ip address # or: ip a — all interfaces, up and down
ip -br address # brief one-line-per-interface view
ip address show dev eth0
ip link # link-layer only: state, MAC, MTU, no IPs
ip -br a is the one to memorize; it prints exactly what you usually want:
lo UNKNOWN 127.0.0.1/8 ::1/128
enp1s0 UP 203.0.113.10/24 2001:db8::10/64 fe80::5054:ff:fe12:3456/64
docker0 DOWN 172.17.0.1/16
Interface names on modern systems are predictable names (enp1s0, ens192, eno1) rather than eth0. Use whatever ip -br link shows; the examples below use eth0 for brevity.
Reading ifconfig output
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 203.0.113.10 netmask 255.255.255.0 broadcast 203.0.113.255
inet6 fe80::5054:ff:fe12:3456 prefixlen 64 scopeid 0x20<link>
ether 52:54:00:12:34:56 txqueuelen 1000 (Ethernet)
RX packets 184233 bytes 211839284 (211.8 MB)
RX errors 0 dropped 12 overruns 0 frame 0
TX packets 92831 bytes 9828374 (9.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
UPmeans administratively enabled;RUNNINGmeans there is a carrier (cable/link).UPwithoutRUNNINGis an unplugged or down-at-the-switch port.RX droppedclimbing steadily points at a saturated receive queue or a driver issue;errors/frame/collisionspoint at the physical layer.ip -s link show eth0prints the same counters.
Bring an interface up or down
sudo ifconfig eth0 up
sudo ifconfig eth0 down
sudo ip link set eth0 up
sudo ip link set eth0 down
Taking down the interface your SSH session uses disconnects you. On a remote box, either do it from a console, or chain the down and up in one command so it comes back: sudo sh -c 'ip link set eth0 down; sleep 2; ip link set eth0 up'.
Assign an IP address, netmask and broadcast
sudo ifconfig eth0 192.168.10.20
sudo ifconfig eth0 netmask 255.255.255.0
sudo ifconfig eth0 broadcast 192.168.10.255
# or all at once
sudo ifconfig eth0 192.168.10.20 netmask 255.255.255.0 broadcast 192.168.10.255
sudo ip address add 192.168.10.20/24 brd + dev eth0
Two differences worth knowing: ifconfig replaces the primary address, ip address add adds another one (an interface can hold many). To replace with ip, delete the old one first: sudo ip address del 192.168.10.5/24 dev eth0. And ip takes the prefix length (/24) instead of a dotted netmask — a subnet calculator converts between the two.
Change the MTU
sudo ifconfig eth0 mtu 9000
sudo ip link set eth0 mtu 9000
Jumbo frames (9000) only work if every device on the path supports them; a mismatched MTU shows up as large transfers hanging while pings succeed. Test with ping -M do -s 8972 <host> (8972 = 9000 minus 28 bytes of headers).
Promiscuous mode
Promiscuous mode makes the NIC pass every frame it sees to the kernel, not just the ones addressed to it — what packet sniffers like tcpdump need (they usually enable it themselves).
sudo ifconfig eth0 promisc
sudo ifconfig eth0 -promisc
sudo ip link set eth0 promisc on
sudo ip link set eth0 promisc off
Aliases: more than one IP on an interface
The ifconfig way is the eth0:0 alias syntax:
sudo ifconfig eth0:0 192.168.10.21 netmask 255.255.255.0 up
sudo ifconfig eth0:0 down
With ip, aliases are unnecessary — just add a second address (optionally with a label so ifconfig can still see it):
sudo ip address add 192.168.10.21/24 dev eth0 label eth0:0
sudo ip address del 192.168.10.21/24 dev eth0
ifconfig without a label only ever shows the first address on an interface. If a server seems to be missing an IP in ifconfig but answers on it, that is why — check with ip a.
Change the MAC address
sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether 02:11:22:33:44:55
sudo ifconfig eth0 up
sudo ip link set eth0 down
sudo ip link set eth0 address 02:11:22:33:44:55
sudo ip link set eth0 up
Use a locally administered address (second hex digit 2, 6, A or E, e.g. 02:…) to avoid colliding with a real vendor OUI — the MAC address lookup tool shows which prefixes are assigned. Many cloud providers filter traffic by the MAC they assigned; changing it there will take the instance offline.
Making changes permanent
Everything above is live-only. On reboot (or when the network service restarts) the interface is reconfigured from the distribution's configuration:
-
Ubuntu (netplan) — edit
/etc/netplan/*.yaml, thensudo netplan try(reverts automatically if you lose connectivity) andsudo netplan apply. -
Debian —
/etc/network/interfaces, thensudo ifdown eth0 && sudo ifup eth0. -
RHEL, AlmaLinux, Rocky, Fedora (NetworkManager) —
nmcli:nmcli connection show sudo nmcli connection modify "eth0" ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1 ipv4.dns 1.1.1.1 ipv4.method manual sudo nmcli connection up "eth0"The legacy
/etc/sysconfig/network-scripts/ifcfg-*files are deprecated in RHEL 9 and ignored unless the compatibility package is installed. -
Cloud images — cloud-init may regenerate network config on boot; disable that in
/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg(network: {config: disabled}) before hand-editing.
Quick reference
| Task | ifconfig | ip |
|---|---|---|
| List active interfaces | ifconfig |
ip -br a |
| List all, incl. down | ifconfig -a |
ip a |
| One interface | ifconfig eth0 |
ip a show dev eth0 |
| Up / down | ifconfig eth0 up / down |
ip link set eth0 up / down |
| Set IP + mask | ifconfig eth0 A.B.C.D netmask M |
ip a add A.B.C.D/NN dev eth0 |
| Remove IP | ifconfig eth0 0.0.0.0 |
ip a del A.B.C.D/NN dev eth0 |
| MTU | ifconfig eth0 mtu 9000 |
ip link set eth0 mtu 9000 |
| Promiscuous | ifconfig eth0 promisc |
ip link set eth0 promisc on |
| Alias / 2nd IP | ifconfig eth0:0 A.B.C.D |
ip a add A.B.C.D/NN dev eth0 label eth0:0 |
| MAC address | ifconfig eth0 hw ether XX |
ip link set eth0 address XX |
| Counters | ifconfig eth0 |
ip -s link show eth0 |
| Routes | route -n |
ip route |
| ARP table | arp -n |
ip neigh |
Troubleshooting
ifconfig: command not found— installnet-toolsor useip(see above). As a non-root user on Debian/Ubuntu,/sbin/ifconfigmay exist but not be on yourPATH.- The IP you set is gone after reboot — expected; persist it in netplan / NetworkManager /
interfacesas described above. SIOCSIFFLAGS: Operation not permitted— you needsudofor anything that changes state.ifconfigshows one IP, the server answers on two —ifconfighides secondary addresses without labels. Useip a.- Interface is
UPbut notRUNNING— no link: cable, switch port, or (in a VM) the virtual NIC is disconnected on the hypervisor side.ethtool eth0 | grep Linkconfirms. - Packets
droppedkeeps increasing — check ring buffer size (ethtool -g eth0) and CPU saturation; on VMs, check for a noisy neighbour or an undersized instance.
Summary
ifconfig is fine for a quick look, but ip is the tool that is always installed and always complete: ip -br a to see, ip link set … up|down to toggle, ip a add …/NN dev … to address, ip link set … mtu|address|promisc to tune. Whatever you change live, persist it in the distribution's network configuration or it will not survive the next reboot.
Related Resources
- Using the Windows ipconfig command — the Windows counterpart, including
/all,/flushdnsand/displaydns - How to install and use tcpdump — once the interface is up, see what is actually flowing through it
- Netstat monitoring — track open connections and listening ports per interface over time
- IP subnet calculator — convert between dotted netmasks and CIDR prefixes