Ubuntu20.04⽹络配置
Ubuntu20.04 ⽹络配置
设置 ROOT 密码
先设置 root 密码,后⾯直接使⽤ root ⽤户操作
it@it:~$ sudo passwd root
[sudo] password for it:
New password:
Retype new password:
passwd: password updated successfully
⽹络管理⼯具 netplan
1. 在 Ubuntu20.04 版本中使⽤ netplan 管理⽹络
2. 在安装好的 Ubuntu20.04 中没有 networking 和 NetworkManage 服务
3. netplan 配置⽂件:/etc/netplan/*.yaml ,⽂件名每个不⼀样
4. netplan ⽰例⽂件: /usr/share/doc/netplan/example/ ⽬录下,在该⽬录下有各种⽰例⽂件,可以提供帮助修改⽹卡配置
1. 编辑⽹络配置⽂件
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
2. 加载刚刚修改的配置⽂件信息
root@it:~# netplan apply
root@it:~#
没有提⽰报错信息,说明配置成功
root@it:~# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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/*.y
aml中⽣成特定后端配置⽂件    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配置应⽤到正在运⾏的系统,并⾃动回滚1. 启⽤调试信息
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:
ubuntu vim命令
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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。