ubuntu网络接口(网口)配置

支持两种配置方式:

1. 界面配置

可以通过增加“new profile”的方式在同一个网口添加多个IP配置;

注意只需要配置一个网关即可,通常配置外接互联网的网关和DNS

2. 文件配置

涉及文件为 /etc/network/interfaces配置IP

auto lo
iface lo inet loopback

auto enp0s31f6
iface enp0s31f6 inet static
address 192.168.15.13
netmask 255.255.255.0
gateway 192.168.15.1
dns-nameservers 192.168.1.20

auto enp3s0f1
iface enp3s0f1 inet static
address 192.168.11.209
netmask 255.255.255.0
gateway 192.168.11.1
和文件/etc/systemd/resolved.conf配置DNS

[Resolve]
DNS=192.168.1.20

两种方式并非统一对应,而是存在冲突和二选一。若文件配置没有修改内容,则已界面配置为准;否则以文件配置为准。

原文地址:https://www.cnblogs.com/atoman/p/13537851.html