1. 程式人生 > >[operator]Ubuntu server 18 設置靜態IP

[operator]Ubuntu server 18 設置靜態IP

ner icmp div add 5.7 from col gate yam

root@ubuntu-MesosMaster-Marathon:~# cat /etc/netplan/50-cloud-init.yaml 
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-inits network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens33:
            addresses: [
192.168.115.148/24] gateway4: 192.168.115.2 dhcp4: false nameservers: addresses: [192.168.115.2] version: 2

看文件格式就知道這個文件嚴格遵守yaml語法格式,需要 使用root權限,設置好之後可以使用如下命令進行即時生效

root@ubuntu-MesosMaster-Marathon:~# netplan apply                       
root@ubuntu
-MesosMaster-Marathon:~# ping baidu.com PING baidu.com (220.181.57.216) 56(84) bytes of data. 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=128 time=25.7 ms

[operator]Ubuntu server 18 設置靜態IP