Ubuntu Server系统配置ip

Ubuntu Server系统配置ip

    • 自动获取ip配置
    • 静态ip配置
    • 全局dns配置

自动获取ip配置

osadmin@osadmin:~$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  version: 2
  renderer: networkd
  ethernets:
    ens36: 
      dhcp4: true

osadmin@osadmin:~$ sudo netplan apply

## dns查看
osadmin@osadmin:~$ resolvectl status
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (ens36)
Current Scopes: DNS
     Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
   DNS Servers: 192.168.1.1
    DNS Domain: localdomain

静态ip配置

osadmin@osadmin:~$ cat  /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  version: 2
  renderer: networkd
  ethernets:
    ens36: 
      addresses: [192.168.1.202/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [114.114.114.114]

osadmin@osadmin:~$ sudo netplan apply


## dns查看
osadmin@osadmin:~$ resolvectl status
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (ens36)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 114.114.114.114
       DNS Servers: 114.114.114.114

全局dns配置

# 修改配置文件
osadmin@osadmin:~$ egrep -v "^#|^$" /etc/systemd/resolved.conf 
[Resolve]
DNS=8.8.8.8

#重启服务
osadmin@osadmin:~$ sudo systemctl restart systemd-resolved.service 

#查看dns配置
osadmin@osadmin:~$ resolvectl status
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
     DNS Servers: 8.8.8.8

Link 2 (ens36)
Current Scopes: DNS
     Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
   DNS Servers: 114.114.114.114

你可能感兴趣的:(网络管理,ubuntu,tcp/ip)