Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Configure a Static IP Address on a Linux System

In a Linux environment, configuring a static IP address is essential for servers and devices that require a consistent network identity. Unlike dynamic IP addresses, which can change over time, a static IP address remains constant, ensuring reliable communication and accessibility. This article will guide you through the process of setting up a static IP address on various Linux distributions, highlighting its importance in network management and server configuration.


Examples:


Configuring a Static IP on Ubuntu/Debian


1. Edit the network configuration file:
Open the /etc/netplan/01-netcfg.yaml file using a text editor like nano or vim.


   sudo nano /etc/netplan/01-netcfg.yaml

2. Modify the configuration:
Update the file with your network details. Here is an example configuration:


   network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4

3. Apply the changes:
Save the file and apply the configuration using the netplan command.


   sudo netplan apply

Configuring a Static IP on CentOS/RHEL


1. Edit the network configuration file:
Open the appropriate configuration file for your network interface, typically found in /etc/sysconfig/network-scripts/ifcfg-eth0.


   sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

2. Modify the configuration:
Update the file with your network details. Here is an example configuration:


   TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4

3. Restart the network service:
Save the file and restart the network service to apply the changes.


   sudo systemctl restart network

Configuring a Static IP on Fedora


1. Edit the network configuration file:
Open the appropriate configuration file for your network interface, typically found in /etc/sysconfig/network-scripts/ifcfg-eth0.


   sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

2. Modify the configuration:
Update the file with your network details. Here is an example configuration:


   TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4

3. Restart the network service:
Save the file and restart the network service to apply the changes.


   sudo systemctl restart network

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.