按照常规方法在/etc/netword/intefaces设置静态ip,重启后静态ip无效。
经过一番折腾,ubuntu从17.10开始,已放弃在/etc/network/interfaces里固定IP的配置,即使配置也不会生效,而是改成netplan方式 ,配置写在/etc/netplan/01-netcfg.yaml或者类似名称的yaml文件里,18.04的server版本安装好以后,配置文件是:/etc/netplan/50-cloud-init.yaml,修改配置以后不用重启,执行 netplan apply 命令可以让配置直接生效。以前的重启网络服务命令/etc/init.d/networking restart或者services network restrart也都会提示为无效命令。
$sudo vim /etc/netplan/50-cloud-init.yaml,配置文件可按如下内容修改。
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
eth0:
dhcp4: no
addresses: [192.168.1.105/24]
gateway: 192.168.1.1
nameservers:
addresses: [114.114.114.114, 8.8.8.8]
version: 2
来源:CSDN
作者:zhdan~
链接:https://blog.csdn.net/zhangdongan1991/article/details/103996468