ubuntu22.04更改DNS
原创小于 1 分钟
ubuntu22.04更改DNS
环境说明
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
编辑 /etc/netplan
目录下文件
vim00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens18:
dhcp4: false
addresses:
- 192.168.1.4/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses:
- 192.168.1.1
version: 2
# 生效
netplan apply
# 命令行帮助
# netplan help
usage: /usr/sbin/netplan [-h] [--debug] ...
Network configuration in YAML
options:
-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
generate Generate backend specific configuration files from /etc/netplan/*.yaml
get Get a setting by specifying a nested key like "ethernets.eth0.addresses", or "all"
info Show available features
ip Retrieve IP information from the system
set Add new setting by specifying a dotted key=value pair like ethernets.eth0.dhcp4=true
rebind Rebind SR-IOV virtual functions of given physical functions to their driver
status Query networking state of the running system
try Try to apply a new netplan config to running system, with automatic rollback