⽹络配置(network configuration)
⽹络配置(network configuration)
Ubuntu 17.10 . , Ubuntu 18 .xx, Ubuntu 19.xx, Ubuntu 20 .xx
更新 /etc/netplan/10-ens3.yaml ⽂件
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: no
addresses: [192.168.1.1/24,'2401:c080::1/64']
gateway4: 192.168.1.254
nameservers:
addresses: [223.5.5.5]
routes:
- to: 192.168.2.0/24
via: 192.168.1.8
metric: 100
netplan apply 更新配置
Ubuntu 22 .xx
更新 /etc/netplan/10-ens3.yaml ⽂件
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: no
addresses: [192.168.1.1/24,'2401:c080::1/64']
nameservers:
addresses: [223.5.5.5]
routes:
- to: default
via: 192.168.1.254
- to: 192.168.2.0/24
via: 192.168.1.8
metric: 100
enp6s0:
match:
macaddress: 51:00:04:53:d8:61
mtu: 1450
dhcp4: no
addresses: [192.168.1.2/24]
netplan apply 更新配置
Ubuntu 16.xx, Ubuntu 17 . 04
更新 /etc/network/interfaces 配置⽂件
auto lo
iface lo inet loopback
auto enp1s0
iface enp1s0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254
dns-nameservers 223.5.5.5
post-up ip route add 192.168.2.0/24 dev enp1s0
iface enp1s0 inet6 static
address 2401:c080:1c01:727:5400:04ff:fe5d:d861
netmask 64
dns-nameservers 2001:19f0:300:1704::6
systemctl restart networking 重启⽹络
Ubuntu 12.xx - Ubuntu 15 .xx
更新 /etc/network/interfaces 配置⽂件
auto lo
iface lo inet loopback
auto enp1s0
iface enp1s0 inet static
address 158.247.202.27
netmask 255.255.254.0
gateway 158.247.202.1
dns-nameservers 108.61.10.10
post-up ip route add 169.254.0.0/16 dev enp1s0
iface enp1s0 inet6 static
address 2401:c080:1c01:727:5400:04ff:fe5d:d861
netmask 64
dns-nameservers 2001:19f0:300:1704::6
# Private network: net641f12e4075d3
auto enp6s0
iface enp6s0 inet static
address 10.34.96.3
netmask 255.255.240.0
mtu 1450
systemctl restart networking 重启⽹络
CentOS 6
更新 /etc/sysconfig/network-scripts/ifcfg-enp1s0 配置⽂件
DEVICE=enp1s0
ONBOOT=yes
BOOTPROTO=static
IPADDR=158.247.202.27
NETMASK=255.255.254.0
GATEWAY=158.247.202.1
DNS1=108.61.10.10
IPV6INIT=yes
IPV6ADDR="2401:c080:1c01:727:5400:04ff:fe5d:d861/64"
IPV6_AUTOCONF="yes"
DNS2=2001:19f0:300:1704::6
service network restart 重启⽹络
CentOS 7
更新 /etc/sysconfig/network-scripts/ifcfg-eth0 配置⽂件
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=158.247.202.27
NETMASK=255.255.254.0
GATEWAY=158.247.202.1
DNS1=108.61.10.10
IPV6INIT=yes
IPV6ADDR="2401:c080:1c01:727:5400:04ff:fe5d:d861/64"
IPV6_AUTOCONF="yes"
DNS2=2001:19f0:300:1704::6
# /etc/sysconfig/network-scripts/route-eth0 路由配置
169.254.0.0/16 dev eth0
service network restart 重启⽹络
CentOS 8
更新 /etc/sysconfig/network-scripts/ifcfg-enp1s0 配置⽂件
TYPE="Ethernet"
DEVICE="enp1s0"
ONBOOT="yes"
BOOTPROTO="none"
IPADDR=158.247.202.27
PREFIX=23
GATEWAY=158.247.202.1
DNS1=108.61.10.10
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
# 加载⽹络配置
nmcli con load /etc/sysconfig/network-scripts/ifcfg-enp1s0
nmcli con up 'System enp1s0'
Debian 7- 10
更新 /etc/network/interfaces 配置⽂件
auto lo
iface lo inet loopback
auto enp1s0
iface enp1s0 inet static
address 158.247.202.27
netmask 255.255.254.0
gateway 158.247.202.1
dns-nameservers 108.61.10.10
post-up ip route add 169.254.0.0/16 dev enp1s0
iface enp1s0 inet6 static
address 2401:c080:1c01:727:5400:04ff:fe5d:d861
netmask 64
dns-nameservers 2001:19f0:300:1704::6
# Private network: net641f12e4075d3
auto enp6s0
iface enp6s0 inet static
address 10.34.96.3
netmask 255.255.240.0
mtu 1450
systemctl restart networking.service 重启⽹络
[配置分享]Linux系统网络配置(network configuration).pdf