vmware ubuntu after suspend docker0 lost ip

安装在vmware里的ubuntu20 ,挂起,恢复后,网络就断了

检查ifconfig 发现是docker0 丢失ip 地址正常的dcker0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 2e:1c:f2:e1:c1:b9  txqueuelen 0  (以太网)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

挂起-恢复后的docker0变成

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 2e:1c:f2:e1:c1:b9  txqueuelen 0  (以太网)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

没有了ip地址,所以即使在vmware虚拟机内部访问 容器内的web服务,也访问不到了。 重启docker服务可以解决,但不符合我的需求,我希望挂起恢复直可以用。

 

最终发现是vmware的挂起机制的问题

If an IP is lost after a sleep/suspend then that is most likely due to the suspend/sleep mode that you are using.

There's hard sleep/suspend modes versus soft sleep/suspend modes.

If you have a soft sleep/suspend mode then the guest will runs scripts to release and renew the IP addresses.

The default is soft sleep/suspend mode...

As you mention both Fusion as well as Workstation..

On Fusion, select the VM, settings -> Advanced -> Power Options --> change "Suspend" to "Suspend Hard"

On Workstation, edit virtual machine settings -> Options tab -> Power -> change "Suspend Guest" to "Suspend"

IIRC then you don't need to change the resume.

Alternatively you would have to look at extending the vmware tools scripts for suspend/resume.

hope this helps,
--

把虚拟机的电源 挂起 从 “挂起客户机” 变成“挂起” 完美解决

 

 

 

------------------无效的方案 废弃------------------

 

参考 https://gist.github.com/lanrat/458066dbdeb460b9cef40dc2af639a24

sudo xed /etc/NetworkManager/NetworkManager.conf

添加

[keyfile]
unmanaged-devices=interface-name:docker*;interface-name:veth*;interface-name:br-*;interface-name:vmnet*;interface-name:vboxnet*;

 

posted @ 2022-02-22 06:56  永远的幻想  阅读(327)  评论(0)    收藏  举报