HOWTO Configure a Static IP Address on Linux
Introduction
This document explains how to configure a static IP address on the Ethernet interface of a Linux host.
With recent versions of Linux distributions, the network configuration is performed with NetworkManager.
Ubuntu configures networking through a higher abstraction tool called Netplan which internally invokes NetworkManager as a renderer.
Reference documents
Configuring Netplan
From https://netplan.io:
Netplan is a utility for easily configuring networking on a linux system. You simply create a YAML description of the required network interfaces and what each should be configured to do. From this description Netplan will generate all the necessary configuration for your chosen renderer tool.
TODO
Configuring NetworkManager
NOTE: Even though NetworkManager was designed for the Gnome desktop environment, it works “just-fine” also in server editions of those OSs. Checked on the following
Vendor |
OS Name |
network-manager |
version |
---|---|---|---|
Canonical |
Ubuntu 22.04 |
network-manager |
1.36.6-0ubuntu2 |
Raspberry Pi |
Raspbian GNU/Linux 10 (buster) |
dhcpd5 |
1:8.1.2-1+rpt1 |
Raspberry Pi |
Debian GNU/Linux 11 (bullseye) |
network-manager |
1.30.6-1+deb11u1 |
Raspberry Pi |
Debian GNU/Linux 12 (bookworm) |
network-manager |
1.42.4-1+rpt1 |
Logged in to the host which will act as raspinstall01
execute the following commands:
sudo cp /etc/network/interfaces /etc/network/interfaces.ORIG
sudo vi /etc/network/interfaces/eth0-static
and write the following contents to the config file:
# file:/etc/network/interfaces.d/eth0-static
# Configure static IP address for eth0
auto eth0
iface eth0 inet static
address 172.20.0.1
netmask 255.255.0.0
# EOF
Reboot raspinstall01
to allow the changes to take effect.
Login again and verify that eth0
was assigned the desired IP address:
gmacario@raspinstall01:~ $ ip address show eth0
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether e4:5f:01:dd:4c:0e brd ff:ff:ff:ff:ff:ff
inet 172.20.0.1/24 brd 172.20.0.255 scope global eth0
valid_lft forever preferred_lft forever
gmacario@raspinstall01:~ $