ubuntu 18.04设置静态IP

版权声明:转载请注明作者和出处! 作者QQ 152910000 https://blog.csdn.net/icodestechnology/article/details/90000447

vi编辑 /etc/netplan/01-network-manager-all.yaml 配置文件,原内容如下:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

更改为如下配置:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

  ethernets:
    ens33:   #配置的网卡名称
      dhcp4: no    #dhcp4关闭
      dhcp6: no    #dhcp6关闭
      addresses: [192.168.117.130/24]   #设置本机IP及掩码
      gateway4: 192.168.117.2   #设置网关
      nameservers:
          addresses: [114.114.114.114, 8.8.8.8]   #设置DNS

执行如下命令使设置生效:

netplan apply

没有更多推荐了,返回首页