How to set a static IP address on Debian 10 Buster?

0
50

In this opportunity, I will show you how to define a static IP address in Debian 10. With that, you will be able to give a specific IP address to your Debian team. Ideal if you are on a home network or for educational purposes.

What do you will learn in this post?

This is a post, quite simple to apply. If you keep reading, you will learn the following

  1. What is a static IP address?
  2. Advantages of having a server with a static IP address.
  3. How to define a static IP address in Debian 10 Buster?

On the other hand, if you do not have Debian 10 Buster installed yet, I recommend you to visit our post where we explain it in detail.

How to install Debian 10 Buster?

So, we can start now.

A Static IP address

An IP address is an identifier held by each device that connects to the Internet or a computer network. In the case of the Internet, it must be unique to avoid connection conflicts.

On the one hand, there are dynamic IP addresses that change their value from time to time. Normally, these addresses are assigned by a DCHP server. The sysadmin does not have to worry about the assigned address as they are renewed from time to time.

On the other hand, we have static or fixed IP addresses, which unlike dynamical ones, do not change over time. In this case, it must be assigned and configured manually in the system.

Each of them has its own advantages, however, for internal networks, it is convenient to have equipment with static IP addresses. This facilitates the administration and routing of packets within the network. It is also easier to maintain the network.

Now, I will show you how to define a static IP address in Debian 10.

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.250.15/16 brd 192.168.255.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.250.15. However, I always want the address to be 192.168.250.99.

Now that we know the name of the interface, we need to edit the file /etc/network/interfaces.

:~$ 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
  • Netmask
  • Network
  • Broadcast
  • Gateway
address 192.168.250.99
netmask 255.255.255.0
network 192.168.1.1
broadcast 192.168.255.255
gateway 192.168.1.1

Remember that these parameters are as an example. You need to type the corresponding ones to your network.

After making the settings, it should look like this:

1.- Configuring a static IP address on Debian 10 Buster
1.- Configuring a static IP address on Debian 10 Buster

Next, restart the network service

:~$ sudo systemctl restart networking

Then, check the changes:

:~$ ip addr show
2.- Check the results
2.- Check the results

So, everything was fine.

Conclusion

Setting up a static IP address on Debian 10 is quite simple. However, you must have root privileges to do this. You can learn how to enable sudo in Debian 10 for that.

Ideally, you should have a static IP address for computers within an internal network to make them easier to handle.

Please share this post with your friends and join our Telegram channel.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here