3

The code below generates two CentOS 7 GUEST virtual machines on a CentOS 7 HOST. One of the virtual machines is connected to the internet via a PUBLIC IP address. The other is given a PRIVATE IP address, but is not able to ping the gateway or be pinged by the other virtual machine.

The server needs two routes. One route for each of the virtual machines to communicate with each other using PRIVATE IP addresses. And another route for the first virtual machine to use to communicate with the outside world using a PUBLIC IP address. What specific changes need to be made to the below to make this happen?


Creating the Public Virtual Machine

The following command successfully sets the IP address and gateway, dns, netmask, etc automatically during install, so that the resulting virtual machine is immediately able to interact on the internet as the desired PUBLIC IP:

virt-install --name=public-centos7 --disk path=/var/lib/libvirt/images/guest.img,size=50 \
--graphics none --vcpus=1 --memory=2048 --location /tmp/CentOS-7-x86_64-Minimal-1611.iso \
--network=default --os-type=linux --os-variant=rhel7.0 --initrd-inject=/tmp/vm.ks \
--extra-args "ks=file:/vm.ks console=ttyS0 ip=PUBLIC.IP.OF.VM::PUBLIC.IP.OF.GATEWAY:255.255.255.248:localhost2:eth0:none"


Creating the PRIVATE Virtual Machine

The following command creates a virtual machine that is NOT able to ping PUBLIC.IP.OF.GATEWAY or any other address. Also, the other virtual machine created above is not able to ping 192.168.122.2 after the following command is run:

virt-install --name=private-centos7 --disk path=/var/lib/libvirt/images/guest2.img,size=50 \
--graphics none --vcpus=1 --memory=2048 --location /tmp/CentOS-7-x86_64-Minimal-1611.iso \
--network=default --os-type=linux --os-variant=rhel7.0 --initrd-inject=/tmp/vm.ks \
--extra-args "ks=file:/vm.ks console=ttyS0 ip=192.168.122.2::PUBLIC.IP.OF.GATEWAY:255.255.255.0:localhost2:eth0:none"

However, while the above virt-install command was running, the following lines were added to the dmesg logs:

[94333.242521] systemd[1]: sys-subsystem-net-devices-vnet1.device changed plugged -> dead
[94333.242528] systemd[1]: sys-devices-virtual-net-vnet1.device changed plugged -> dead
[94333.242533] systemd[1]: Collecting sys-devices-virtual-net-vnet1.device
[94333.242534] systemd[1]: Collecting sys-subsystem-net-devices-vnet1.device

Other logs were also written to dmesg during the virt-install run, but the 4 above lines were the most related to networking. Should I look for some way of addressing the report that vnet1 is dead? If so, how?


default Network On HOST:

The following is the xml definition of the default network on the HOST:

[root@localhost ~]# virsh net-edit default
<network>
  <name>default</name>
  <uuid>some-long-complex-string</uuid>
  <forward mode='nat'/>
  <bridge name='br0' stp='on' delay='0'/>
  <mac address='11:22:33:44:55:66'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>
~
~
"/tmp/virshycDOpm.xml" 12L, 347C

And here is the output listing the bridges available on the HOST:

[root@localhost ~]# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.1stStringID        no              eno1
                                                        vnet0
                                                        vnet1
virbr0          8000.2ndStringID        yes             virbr0-nic
[root@localhost ~]#  

Note that the same problem persists whether the bridge name in the default network xml definition is set to virbr0 or to br0.


PRIVATE Guest Config:

[root@localhost ~]# virsh console public2-centos7
Connected to domain public2-centos7
Escape character is ^]
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    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 pfifo_fast state UP qlen 1000
    link/ether 11:22:33:44:55:66 brd aa:bb:cc:dd:ee:ff
    inet 192.168.122.2/29 brd 192.168.122.7 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 ipv6:addr:does:NOT::matter/128 scope global dynamic
       valid_lft 603985sec preferred_lft 603985sec
    inet6 ipv6:addr:does:NOT::matter/64 scope global noprefixroute dynamic
       valid_lft 2371267sec preferred_lft 297667sec
    inet6 ipv6:addr:does:NOT::matter/64 scope link
       valid_lft forever preferred_lft forever
[root@localhost ~]# ping 192.168.122.7
Do you want to ping broadcast? Then -b
[root@localhost ~]#


@Christopher's Suggestions:

Per @Christopher's suggestion, I ran the following commands on the HOST:

[root@remote-host ~]# netstat -anr
Kernel IP routing table
Destination           Gateway                Genmask         Flags   MSS Window  irtt Iface
0.0.0.0               PUBLIC.IP.OF.GATEWAY   0.0.0.0         UG        0 0          0 br0
PUBLIC.IP.OF.HOST-1   0.0.0.0                255.255.255.248 U         0 0          0 br0
192.168.122.0         0.0.0.0                255.255.255.0   U         0 0          0 virbr0

[root@remote-host ~]# vi /etc/iproute2/rt_tables
#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
~
"/etc/iproute2/rt_tables" 11L, 87C

Note that the Destination specified for br0 is one less than the PUBLIC.IP.OF.HOST, which means that it is a PUBLIC IP, but that it is NOT one of the public IPs for which our internet account has any claim.

Per @Christopher's suggestion, I hear that I should change /etc/iproute2/rt_tables to become:

#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
200 mgmt

The contents of the directory containing the ifcfg files on the CentOS 7 server in question are as follows:

[root@remote-host ~]# ls -al /etc/sysconfig/network-scripts
total 256
drwxr-xr-x. 2 root root  4096 Mar 28 08:18 .
drwxr-xr-x. 6 root root  4096 Mar 28 08:18 ..
-rw-r--r--. 1 root root   148 Mar 24 19:39 ifcfg-br0
-rw-r--r--. 1 root root   129 Mar 24 19:36 ifcfg-eno1
-rw-r--r--. 1 root root 12288 Mar 26 13:18 .ifcfg-eno1.swp
-rw-r--r--. 1 root root   254 Sep 12  2016 ifcfg-lo
lrwxrwxrwx. 1 root root    24 Mar 24 19:16 ifdown -> ../../../usr/sbin/ifdown
-rwxr-xr-x. 1 root root   627 Sep 12  2016 ifdown-bnep
-rwxr-xr-x. 1 root root  5817 Sep 12  2016 ifdown-eth
-rwxr-xr-x. 1 root root  6196 Nov  5 18:47 ifdown-ib
-rwxr-xr-x. 1 root root   781 Sep 12  2016 ifdown-ippp
-rwxr-xr-x. 1 root root  4201 Sep 12  2016 ifdown-ipv6
lrwxrwxrwx. 1 root root    11 Mar 24 19:16 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root  1778 Sep 12  2016 ifdown-post
-rwxr-xr-x. 1 root root  1068 Sep 12  2016 ifdown-ppp
-rwxr-xr-x. 1 root root   837 Sep 12  2016 ifdown-routes
-rwxr-xr-x. 1 root root  1444 Sep 12  2016 ifdown-sit
-rwxr-xr-x. 1 root root  1621 Nov  5 18:36 ifdown-Team
-rwxr-xr-x. 1 root root  1556 Apr 15  2016 ifdown-TeamPort
-rwxr-xr-x. 1 root root  1462 Sep 12  2016 ifdown-tunnel
lrwxrwxrwx. 1 root root    22 Mar 24 19:16 ifup -> ../../../usr/sbin/ifup
-rwxr-xr-x. 1 root root 12688 Sep 12  2016 ifup-aliases
-rwxr-xr-x. 1 root root   859 Sep 12  2016 ifup-bnep
-rwxr-xr-x. 1 root root 11880 Sep 12  2016 ifup-eth
-rwxr-xr-x. 1 root root 10145 Nov  5 18:47 ifup-ib
-rwxr-xr-x. 1 root root 12039 Sep 12  2016 ifup-ippp
-rwxr-xr-x. 1 root root 10525 Sep 12  2016 ifup-ipv6
lrwxrwxrwx. 1 root root     9 Mar 24 19:16 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root   642 Sep 12  2016 ifup-plip
-rwxr-xr-x. 1 root root  1043 Sep 12  2016 ifup-plusb
-rwxr-xr-x. 1 root root  2772 Sep 12  2016 ifup-post
-rwxr-xr-x. 1 root root  4154 Sep 12  2016 ifup-ppp
-rwxr-xr-x. 1 root root  1925 Sep 12  2016 ifup-routes
-rwxr-xr-x. 1 root root  3263 Sep 12  2016 ifup-sit
-rwxr-xr-x. 1 root root  1755 Apr 15  2016 ifup-Team
-rwxr-xr-x. 1 root root  1876 Apr 15  2016 ifup-TeamPort
-rwxr-xr-x. 1 root root  2682 Sep 12  2016 ifup-tunnel
-rwxr-xr-x. 1 root root  1740 Sep 12  2016 ifup-wireless
-rwxr-xr-x. 1 root root  4623 Sep 12  2016 init.ipv6-global
-rw-r--r--. 1 root root 15383 Sep 12  2016 network-functions
-rw-r--r--. 1 root root 26829 Sep 12  2016 network-functions-ipv6

And the contents of ifcfg-br0 are as follows:

[root@remote-host ~]# vi /etc/sysconfig/network-scripts/ifcfg-br0
TYPE=Bridge
BOOTPROTO=static
NAME=br0
DEVICE=br0
ONBOOT=yes
DNS1=11.11.11.11
DNS2=11.11.22.22
IPADDR=PUBLIC.IP.OF.HOST
PREFIX=29
GATEWAY=PUBLIC.IP.OF.GATEWAY
~
~
"/etc/sysconfig/network-scripts/ifcfg-br0" 11L, 148C  

And the contents of ifcfg-eno1 are:

[root@remote-host ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno1
TYPE=Ethernet
BOOTPROTO=static
NAME=eno1
UUID=some-long-complicated-string-here
DEVICE=eno1
ONBOOT=yes
BRIDGE=br0

Do we need to add additional files and modify others? If so, how?

  • @Christopher I have read your link. Is there something specific that you suggest in this current situation? – CodeMed Mar 29 '17 at 18:57
  • @Christopher I added a section to the end of the OP with specifics from the server related to your suggestion. What specifically should I add to /etc/iproute2/rt_tables? – CodeMed Mar 29 '17 at 19:09
  • AFAICT, you only have one network; you should have one public-facing network and one internal network. – ILMostro_7 Mar 29 '17 at 19:32
  • @ILMostro_7 Did you notice that the default network is nat, which arguably would not explain how the PUBLIC vm is connecting to the internet? – CodeMed Mar 29 '17 at 19:34
  • @Christopher I added what I think you are suggesting to the end of the OP. But I am not clear how to translate this to CentOS 7, including either disabling NetworkManager, or writing something that is compatible with it. – CodeMed Mar 29 '17 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.