Martin
Martin

Reputation: 768

Vagrant proxy works for `apt-get` but not for `ping`

In Ubuntu Xenial guest machine, I was unable to run apt-get update, and also unable to ping www.google.com. Then I set /etc/apt/apt.conf proxy settings:

Acquire::http::proxy "http://my.proxy.com:80";
Acquire::https::proxy "https://my.proxy.com:80";

Then I was able to run apt-get. Then I tried

export http_proxy=http://my.proxy.com:80
export https_proxy=https://my.proxy.com:80

But I am still unable to ping www.google.com. It just hangs with this message

PING www.google.com (74.125.202.105) 56(84) bytes of data.

So I tried using the vagrant-proxyconf plugin, version 1.5.2. I set the proxy settings in ~/.vagrant.d/Vagrantfile

Vagrant.configure("2") do |config|
    if Vagrant.has_plugin?("vagrant-proxyconf")
        config.proxy.http     = "http://my.proxy.com:80"
        config.proxy.https    = "https://my.proxy.com:80"
        config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
    end
    # ... other stuff
end

But I am still unable to ping www.google.com, whether I export the http_proxy settings or unset them.

I also tried some suggestions from some other answers, such as

config.vm.provider "virtualbox" do |v|
    v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end

and

config.vm.provider 'virtualbox' do |vb|
    vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
end

But none of this works. Does anyone have any ideas?

Thanks!

Upvotes: 1

Views: 367

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53793

ping is using ICMP protocol (see RFC 792) so you should check if your firewall is not blocking this protocol.

Upvotes: 1

Related Questions