Ubuntu Linux 20.04 網路設定由 netplan 管理
如果一開始設定是 dhcp client 的話,/etc/netplan/00-installer-config.yaml 設定類似如下

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens160:
      dhcp4: true #使用dhcp 抓動態ip
  version: 2


以下是改成固定 ip 的步驟
1. 確認/etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg 是否為以下參數
network: {config: disabled}

2. 修改 /etc/netplan/00-installer-config.yaml
network:
  ethernets:
    ens160:

      addresses: [10.10.10.246/24] #靜態ip 地址
      gateway4: 10.10.10.254 # default gateway
      nameservers:
        addresses: [10.10.10.26,8.8.8.8] #dns server, 兩組以上可用逗點隔開

  version: 2
存檔離開

3. 套用設定檔
# netplan apply

4. 檢查ip 是否生效
# ip addr show 或是 # ifconfig -a

undefined

 

arrow
arrow
    文章標籤
    ubuntu linux netplan 固定ip
    全站熱搜

    helloworld 發表在 痞客邦 留言(0) 人氣()