2018年7月15日 星期日

Ubunt 18.04 ip config

18.04 的IP 設定有變動
不在
/etc/network/interfaces

而是在
/etc/netplan/50-cloud-init.yaml


可以由此查找位置
vim /etc/netplan/

vim /etc/netplan/50-cloud-init.yaml

DHCP設定如下:


# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens3:
            addresses: []
            dhcp4: true
            optional: true
    version: 2


固定IP 設定則為:


# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens3:
            addresses: [192.168.1.220/24, ]
            gateway4: 192.168.1.254
            nameservers:
                 addresses: [192.168.1.254,8.8.4.4]
            dhcp4: false
            optional: true
    version: 2


設定完成後套用可藉由Debug確認設定有無錯誤

sudo netplan --debug apply

#apply 為套用
則如果無誤套用此設定。

沒有留言:

張貼留言