Ubuntu 20 手动更换IP地址方法-VPS主机手动绑定IP教程

178 浏览技术资料ubuntu 20
0

Ubuntu 20 的配置写在 /etc/netplan/01-netcfg.yaml 里了,简单点按照下面的格式写或者直接替换你的IP和网关地址即可

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens3:
      addresses: [ 128.104.172.13/27 ]
      gateway4: 128.104.172.2
      nameservers:
          addresses:
              - "8.8.8.8"

详细配置的说明如下:

network:
  ethernets:
    ens160:     #配置的网卡的名称
      addresses: [192.168.0.105/24]    #配置的静态ip地址和掩码
      dhcp4: no    #关闭DHCP,如果需要打开DHCP则写yes
      optional: true
      gateway4: 192.168.0.1    #网关地址
      nameservers:
         addresses: [114.114.114.114,180.76.76.76]    #DNS服务器地址,多个DNS服务器地址需要用英文逗号分隔开
  version: 2
  renderer: networkd    #指定后端采用systemd-networkd或者Network Manager,可不填写则默认使用systemd-workd

最后让配置生效:

sudo netplan apply

 


分享到:
更改状态以发布

Login

Welcome! Login in to your account

Remember meLost your password?

Don't have account. Register

Lost Password

Register