系统相关
首页 > 系统相关> > ubuntu18.04网络配置

ubuntu18.04网络配置

作者:互联网

ubuntu18.04网络配置

YAML文件格式:常量值,对象,数组

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

标签:addr,no,配置,arpa,网络,setting,ubuntu,ubuntu18.04,root
来源: https://blog.51cto.com/14012942/2430357