ubuntu18.04server 真机无法自动获取IP解决方法

1、查看正确的网卡名称

1 sudo ifconfig -a

因为此图为虚拟机搭建的,所以网卡名称为ens33,如果是真机的话则是enp0s**的名字

2、修改netwlpan文件

 1 sudo vim /etc/netplwan/50-cloud-init.yaml
 2 
 3 一下为默认配置文件
 4 
 5 # This file is generated from information provided by
 6 # the datasource.  Changes to it will not persist across an instance.
 7 # To disable cloud-init's network configuration capabilities, write a file
 8 # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
 9 # network: {config: disabled}
10 network:
11     ethernets:
12         ens33:
13             addresses: []
14             dhcp4: true
15             optional: true
16     version: 2

修改第12行的网卡名称和ifconfig -a中的第一个网卡的名称一样就可以了。

保存退出

1 :wq!   或  :x
2 reboot

重启系统,就可以解决了

posted @ 2018-06-26 15:16  Lyvin.zhang  阅读(5123)  评论(0编辑  收藏  举报