ubuntu18.04网络配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu18.04网络配置相关的知识,希望对你有一定的参考价值。
ubuntu18.04网络配置YAML文件格式:常量值,对象,数组
dhcp自动获取:
root@ubuntu:~# grep -Ev "^$|#" /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: yes
root@ubuntu:~# netplan apply #应用
静态IP(单个IP):
root@ubuntu:~# grep -Ev "^$|#" /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: no
addresses: [192.168.38.130/24]
gateway4: 192.168.38.2
nameservers:
addresses: [8.8.8.8]
root@ubuntu:~# netplan apply
静态IP(多个IP),采用数组格式
root@ubuntu:~# grep -Ev "^$|#" /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: no
addresses:
- 192.168.38.130/24
- 192.168.38.103/24
gateway4: 192.168.38.2
nameservers:
addresses:
- 192.168.38.2
- 8.8.8.8
root@ubuntu:~# netplan apply
DNS查看
root@ubuntu:~# ll /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Jul 18 01:36 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
root@ubuntu:~# systemd-resolve --status
Global
LLMNR setting: no
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 3 (docker0)
Current Scopes: none
DefaultRoute setting: no
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 2 (ens33)
Current Scopes: DNS
DefaultRoute setting: yes
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.38.2
8.8.8.8
以上是关于ubuntu18.04网络配置的主要内容,如果未能解决你的问题,请参考以下文章