dns ubuntu20 有线网络_Ubuntu20.04 网络配置

本文介绍了如何在Ubuntu20.04上设置root密码并使用netplan进行网络配置。步骤包括:设置root密码、编辑网络配置文件`/etc/netplan/00-installer-config.yaml`、应用配置并验证IP信息。通过netplan的`apply`命令成功应用配置后,系统网络设置生效。
摘要由CSDN通过智能技术生成

Ubuntu20.04 网络配置

设置 ROOT 密码

先设置 root 密码,后面直接使用 root 用户操作

it@it:~$ sudo passwd root

[sudo] password for it:

New password:

Retype new password:

passwd: password updated successfully

网络管理工具 netplan

在 Ubuntu20.04 版本中使用 netplan 管理网络

在安装好的 Ubuntu20.04 中没有 networking 和 NetworkManage 服务

netplan 配置文件:/etc/netplan/*.yaml ,文件名每个不一样

netplan 说明文件: /usr/share/doc/netplan/example/ 目录下,在该目录下有各种样例文件,可以提供帮助

d9228415bbfd3aebcff3739e0a1b0399.png

修改网卡配置

编辑网络配置文件

root@it:~# vim /etc/netplan/00-installer-config.yaml

# This is the network config written by 'subiquity'

network:

ethernets:

ens32:

addresses:

- 192.168.121.25/24

gateway4: 192.168.121.2

nameservers:

addresses:

- 8.8.8.8

version: 2

加载刚刚修改的配置文件信息

root@it:~# netplan apply

root@it:~#

没有提示报错信息,说明配置成功

root@it:~# ip add

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: ens32: mtu 1500 qdisc fq_codel state UP group default qlen 1000

link/ether 00:0c:29:16:8d:18 brd ff:ff:ff:ff:ff:ff

inet 192.168.121.25/24 brd 192.168.121.255 scope global ens32

valid_lft forever preferred_lft forever

inet6 fe80::20c:29ff:fe16:8d18/64 scope link

valid_lft forever preferred_lft forever

netplan 帮助信息

root@it:~# netplan help

usage: /usr/sbin/netplan [-h] [--debug] ...

Network configuration in YAML #YAML中的网络配置

optional arguments:

-h, --help show this help message and exit #显示此帮助信息并退出

--debug Enable debug messages #启用调试消息

Available commands:

help Show this help message #显示帮助信息

apply Apply current netplan config to running system #应用当前netplan配置到运行系统

generate Generate backend specific configuration files from /etc/netplan/*.yaml #从/etc/netplan/*.yaml中生成特定后端配置文件

info Show current netplan version and available features #显示当前netplan版本和可用特性

ip Retrieve IP information from the system #从系统中检索IP信息

try Try to apply a new netplan config to running system, with automatic rollback #尝试将新的netplan配置应用到正在运行的系统,并自动回滚

启用调试信息

root@it:~# netplan --debug apply

** (generate:3189): DEBUG: 01:15:27.908: Processing input file /etc/netplan/00-installer-config.yaml..

** (generate:3189): DEBUG: 01:15:27.908: starting new processing pass

** (generate:3189): DEBUG: 01:15:27.908: We have some netdefs, pass them through a final round of validation

** (generate:3189): DEBUG: 01:15:27.908: ens32: setting default backend to 1

** (generate:3189): DEBUG: 01:15:27.908: Configuration is valid

** (generate:3189): DEBUG: 01:15:27.908: Generating output files..

** (generate:3189): DEBUG: 01:15:27.908: NetworkManager: definition ens32 is not for us (backend 1)

(generate:3189): GLib-DEBUG: 01:15:27.908: posix_spawn avoided (fd close requested)

DEBUG:netplan generated networkd configuration changed, restarting networkd

DEBUG:no netplan generated NM configuration exists

DEBUG:ens32 not found in {}

DEBUG:Merged config:

network:

bonds: {}

bridges: {}

ethernets:

ens32:

addresses:

- 192.168.121.25/24

gateway4: 192.168.121.2

nameservers:

addresses:

- 8.8.8.8

vlans: {}

wifis: {}

DEBUG:Skipping non-physical interface: lo

DEBUG:device ens32 operstate is up, not changing

DEBUG:{}

DEBUG:netplan triggering .link rules for lo

DEBUG:netplan triggering .link rules for ens32

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值