CentOS VM on hyper-v cannot establish internet connection

Issues related to applications and software problems and general support
Post Reply
Johnylemony
Posts: 1
Joined: 2021/06/03 22:27:37

CentOS VM on hyper-v cannot establish internet connection

Post by Johnylemony » 2021/06/03 22:32:23

Hello
I am having problems with configuring internet connection for CentOS VM hosted on Hyper-V

Initially I installed OS with 1 internal network card. Configured it and now I am able to communicate between VMs hosted on mu computer - that's eth0.

Next I added external network card and rebooted VMs. Can't make it work from here.. Any ideas what might be wrong here?

I use same external switch for Windows server and it works fine.

At first device was disconnected

DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
eth1 ethernet disconnected --
lo loopback unmanaged --
nmcli con add type ethernet con-name zew ifname eth1

Now device is connected

DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
eth1 ethernet connected zew
lo loopback unmanaged --
Here's results of cat /etc/sysconfig/network-scripts/ifcfg-zew

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=zew
UUID=ed19cc64-5446-4d96-9564-76dcc840645b
DEVICE=eth1
ONBOOT=yes
nmcli connection show is all green

NAME UUID TYPE DEVICE
eth0 86933dbd-7c39-45b9-b9cf-0f2a16cb7d34 ethernet eth0
zew ed19cc64-5446-4d96-9564-76dcc840645b ethernet eth1
cat /etc/resolv.conf

# Generated by NetworkManager
search home thebest.local
nameserver 192.168.1.1
results of ip a


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:19:10:10 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.35/24 brd 192.168.1.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::7259:9d8a:acc7:52e0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:19:10:13 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.38/24 brd 192.168.1.255 scope global dynamic noprefixroute eth1
valid_lft 86126sec preferred_lft 86126sec
inet6 fe80::3af6:a29a:6111:1d34/64 scope link noprefixroute
valid_lft forever preferred_lft forever
when I try to ping google

[root@ora-linux network-scripts]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.1.35 icmp_seq=1 Destination Host Unreachable

Resolve.conf file has strange the best.local value which is name of my windows domain
I was playing with adding a hostname with such name, but I have since removed it from /etc/hostname

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: CentOS VM on hyper-v cannot establish internet connection

Post by TrevorH » 2021/06/04 08:08:07

You've put the 2nd interface in the same subnet as the first and it's using DHCP so it'll grab the gateway address from DHCP and set it (you set DEFROUTE=yes). So when hte 2nd interface is up it tries to send all your traffic via the new interface. Then you run into complications with the 2 interfaces having ip addresses in the same subnet. That can be done but it's complicated and not recommended.

Why do you want a 2nd interface in the same subnet anyway?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: CentOS VM on hyper-v cannot establish internet connection

Post by jlehtone » 2021/06/04 08:49:35

Note that the main issue is not in CentOS, but in HyperV/physical network configuration.

You essentially have a machine (VM) with two network cards that are both connected to same network switch and get addresses from same DHCP server. To same subnet.

What are the "internal" and "external" network cards? Are those HyperV terms?

Post Reply