虚拟机ubuntu18.04设置静态IP

说明:

       网关:192.168.8.2

       待设置静态IP:192.168.8.25

1、编辑:vi /etc/netplan/01-network-manager-all.yaml

打开以后内容如下:

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

增加下面内容:

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

 2、保存后,输入指令:netplan apply

 3、检查

      1)、ifconfig,查看是否已是所配置的IP地址

      2)、ping 外网地址,Ping www.baidu.com

       能Ping通则说明配置完成

猜你喜欢

转载自www.cnblogs.com/SH170706/p/10357676.html