Network configuration in Linux can vary depending on the distribution being used. In this article, we will explain how to configure the network in different Linux families, such as Debian, CentOS, and others.

Static Network Configuration in Debian

In Debian, network configuration is performed through the "/etc/network/interfaces" file. To get started, we must open the file with a text editor, such as vim or nano, and add the following lines:

auto eth0
iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.4.4

These lines configure the static IP address, network mask, gateway, and DNS servers. Replace the values with those appropriate for your network.

Then, restart the network service with the following command:

sudo /etc/init.d/networking restart

Static Network Configuration in CentOS

In CentOS, network configuration is performed through the "/etc/sysconfig/network-scripts/ifcfg-eth0" file. To get started, we must open the file with a text editor and add the following lines:

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4

These lines configure the static IP address, network mask, gateway, and DNS servers. Replace the values with those appropriate for your network.

Then, restart the network service with the following command:

sudo service network restart

Network Configuration in Other Linux Distributions

In other Linux distributions, network configuration may vary. Below is an example of how to configure the network in Arch Linux.

In Arch Linux, network configuration is performed through the “/etc/netctl/eth0” file. To get started, we must open the file with a text editor and add the following lines:

Description='A basic static ethernet connection'
Interface=eth0
Connection=ethernet
IP=static
Address=('192.168.1.100/24')
Gateway='192.168.1.1'
DNS=('8.8.8.8' '8.8.4.4')

These lines configure the static IP address, network mask, gateway, and DNS servers. Replace the values with those appropriate for your network.

Then, restart the network service with the following command:

sudo netctl restart eth0

Configuring the network in Linux can vary depending on the distribution being used. In this article, we explained how to configure the network in different Linux families, such as Debian, CentOS, and others. Network configuration is an important task for ensuring a stable and secure internet connection. Remember to replace the values with those appropriate for your network and make sure to restart the network service after making changes so they are applied correctly.

It is important to mention that, in addition to static network configuration, it is also possible to configure the network dynamically through the DHCP protocol. In this case, the DHCP server will automatically assign an IP address, network mask, gateway, and DNS servers to our system.

To enable dynamic network configuration in Linux, we must add the following lines to the corresponding configuration file, making sure to know the name of your network interface in your local distribution:

auto eth0
iface eth0 inet dhcp

For CentOS, we must add the following lines to the "/etc/sysconfig/network-scripts/ifcfg-eth0" configuration file:

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

For Arch Linux, we must add the following lines to the "/etc/netctl/eth0" file:

Description='A basic dhcp ethernet connection'
Interface=eth0
Connection=ethernet
IP=dhcp

With this, our system will be configured to obtain an IP address, network mask, gateway, and DNS servers automatically through the DHCP protocol.

In Conclusion

Network configuration in Linux can vary depending on the distribution being used. In this article, we explained how to configure the network in different Linux families, such as Debian, CentOS, and others, both statically and dynamically through the DHCP protocol. Remember that it is important to configure the network correctly to ensure a stable and secure internet connection on our Linux operating system.