前言
自己經常使用redhat 或者 centos,但是工作還是接觸到ubuntu。因此就准備裝一個虛擬機跑docker容器,遇到麻煩的問題就ip地址固化,並設置dns。
dns最后使用netplan工具設置的,dns設置不好識別不了各種域名,下載軟件不得行。
下載的版本是ubuntu server 18.0.4
/etc/netplan目錄下設置ip與dns
配置的內容如下
root@ubuntuvir-VirtualBox:~# cat /etc/netplan/01-network-manager-all.yaml .
./ ../ .bash_history .bashrc .cache/ .profile
root@ubuntuvir-VirtualBox:~# cat /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
dhcp4: no
addresses: [10.x.x.x/24]
gateway4: x.x.x.1
nameservers:
addresses: [8.8.8.8]
root@ubuntuvir-VirtualBox:~#
root權限修改文件,並執行
netplan apply
結尾
自己試過配置/etc/network/interfces /etc/resolv.conf。都沒有成功,因此就用了netplan.
netplan用來進行網絡設備的管理並設置,是18 lts版本引入的。netplan的配置文件位於/etc/netplan文件夾下面。