未找到结果
我们无法找到任何使用该词的内容,请尝试搜索其他内容。
這是一篇筆記文,每一個 Linux distribution 的網路設定都不太一樣,最近裝了 Ubuntu Server 18.04 LTS 版 ( Cosmic cuttlefish),網路設定又變得陌生了,network Manager 改用 netplan ( 專案網站 ) 來管理網路設定
這是一篇筆記文,每一個 Linux distribution 的網路設定都不太一樣,最近裝了 Ubuntu Server 18.04 LTS 版 ( Cosmic cuttlefish),網路設定又變得陌生了,network Manager 改用 netplan ( 專案網站 ) 來管理網路設定,改好之後順便上來紀錄一下,不然下次又忘了 。
先看看原本熟悉的 /etc/network/interface 檔案變成什麼樣子:
# ifupdown has been replaced by netplan(5) on this system. See # /etc/netplan for current configuration. # To re-enable ifupdown on this system, you can run: # sudo apt install ifupdown
照上面的說明看了一下 /etc / netplan 目錄,查閱一下 /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-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: ens192: dhcp4: true ens224: dhcp4: true version: 2
看來可以關閉 cloud network,但是我其實也沒有要用 cloud-init,乾脆移除它,如下:
sudo apt-get remove cloud-init
然後把 /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-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: ens192: addresses: [192.168.32.231/24] gateway4: 192.168.32.1 nameservers: addresses: [8.8.8.8,8.8.4.4] dhcp4: no ens224: dhcp4: true version: 2
這幾年 yaml 深得大眾的心,設定檔就是要用 yaml 格式才是潮,解說一下上述幾個設定:
修改後存檔後輸入以下命令:
sudo netplan try
這個命令執行後會檢查設定檔格式,如果正確的話就會套用,並且在 120 秒以後自動還原設定!
是不是很貼心?想必各位應該有過把遠端 Linux 網路設定改錯 restart 的痛吧,有了這個設定,至少錯了在兩分鐘以後會還原,不至於讓你的終端機斷線以後就 GG 惹 ~
如果測試沒有問題,就可以執行以下命令真正進行設定 :
sudo netplan apply
就是那麼簡單,下台一鞠躬…
Configure Static IP Addresses On Ubuntu 18.04 LTS Server