How to configure a static IP and what it is used for
IP Static
A static IP address is used to assign a permanent, fixed IP address to a network interface on an operating system. Unlike a dynamic IP address, which can change each time the network connection is rebooted or renewed, a static IP address remains constant.
A static IP address serves several purposes:
Hosting services: Servers hosting websites, email servers, or any online services typically use static IP addresses to ensure that the services are always accessible at the same address.
Remote access: When accessing a network remotely or setting up a Virtual Private Network (VPN), having a static IP address makes it easier to establish a secure connection since the IP address is known in advance.
Network configuration: Certain network devices, such as routers or network printers, may require static IP addresses for proper configuration and management.
Port forwarding and network routing: Static IP addresses are often used in scenarios involving port forwarding or routing traffic between networks, allowing specific data to be directed to the correct device.
How to configure a static IP in DEBIAN 11 ?
By default you will find the following configuration within the /etc/network/interfaces
Simply, a network interface is the point of connection between a computer and a network. In other words, how the Linux system links up the software side of networking to the hardware side.
nano /etc/network interfaces
source /etc/network/interfaces.d/* auto lo iface lo inet loopback allow_hotplug enp0s3 iface enp0s3 init dhcp
as we can see by default it is configured dhcp.
DHCP (Dynamic Host Configuration Protocol) is a network management protocol used to dynamically assign an IP address.
change a:
source /etc/network/interfaces.d/* auto lo iface lo inet loopback allow-hotplug enp0s3 iface enp0s3 inet static address 192.168.0.100 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 8.8.4.4 8.8.8.8
F12 and S to exit and save.
"enp0s3" is simply the name assigned to a specific Ethernet network interface in the Linux system, following the predictable naming convention. It's worth noting that the exact interface name may vary depending on the system and specific configuration.
"address" is the static address that we are going to establish.
"netmask" refers to the subnet mask associated with the network interface
"gateway" is the IP address of the router or gateway device that acts as the entry point or exit point for the network.
"dns-nameservers" (google DNS) DNS servers ensures that the system can resolve domain names and access resources on the
internet or within the local network
To apply the changes we must restore the service using the following command
systemctl restart networking