How to set up a static IP address on Debian 10?
First, it is necessary to know which network interface we are going to configure. For this example, I will assume that we will configure the wired network interface.
Then, we verify the name of the interface with the following command:
:~$ ip addr show
The output will be something similar to this one:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:33:07:93 brd ff:ff:ff:ff:ff:ff inet 192.168.1.15/16 brd 192.168.1.255 scope global dynamic enp0s3 valid_lft 86277sec preferred_lft 86277sec inet6 fdd4:a148:ea1:7a00:a00:27ff:fe33:793/64 scope global dynamic mngtmpaddr valid_lft 7078sec preferred_lft 3478sec inet6 fe80::a00:27ff:fe33:793/64 scope link valid_lft forever preferred_lft forever
There we will have the name of the network interfaces. The one that corresponds to the wired network is called
enp0s3. Something similar should be in your case.
And it has an IP address
192.168.1.15. However, I always want the address to be
Now that we know the name of the interface, we need to edit the file
:~$ sudo nano /etc/network/interfaces
On the line:
iface enp0s3 inet dhcp
It says that it will configure the interface with DHCP i.e. for a dynamic IP address. It has to be changed to configure it in a static way. So, change it for this line:
iface enp0s3 inet static
The following connection parameters should then be added.
address 192.168.1.99 netmask 255.255.255.0 network 192.168.1.1 broadcast 192.168.1.255 gateway 192.168.1.1
Remember that these parameters are as an example. You need to type the corresponding ones to your network.
Next, restart the network service
:~$ sudo systemctl restart networking
Then, check the changes:
:~$ ip addr show
So, everything was fine.
Setting up a static IP address on Debian 10 is quite simple. However, you must have root privileges to do this.
Ideally, you should have a static IP address for computers within an internal network to make them easier to handle.