1. 程式人生 > >ubuntu下如何配置靜態ip

ubuntu下如何配置靜態ip

前些天在xubuntu 18.04 desktop上設定了下靜態IP,發現與centos/linux中區別極大。

1、首先檢視網絡卡名

$ ip a / ifconfig

2、 cp一份yaml檔案,改個名字

$ sudo cp /etc/netplan/*.yaml /etc/netplan/網絡卡名.yaml

3、修改yaml檔案內容,如下:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    網絡卡名:
      dhcp4: no
      addresses: [ip/prefix]
      gateway4: gateway
      nameservers:
        addresses: [dns]

4、啟動

$ sudo netplan apply

5、驗證

$ ip a / ifconfig

 

注意:

1)在yaml檔案中,不能用tab鍵,會報錯。

2)有五層,每層空兩格