文章目录[隐藏]
# 先查看动态IP时的网络参数
ip addr
# 修改配置文件,配置静态IP
vim /etc/netplan/01-netcfg.yamlnetwork:
version: 2
renderer: NetworkManager
ethernets:
eth0:
dhcp4: no
addresses: [192.168.12.18/24]
gateway4: 192.168.12.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]完成上述配置,执行: netplan apply
1. network命令
#service network restart
或者
# /etc/init.d/networking restart
2. ifdown/ifup命令
# ifdown eth0 关闭
# ifup eth0 开启
3. ifconfig命令
# ifconfig eth0 down 关闭
# ifconfig eth0 up 开启