个人小站

netplan配置网络

字数统计: 225阅读时长: 1 min
2022/04/19

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

原文作者:ted423

原文链接:http://ted423.github.io/Document/netplan/

发表日期:April 19th 2022, 2:52:00 pm

更新日期:April 19th 2022, 3:08:17 pm

版权声明:本站原创内容(一般是语句不通顺的那种)采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可,转载内容以及不带个人观点的分享不在此例,摘抄有Wiki的内容的文章统一根据Wiki采用 CC BY-SA 3.0

CATALOG