Ubuntu设置静态IP

内容纲要
  • 进入配置文件夹
    cd /etc/netplan
  • 备份旧配置文件内容为 00-installer-config.yaml_before
    sudo cp 00-installer-config.yaml  00-installer-config.yaml_before
  • 旧 00-installer-config.yaml 的内容为:
    
    # This is the network config written by 'subiquity'
    network:
    ethernets:
    enp0s5:
      dhcp4: true
    version: 2
    ```
  • 修改配置文件
    sudo vim 00-installer-config.yaml
  • 更新后的00-installer-config.yaml内容为:
    network:
    version: 2
    renderer: NetworkManager
    ethernets:
    enp0s5:   # 网卡名称
      dhcp4: no     # 关闭dhcp
      dhcp6: no
      addresses: [10.211.55.10/24]  # 静态ip
      gateway4: 10.211.55.1     # 网关
      nameservers:
        addresses: [8.8.8.8, 114.114.114.114] #dns
  • 使配置生效
    sudo netplan apply
THE END
分享
二维码
< <上一篇
下一篇>>