2

I recently had to replace my PC, so copied the drive file for my guest Ubuntu 20.04 machine to the new box. I installed VM Ware Workstation Pro 16 and started the Ubuntu system up. When it started up I no longer have the eth0 network interface and certain applications are failing to connect. The default Firefox browser can access the internet, but some applications are failing to connect to my local network.

ifconfig -s shows this:

Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
docker0   1500        0      0      0 0             0      0      0      0 BMU
ens33     1500     6828      0      0 0          3357      0      0      0 BMRU
lo       65536      961      0      0 0           961      0      0      0 LRU
veth013d  1500      303      0      0 0           316      0      0      0 BMRU
veth0f0d  1500     2777      0      0 0           408      0      0      0 BMRU
veth78e2  1500    29689      0      0 0         33318      0      0      0 BMRU
vethbfaf  1500    39039      0      0 0         29841      0      0      0 BMRU

I have tried searching for commands to re-enable eth0, rename ens33 to etho0 and even re-installing the kernel modules and network manager but the /etc/network/interfaces does not exist (I have since discovered this is because it was removed from 18.04) and most of the commands listed in these links do not exist on my machine. I have updated the OS with sudo apt-get update && sudo apt-get upgrade which appeared to succeed.

Because /etc/network/interfaces/ does not exist I cannot add auto eth0.

I have looked in etc/netplan/01-network-manager-all.yaml but it just says:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

What can I do to get eth0 restored?

Matt W
  • 131
  • Simply moving a hard drive or an OS to different hardware often has issues. A reinstall of the OS is your best bet. – David Oct 14 '22 at 09:34
  • Doesn't that somewhat defeat the purpose of a virtualised machine? Regardless, there must be a way to restore the network device or rename an existing one, right?7 – Matt W Oct 17 '22 at 09:15

2 Answers2

0

Did have same issue after porting Ubuntu 20.04 from VirtualBox 6.1 to ESXi 6.5. Old interface "enp0s3" disappeared but new interface "ens33" appeared.

Configured "ens33" interface by following "IP Addressing" section of Ubuntu documentation: https://ubuntu.com/server/docs/network-configuration

P.S. boot log show that "eth0" was renamed to "ens33"

log line: "e1000 ens33: renamed from eth0"

command: "dmesg | grep eth0"

If you just need to rename interface use following commands:

ifconfig ens33 down
ip link set ens33 name eth0
ifconfig eth0 up
GaOlSt
  • 1
  • 1
0

You may need to run this (if you don't have NetworkManager installed):

systemctl restart systemd-networkd

Otherwise, it might be good to have periodically running script to check the network connection and restart the networking on the server. Here is what I use:

#!/bin/bash

Set target host IP or hostname to check the connectivity with:

TARGET_HOST='google.com'

Specify your log file:

LOG_FILE='/var/log/netmon.log'

count=$(ping -c 3 $TARGET_HOST | grep from* | wc -l)

if [ $count -eq 0 ]; then echo "$(date)" "Target host" $TARGET_HOST "unreachable, Restart network service!" >>$LOG_FILE systemctl restart systemd-networkd echo "$(date)" "Finished restarting network service" >>$LOG_FILE else echo "$(date) ===-> OK! " >>$LOG_FILE fi

And finally, make sure to have cron job added using crontab -e (after making the script file executable using chmod a+x path_to_your_script

*/10 * * * * /path_to_your_script