...
1° - First, we will need to find out what interfaces we have in the system:
ip addr show
Output of the previous command:
root@debian:~$ ip addr show 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 noprefixroute valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.0.124/24 brd 192.168.0.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::fe80:fe80:fe80:fe80/64 scope link valid_lft forever preferred_lft forever
Caso não tenha nenhum IP atribuído nas interfaces, você pode utilizar o comando (dhclient) para tentar pegar um automáticamente via DHCP
/usr/sbin/dhclient
2° - Now that we know our interfaces, let's open the interface configuration file to set the IP(s):
vi /etc/network/interfaces
3° - Let's add the settings for our main network interface (remember to adapt for your scenario):
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug ens33
iface ens33 inet static
address 192.168.0.124
netmask 255.255.255.0
gateway 192.168.0.1
# This is an autoconfigured IPv6 interface
iface ens33 inet6 auto
4° - To apply the changes, let's restart the network service:
systemctl restart networking
5° - Now we need to confirm that the interface's IP address is static:
ip addr show
inet 192.168.0.124/24 brd 192.168.0.255 scope global dynamic ens33
inet 192.168.0.124/24 brd 192.168.0.255 scope global ens33
And that's it, we already have our static IP configured on our server.