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

Leave a Comment

en_USEnglish