Vagrant OEL 8 DevOps · VirtualBox · Parallels · Networking

VagrantBehind Proxy & Firewall

Configure Vagrant to work behind corporate HTTP proxies and firewalls. vagrant-proxyconf plugin, dnf proxy settings, offline/air-gapped setup and required firewall ports.

In corporate environments, internet access is often routed through an HTTP proxy or restricted by firewall rules. This can break Vagrant box downloads, provisioner package installs (dnf/yum), and plugin installations. This page covers all the configuration needed to make Vagrant work in such environments.

BASH — Host Proxy Setup
# Install vagrant-proxyconf plugin
vagrant plugin install vagrant-proxyconf

# Set proxy environment variables on your host
export http_proxy="http://proxy.company.com:8080"
export https_proxy="http://proxy.company.com:8080"
export no_proxy="localhost,127.0.0.1,192.168.56.0/24"

# For Windows PowerShell
$env:http_proxy  = "http://proxy.company.com:8080"
$env:https_proxy = "http://proxy.company.com:8080"
$env:no_proxy    = "localhost,127.0.0.1"
Ruby — vagrant-proxyconf in Vagrantfile
# vagrant-proxyconf plugin automatically configures proxy inside VM
Vagrant.configure("2") do |config|
  config.vm.box = "generic/oracle8"

  # Read proxy from host environment
  if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http     = ENV["http_proxy"]   || "http://proxy.company.com:8080"
    config.proxy.https    = ENV["https_proxy"]  || "http://proxy.company.com:8080"
    config.proxy.no_proxy = ENV["no_proxy"]     || "localhost,127.0.0.1,192.168.56.0/24"
    # Apply to these tools inside VM
    config.proxy.enabled  = { apt: true, yum: true, git: true, svn: true, docker: true }
  end

  config.vm.provision "shell", inline: "dnf install -y wget curl"
end
BASH — dnf Proxy Config
# Inside OEL 8 VM — configure dnf proxy manually
# (if vagrant-proxyconf is not available)

sudo cat >> /etc/dnf/dnf.conf << EOF
proxy=http://proxy.company.com:8080
proxy_username=
proxy_password=
EOF

# Test
sudo dnf install -y wget

# Also set system-wide proxy
sudo cat >> /etc/environment << EOF
http_proxy=http://proxy.company.com:8080
https_proxy=http://proxy.company.com:8080
no_proxy=localhost,127.0.0.1,192.168.56.0/24
EOF

# Export for current session inside VM
export http_proxy="http://proxy.company.com:8080"
export https_proxy="http://proxy.company.com:8080"
export no_proxy="localhost,127.0.0.1"

# Test download
curl -v https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
BASH — Box Download Behind Proxy
# Set proxy before vagrant box add
export http_proxy="http://proxy.company.com:8080"
export https_proxy="http://proxy.company.com:8080"

# Download box
vagrant box add generic/oracle8

# Or use a locally cached box file
# Download the box file manually using a browser/curl from outside network
# Then add it locally
vagrant box add oel8-local /path/to/downloaded/oracle8.box

# For Parallels — use metadata JSON
vagrant box add /path/to/box-metadata.json

If your lab machines have no internet access at all, use this approach:

BASH — Air-Gapped Setup
# Step 1 — On a machine WITH internet access:
# Download box
vagrant box add generic/oracle8 --provider virtualbox
# Box is saved at: ~/.vagrant.d/boxes/generic-VAGRANTSLASH-oracle8/

# Download RPM packages needed for provisioning
mkdir -p ~/offline-rpms
dnf download --resolve --destdir ~/offline-rpms   mysql-community-server mysql-community-client

# Step 2 — Transfer to air-gapped machine:
# Copy ~/.vagrant.d/boxes/ directory
# Copy ~/offline-rpms/ directory
rsync -avz ~/.vagrant.d/boxes/ airgapped-machine:~/.vagrant.d/boxes/
rsync -avz ~/offline-rpms/ airgapped-machine:~/offline-rpms/

# Step 3 — On air-gapped machine:
# Use local RPMs in provisioner
vagrant up

# In provisioner script — install from local RPMs
dnf localinstall -y /vagrant/offline-rpms/*.rpm
BASH — Authenticated Proxy
# Proxy with username and password
export http_proxy="http://username:password@proxy.company.com:8080"
export https_proxy="http://username:password@proxy.company.com:8080"

# In Vagrantfile with vagrant-proxyconf
config.proxy.http  = "http://username:password@proxy.company.com:8080"
config.proxy.https = "http://username:password@proxy.company.com:8080"

# dnf.conf with authentication
sudo cat >> /etc/dnf/dnf.conf << EOF
proxy=http://proxy.company.com:8080
proxy_username=myuser
proxy_password=mypassword
EOF
DestinationPortPurpose
app.vagrantup.com443Box downloads, Vagrant Cloud
vagrantcloud-files.s3.amazonaws.com443Box file storage
repo.mysql.com443/80MySQL repository
yum.oracle.com443/80OEL packages
repo.percona.com443/80Percona/PXC packages
download.postgresql.org443/80PostgreSQL packages
github.com443Vagrant plugin downloads
💡 Note: If only specific boxes need to work offline, download them once on any machine with internet, then copy the ~/.vagrant.d/boxes/ directory to the target machine. Vagrant will use the locally cached box without needing internet.