Commands / Interfaces and addresses

Interfaces and addresses

ifup

Also ifdown, /etc/network/interfaces, networking, systemd-networkd, netplan

Brings a card up as /etc/network/interfaces describes it, or takes it down again.

ip changes the running kernel and is forgotten at the next boot. To come back, the settings are written to a file that a boot service reads and applies with the same ip calls: /etc/network/interfaces read by ifup -a on Alpine and Debian, a systemd-networkd .network file on Arch, netplan on Ubuntu. A stanza names the card and how it is set: inet static with address, netmask, gateway and dns-nameservers, or inet dhcp.

ifup command usage

ifup [-a] [-v] [CARD]
ifdown [-a] [CARD]

Options

-a
every card marked auto in the file
-v
print each command it runs

ifup examples

ifup -v eth0
Sets eth0 up as the file says and prints each ip command it runs.
ifdown eth0; ifup eth0
Takes eth0 down and brings it up again from the file, as a boot would.
cat /etc/network/interfaces
Shows the settings the next boot will apply.

Pitfalls

  • BusyBox's ifup (Alpine) wants the address and the netmask on separate lines; address 10.0.1.10/24 fails with don't have all variables.
  • ifup remembers which cards it brought up: a card it thinks is up is skipped until ifdown.

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Start free