How to configure network under linux

Configuring Linux /etc/network/interfaces

Edit the /etc/network/interfaces file

# nano /etc/network/interfaces

The default configuration file is as follows:

source /etc/network/interfaces.d/*

# The loopback network interface
iface lo inet loopback
iface lo inet loopback

Check the NIC information first:

1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

2: enp0s3:  mtu 1500 qdisc fq_codel state UP group default qlen 1000

3: enp0s8:  mtu 1500 qdisc fq_codel state UP group default qlen 1000

Start Configuration

Using DHCP autoconfiguration

If you want the interface to obtain an IP address automatically at startup, you can use the following configuration:

auto enp0s3
iface enp0s3 inet dhcp

This will cause the enp0s3 interface to automatically use DHCP to configure network settings at boot time.

Static IP Configuration

For static IP configuration, you need to specify the IP address, subnet mask and gateway. Example:

auto enp0s8
iface enp0s8 inet static
    address 192.168.1.102
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.8.4.4


How to Configure a Network on Linux: A Checklist Before Getting Started

When creating technical tutorials, the biggest pitfall is copying commands verbatim while ignoring differences in the environment. Different system versions, web servers, plugin combinations, and permission settings can all affect the final outcome. Before proceeding, it’s recommended that you document your current configuration and, if necessary, create a snapshot or backup. That way, even if you make a mistake during the process, you can quickly roll back the changes.

We recommend confirming the following before proceeding

  • System and Software Versions:Verify the versions of Windows, Debian, Nginx, Apache, WordPress, or related tools.
  • Permissions:When dealing with credentials, certificates, or configuration files, first verify that the current user has sufficient permissions.
  • Backup:Before modifying a configuration file, make a copy of the original file first. For WordPress sites, it’s also recommended to back up the database.
  • Test Method:Validate your changes after each step; don't wait until you've finished making all the changes to troubleshoot.

Troubleshooting Approach

When you encounter an error, first determine at which layer it occurred: the browser, DNS, server, application, plugin, or permissions. Breaking the problem down into smaller parts is more effective than repeatedly searching through an entire error message. For issues involving WordPress, Nginx, certificates, and proxies, logs are usually more reliable than front-end pages.

If the paths or menus in this tutorial differ from those in your environment, refer to your system’s current display first, and then use the keywords to locate the corresponding features. This is especially true for the Windows Control Panel, the WordPress plugin menu, and cloud service consoles, as their access points are frequently updated with new versions.

Recommendations for Follow-up Maintenance

Completing a fix does not mean the problem is permanently resolved. We recommend documenting key commands, modified files, modification times, and verification results. These records can save a significant amount of troubleshooting time when you later migrate servers, upgrade plugins, or change themes.

Related Content

en_USEnglish