1

I am using a self-built Vagrant base box running a minimal installation of CentOS 7 (I created it following Vagrant's documentation - if you want more information, I outlined the process in an article on my website and you can download the machine from here).

Before provisioning the machine with Ansible (which is irrelevant for this question) I use the following Vagrantfile to bring up the box:

Vagrant.configure(2) do |config|
  config.vm.box = "relativkreativ/centos-7-minimal"
  config.vm.network "public_network", ip: "192.168.0.100", bridge: 'en0: WLAN (AirPort)'

  config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/id_rsa.pub"
  config.vm.provision "shell", inline: <<-END.gsub(/^\s{4}/, '')
    mkdir -m 0700 /root/.ssh
    mv /home/vagrant/id_rsa.pub /root/.ssh/authorized_keys
    chmod 0600 /root/.ssh/authorized_keys
    chown root:root /root/.ssh/authorized_keys
  END
end

Nothing fancy here, just adding an additional network interface and copying my public key.

When logging in to the server as root (ssh root@192.168.0.100) I sometimes get a broken pipe after a few seconds and the server is not pingable (sometimes even while running the Ansible manifest). Most of the time I am able to reconnect after a few tries but when this is not possible, I have to use Vagrant to login (vagrant ssh - this always works) and restart the network service (systemctl restart network.service). After that, SSH mostly works again for some time.

The server's routes:

[root@localhost ~]# ip route
default via 10.0.2.2 dev enp0s3 
10.0.2.0/24 dev enp0s3  proto kernel  scope link  src 10.0.2.15 
169.254.0.0/16 dev enp0s3  scope link  metric 1002 
169.254.0.0/16 dev enp0s8  scope link  metric 1003 
192.168.0.0/24 dev enp0s8  proto kernel  scope link  src 192.168.0.100

The network interfaces:

[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:c0:9e:5b brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 84324sec preferred_lft 84324sec
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:b6:45:8c brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255 scope global enp0s8
       valid_lft forever preferred_lft forever

Their configuration files:

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-lo 
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
HWADDR="08:00:27:C0:9E:5B"
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="enp0s3"
UUID="957d70e5-1097-4952-b3a4-dc67b919b934"
ONBOOT="yes"

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s8
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.0.100
NETMASK=255.255.255.0
DEVICE=enp0s8
PEERDNS=no
#VAGRANT-END

I disabled IPv6 for troubleshooting but this did not make a difference.

This also happens when I run the exact same workflow with my CentOS 6 Vagrant box (which I built in the exact same way), and also with Vagrant boxes other people built.

I am using the latest version of Vagrant (1.7.2) as well as VirtualBox (4.3.20). I did not change anything on VirtualBox' default network configuration.

Does anybody have any clue what is going on here? I cannot track this problem down.

Thanks a lot!

  • Exactly how are you trying to network this on the host? – Michael Hampton Jan 10 '15 at 15:07
  • What do you mean? – Michael Trojanek Jan 11 '15 at 0:56
0

For me it worked to disable the NetworkManager when I had the same problem (but with host-only network)

| improve this answer | |
  • If you could explain how to do that, this would be a better answer. Please edit your post. Thanks! – slhck May 22 '15 at 17:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.