16版本配置
/etc/network/
vim interfaces
注释iface xxxxxx xxxx dhcp
复制iface
并改为ifcae xxxx xxx static
address 192.168.68.188
netmask 255.255.255.0
gateway 192.168.68.2
配置DNS
18版本配置静态IP
打开vim /etc/netplan/01-network-manager-all.yaml
配置文件,原文内容如下
Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
1
2
3
4
修改后的配置
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及掩码
执行以下命令使得配置生效,然后IP 地址就变成了静态,并且ping 互联网的地址就正常了
netplan apply
gateway4: 192.168.117.2 #设置网关
nameservers:
addresses: [114.114.114.114, 8.8.8.8] #设置DNS
复制代码
18静态ip网络配置
network:
ethernets:
ens33:
addresses:
- 192.168.1.64/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 114.114.114.114
version: 2
Q.E.D.