Debian Networking
...
Set a static IP
With the CLI
First, get your network interface name by running ip a
. Look for a line that starts with eno1
, ens18
, eth01
, etc. This interface should have an IP address on your subnet (i.e. for a 192.168.1.0/24
network, you might see an address like 192.168.1.102
). Note the interface name.
Create a backup of the /etc/network/interfaces
file (cp /etc/network/interfaces /etc/network/interfaces.orig
), then edit the file with nano
, (neo)vi(m)
, or some other terminal editor. Find your interface name in the file (referencing the interface you noted above) and change it to a static
connection, with your desired IP address, gateway, and DNS nameservers. Replace any xxx
values below with your own networking values.
Restart your machine, or run one of the following (if you do not have systemd, use the 2nd method with ifup
and ifdown
):
- Restart systemd service:
sudo systemctl restart networking
- Use the
ifup
andifdown
utility:sudo ifdown <eth0, eno1, ens18, ...>
(use your interface name, do not copy the<angle brackets>
)sudo ifup <eth0, eno1, ens18>
With a GUI
...