最近装了Ubuntu 20 桌面版,需要配置内网,一如既往地找/etc/network/interfaces去配置,发现没有。

于是上网查询,说桌面版现在使用的是netplan.io,官网打开后如下:

什么是NetPlan

Netplan is a utility for easily configuring networking on a linux system. You simply create a YAML description of the required network interfaces and what each should be configured to do. From this description Netplan will generate all the necessary configuration for your chosen renderer tool.

译文:

Netplan 是一个用于在 linux 系统上轻松配置网络的实用程序。您只需创建所需网络接口的 YAML 描述以及每个应配置的功能。根据此描述,Netplan 将为您选择的渲染器工具生成所有必要的配置。

NetPlan 如何工作

How does it work?

Netplan reads network configuration from /etc/netplan/*.yaml which are written by administrators, installers, cloud image instantiations, or other OS deployments. During early boot, Netplan generates backend specific configuration files in /run to hand off control of devices to a particular networking daemon.

Netplan currently works with these supported renderers

译文:

它是如何工作的?

Netplan 从 /etc/netplan/*.yaml 读取网络配置,这些配置由管理员、安装程序、云映像实例化或其他操作系统部署编写。在早期启动期间,Netplan 在 /run 中生成后端特定配置文件,以将设备控制权移交给特定的网络守护进程。

Netplan 目前可与这些受支持的渲染器一起使用。

  • NetworkManager
  • Systemd-networkd

也就是说,NetPlan 其实最终还是使用NetworkManager 和 System-networkd 完成网络配置,只不过配置方式改为更直观的yaml。

配置项

Netplan为yaml文件设计了一系列配置字段,这些字段满足详见Netplan | Backend-agnostic network configuration in YAML

配置示例

需求不一样,配置也不一样,以下是官方列出的常用配置示例:

network:version: 2# if specified globally, can only realistically have that value, as# networkd cannot render wifi/3G. This would be shipped as a separate# config.d/ by desktop images# it can also be specified by-type or by-devicerenderer: network-managerethernets:# opaque ID for physical interfaces with match rules# only referred to by other stanzasid0:match:macaddress: 00:11:22:33:44:55wakeonlan: truedhcp4: trueaddresses:- 192.168.14.2/24- 2001:1::1/64lom:# example for explicitly setting a backend (default would be networkd)match:driver: ixgbe# you are responsible for setting tight enough match rules# that only match one device if you use set-nameset-name: lom1dhcp6: trueswitchports:# all cards on second PCI bus# unconfigured by themselves will be added to br0 belowmatch:name: enp2*mtu: 1280wifis:all-wlans:# useful on a system where you know there is# only ever going to be one devicematch: {}access-points:"Joe's home":# mode defaults to "managed" (client), key type to wpa-pskpassword: "s3kr1t"# this creates an AP on wlp1s0 using hostapd# no match rules, thus ID is the interface namewlp1s0:access-points:"guest":mode: apchannel: 11# no WPA config implies default of openbridges:# the key name is the name for virtual (created) interfaces;# no 'match' or 'set-name' attributes are allowed.br0:# IDs of the components# switchports expands into multiple interfacesinterfaces: [wlp1s0, switchports]dhcp4: trueroutes:- to: 0.0.0.0/0via: 11.0.0.1metric: 3nameservers:search: [foo.local, bar.local]addresses: [8.8.8.8]

更多详细见Netplan | Backend-agnostic network configuration in YAML

命令

根据设计,配置完成后,Netplan 需要执行命令是配置生效。

  • netplan generate

    Use /etc/netplan to generate the required configuration for the renderers.

    使用 /etc/netplan 为渲染器生成所需的配置。

  • netplan apply

    Apply all configuration for the renderers, restarting them as necessary.

    应用渲染器的所有配置,并根据需要重新启动它们

  • netplan try

    Apply configuration and wait for user confirmation; will roll back if network is broken or no confirmation is given.

    应用配置并等待用户确认;如果网络中断或没有确认将回滚。

  • netplan get

    Merge and display all the current available configuration on the system.

    合并并显示系统上所有当前可用的配置。

  • netplan set

    Add new setting by specifying a dotted key=value pair like ethernets.eth0.dhcp4=true.

    通过指定带点的 key=value 对来添加新设置,例如 ethernets.eth0.dhcp4=true

  • netplan info

    Show available feature flags of the currently installed version as YAML.

    将当前安装版本的可用功能标志显示为 YAML。

  • netplan ip

    Retrieve IP information from the system.

    从系统中检索 IP 信息。

  • netplan help

    Show the help message.

    显示帮助信息。

更多详细,请移步官网。

当然,作为桌面版,可以在右上角找到网络设置功能,使用图形化配置来配置。

Ubuntu 20.4 没有/etc/network/interfaces,配置网络需用Netplan相关推荐

  1. linux配置接口多地址,Linux /etc/network/interfaces配置接口方法

    Linux下/etc/network/interfaces文件用来配置网络接口. 初始化网口Ethernet Interface 大部分的网络接口配置都可以在/etc/network/interfac ...

  2. Ubuntu 20.04 LTS/RTX30XX显卡 快速配置深度学习环境(一行命令)

    近日,新入一台RTX3080的服务器,目前好像还没办法很方便地在 RTX 30 系列 GPU上通过 pip/conda 安装 TensorFlow 或 PyTorch.因为这些 GPU 需要 CUDA ...

  3. linux ip端口配置文件,Linux /etc/network/interfaces配置接口方法

    Linux下/etc/network/interfaces文件用来配置网络接口. 初始化网口Ethernet Interface 大部分的网络接口配置都可以在/etc/network/interfac ...

  4. linux interfaces文件,Linux /etc/network/interfaces配置接口方法

    Linux下/etc/network/interfaces文件用来配置网络接口. 初始化网口Ethernet Interface 大部分的网络接口配置都可以在/etc/network/interfac ...

  5. Ubuntu 20.04安装、显卡驱动配置及搜狗输入法配置(U盘离线安装、vi编辑器,esc ZZ,tty3模式)(一)

    小白装Ubuntu20.04-系列记录(一) 目录 小白装Ubuntu20.04-系列记录(一) Ubuntu 20.04安装 显卡驱动配置(U盘离线安装.vi编辑器,esc ZZ,tty3模式) 搜 ...

  6. Ubuntu 20.04 连不上网,没有网络图标

    重启后没有网络和网络图标 尝试了很多的方法,都没有奏效.这个问题其中还包括使用ifconfig查看信息时只能显示127.0.0.1,其他什么信息都没有. 解决方法: 1.删除NetworkManage ...

  7. Raspberry/Ubuntu 20.04命令行连接eap-gtc企业wifi

    Ubuntu 20.04命令行连接eap-gtc企业wifi 1设置netplan内容 2设置wpa_supplicant 3 Raspberry 系统配置: 完成. 1设置netplan内容 在/e ...

  8. ubuntu命令行配置网络

    首先编辑/etc/network/interfaces 文件,在终端中执行下面的命令 sudo vi /etc/network/interfaces 配置静态IP地址 要编辑的内容如下: auto e ...

  9. Ubuntu环境基础配置 -- 网络配置

    转载1: Ubuntu镜像下载. 转载2: Ubuntu Server和Desktop版本的区别. 转载3: Server版.Desktop版本网络配置. 转载4: Ubuntu18下的网络配置. 转 ...

最新文章

  1. 双项通过|百度点石通过信通院「可信数据流通平台」、「联邦学习」双项测评
  2. 安卓虚拟linux系统教程,在Linux上模拟Android应用程序的3种方法 | MOS86
  3. 在hive的beeline下,Error: org.apache.thrift.transport.TTransportException: java.net.SocketException: Bro
  4. Spark RDD使用详解2--RDD创建方式
  5. 蓝图中实现人物移动1
  6. linux 分隔大文件,linux系统下分割大文件的方法
  7. php 7 class 初始化 销毁_在 PHP 中使用和管理 Session
  8. DateTimeFormat注解
  9. 浏览器cookie那些事儿
  10. STC学习:定时器和中断
  11. oracle解锁sysman用户,详解Oracle如何解锁用户的方法
  12. Dell安装Ubuntu教程
  13. WordPress使用腾讯云CDN配置如何实现https访问?
  14. psd 直接导入unity
  15. NVIDIA TITAN XP 显卡直通(Pass-through)求助
  16. 融云会话界面自定义功能_Android快速集成融云
  17. 网络打印机安装教程:HP LaserJet Pro MFP M226dw,Windows解决外网无法使用打印机问题
  18. Linux为什么不怕病毒
  19. Alpha GO核心原理
  20. 呃,bing 桌面词典中的成熟美女

热门文章

  1. Vue.use 写多个_缺少实践技能的你应该如何写简历
  2. 打开网页自动下载php,打开网页自动弹出下载aidclient.php窗口解决方法
  3. 爬虫怎么解决封IP?
  4. 为什么深度学习模型不能适配不同的显微镜扫描仪产生的图像
  5. java object大小_在Java中,确定对象object大小的最佳方法是什么? - Break易站
  6. 2023泰晤士高等教育世界大学排名发布(附TOP200榜单)
  7. 如何用科技拯救好吃的?——百度深度学习技术赋能可持续发展
  8. 神级插件Bito介绍及使用
  9. Ubuntu下的Selenium爬虫的配置
  10. py6s 光谱响应函数_Windows7 64位环境6sv2.1大气传输模型修改源码添加国产高分卫星GF-1 GF-2光谱响应支持...