Странные сетевые проблемы с Бродягой, VirtualBox, полем Ansible и Ubuntu Server

Мы используем Vagrant и Ansible для настройки машины VirtualBox.

Это работало отлично, но недавно мы начали встречаться с некоторыми странными сетевыми проблемами с задачами, которые требуют доступа к Интернету, как: apt-get update, composer update, gem install и т.д. Эти проблемы время от времени появляются, и они нестабильны. Иногда это не может соединиться с некоторым именем сервера, или доменное имя не решает.

Интересно, когда я соединяюсь с самим полем через SSH (vagrant ssh) и дайте такие команды вручную, как sudo apt-get update; sudo apt-get dist-upgrade - это хорошо работает все время.

Вот демонстрационная ошибка с NPM:

failed: [localhost] => {"cmd": "/usr/bin/npm install --global npm-check-updates", "failed": true, "rc": 1}
stderr: npm http GET https://registry.npmjs.org/npm-check-updates
npm http GET https://registry.npmjs.org/npm-check-updates
npm http GET https://registry.npmjs.org/npm-check-updates
npm ERR! network getaddrinfo ENOTFOUND
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

Вот демонстрационная ошибка с APT:

failed: [localhost] => {"failed": true, "parsed": false}
invalid output was: SUDO-SUCCESS-qryiheatxowjxtcfbzrnzercnnwxtmyv
Traceback (most recent call last):
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1405611978.79-161922279792225/apt", line 1762, in <module>
    main()
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1405611978.79-161922279792225/apt", line 492, in main
    cache.update()
  File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 440, in update
    raise FetchFailedException(e)
apt.cache.FetchFailedException: W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/main/i18n/Translation-en_US  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/main/i18n/Translation-en  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/main/i18n/Translation-en_US.UTF-8  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/universe/i18n/Translation-en_US  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/universe/i18n/Translation-en  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/universe/i18n/Translation-en_US.UTF-8  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/i18n/Translation-en_US  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/i18n/Translation-en  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/i18n/Translation-en_US.UTF-8  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/i18n/Translation-en_US  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/i18n/Translation-en  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/i18n/Translation-en_US.UTF-8  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/main/source/Sources  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/universe/source/Sources  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/main/binary-i386/Packages  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/universe/binary-i386/Packages  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/source/Sources  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/source/Sources  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/binary-i386/Packages  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/binary-i386/Packages  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
, E:Some index files failed to download. They have been ignored, or old ones used instead.

Версии программного обеспечения:

  • ansible 1.6.6
  • Бродяга 1.6.3
  • VirtualBox 4.3.14

Мы используем следующее поле:

http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box

Хостом ОС является Ubuntu 14.04.

Мы встречаемся с такими проблемами с различными компьютерами в абсолютно различных сетях (различные города).

Какова может быть причина этого? Как мы отлаживаем его и фиксируем его?

Обновление № 1

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# "2" is an API version here.
Vagrant.configure("2") do |config|

  config.vm.box = "trusty32"
  config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box"

  config.vm.hostname = "wa.local"
  config.vm.network "private_network", ip: "192.168.2.2"

  # Using NFS for now, cause native sharing is broken
  config.vm.synced_folder ".", "/vagrant", nfs: true

  # Provisioning
  config.vm.provision "ansible" do |ansible|
    ansible.host_key_checking = false
    ansible.inventory_path = "ansible/inventory.ini"
    ansible.playbook = "ansible/vagrant.yml"
    ansible.limit = "all"
  end

  # Provider Configuration: VirtualBox
  config.vm.provider :virtualbox do |vb|
    # Setting RAM to 1 GB
    vb.memory = 1024
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
  end

end

Обновление № 2

Проблемы не стало на данный момент. Я все еще не знаю, почему это произошло во-первых. Возможно, строка vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] то, что я недавно добавил к Vagrantfile, помогло.

Спасибо за все предложения!

7
задан 23 July 2014 в 15:08
2 ответа

Есть ли у вас устройства предотвращения вторжений или брандмауэры, которые могут вызывать проблемы? Я видел, как методы автоматизации запускают правила, предназначенные для борьбы с ботами. Многочисленные соединения могут быть неправильно истолкованы как сканирование портов, попытки грубой силы и т.д. IDS/IPS/Firewalls затем начинает сбрасывать пакеты, что приводит к неудаче странных вещей без ясной логики, почему. Эти правила не срабатывают, когда вы делаете вещи вручную, так что все кажется нормальным, когда вы устраняете неполадки.

.
1
ответ дан 2 December 2019 в 23:51

5 лет спустя и версии до

  • Vagrant 2.2.4
  • Virtualbox 6.0.8

У меня все еще возникают те же проблемы. vb.customize ["modifyvm",: id, "--natdnshostresolver1", "on"] уже находится в Vagrantfile, и сейчас я совершенно не понимаю, что еще делать

Из того, что я понял до сих пор, похоже, что это какая-то проблема с DNS внутри виртуальной машины

0
ответ дан 2 December 2019 в 23:51

Теги

Похожие вопросы