netplan配置网络

  • 1121 字
  • 次阅读

Ubuntu 17 开始使用netplan配置网络,因此很多其它系统的教程都不再适用(/etc/network/interfaces 下的配置已经不再起作用)

https://netplan.io/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 cat /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp5s0f0:
dhcp4: no
addresses:
- 192.168.0.4/24
enp6s0f0:
dhcp4: yes
dhcp4-overrides:
route-metric: 1
enp6s0f1:
dhcp4: no
addresses:
- 192.168.1.80/24
gateway4: 192.168.1.254

The top-level node in a netplan configuration file is a network: mapping
that contains version: 2 (the YAML currently being used by curtin, MaaS,
etc. is version 1), and then device definitions grouped by their type, such as
ethernets:, modems:, wifis:, or bridges:. These are the types that our
renderer can understand and are supported by our backends.

Each type block contains device definitions as a map where the keys (called
“configuration IDs”) are defined as below.

老实说,version干嘛的我没看懂,反正都写version: 2就完事了

测试

1
sudo netplan try

应用(其实上面那个命令用完之后按Enter也就应用了)

1
sudo netplan apply
打赏
打赏提示信息
分享
分享提示信息