You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Network is unreachable after turning on VPN #1307
I have the same problem on my Mac, I use a vpn for connecting to my workplace from home, and the vpn does not allow split tunnel, so everything must be routed over the vpn, but the subnet the containers use are not allowed over the vpn.
If I use Docker Desktop for mac it works both with and without the VPN active.
If there some other software than mDNSResponder listening on IPv4:*:53 then you're probably looking at a dupe of #402.
What I want to check is whether this is a routing issue or a potential DNS issue. @kennytm tested with ping to IP addresses so that could mean a routing issue, or that the ICMP packets are getting blackholed for some other reason.
I run container with a VPN active pretty much 100% of the time. Mostly full-tunnel but sometimes split tunnel.
If there some other software than mDNSResponder listening on IPv4:*:53 then you're probably looking at a dupe of #402.
What I want to check is whether this is a routing issue or a potential DNS issue. @kennytm tested with ping to IP addresses so that could mean a routing issue, or that the ICMP packets are getting blackholed for some other reason.
I run container with a VPN active pretty much 100% of the time. Mostly full-tunnel but sometimes split tunnel.
I bumped into the same problems with Zscaler.
External and als Containers Internal DNS is blocked.
External can be overriden with the mentioned --dns 8.8.8.8, but internal is then still non functional.
For container machine this workaround is not availaible, so here the container image needs to be patched.
Would be great if we could get a solution.
Because the docker people eventually got it working.
Otherwise for now apple containers as amazing as it is already, cannot be used with a zscaler corporate proxy. @goafabric remindme
At least part of the problem is that the container system always uses the default hardware interface for the ipv4Gateway and ipv6Gateway, which fails when you have a VPN which prevents split-tunneling by restricting all traffic other than the VPN itself. There doesn't seem to be a documented way to change that gateway.
At least part of the problem is that the container system always uses the default hardware interface for the ipv4Gateway and ipv6Gateway, which fails when you have a VPN which prevents split-tunneling by restricting all traffic other than the VPN itself. There doesn't seem to be a documented way to change that gateway.
Have you tried my workaround in #1307 (comment)
this works perfectly for me. only after reboot or updates i have to redo adding the fw rule as it is not permanent (haven't looked in how to do it).
9. Problem is VPN client changes the default route and than NAT does not work anymore.
in my case my VPN interface is utun6. Setting an explicit NAT rule fixes it for me. echo "nat on utun6 from 192.168.64.0/24 to any -> (utun6)" | pfctl -a "com.apple.internet-sharing" -N -f -
Thanks @ThomasSchoeller It works for me.
You run it like this: container run --rm --dns 10.64.0.1 docker.io/library/alpine nslookup api.github.com
Add more DNS if you don't always exit through the VPN container run --rm --dns 10.64.0.1 --dns 1.1.1.1 docker.io/library/alpine nslookup api.github.com
although it adds a few rounds of failures.
Here's script I've added to my ~/.local/bin
#!/usr/bin/env bash
# Add a pf NAT rule so Apple `container` VMs can reach the internet through an
# active full-tunnel VPN (workaround for apple/container#1307).
# Run it after the VPN connects, and again after a reboot, update or reconnect.
set -euo pipefail
SUBNET="${CONTAINER_SUBNET:-192.168.64.0/24}"
ANCHOR="com.apple.internet-sharing"
IF=$(route -n get 1.1.1.1 2>/dev/null | awk '/interface:/ {print $2}')
if [[ -z "$IF" ]]; then
echo "No route to 1.1.1.1 (offline?)" >&2
exit 1
fi
if [[ "$IF" != utun* ]]; then
echo "Traffic goes out via $IF, not a VPN tunnel: no rule needed."
exit 0
fi
if ! out=$(echo "nat on $IF from $SUBNET to any -> ($IF)" | sudo pfctl -a "$ANCHOR" -N -f - 2>&1); then
echo "$out" >&2
exit 1
fi
echo "Applied:"
sudo pfctl -a "$ANCHOR" -s nat 2>&1 | grep '^nat' || true
One of the laptops I use has a GlobalProtect VPN and although I came across a few suggestions and scripts in this repo, nothing seemed to work. After some back and forth with one LLM, I managed to get it working.
The is the script the LLM came up with
~/.bin/container-vpn
#!/usr/bin/env bash
# Make Apple `container` networking work while GlobalProtect is connected.
#
# GlobalProtect routes every local subnet (including the container vmnet subnet)
# into its tunnel, so replies NATed back by vmnet get sent to utunX instead of the
# container bridge. This loads a pf rule that re-routes those packets to the bridge.
#
# Usage: container-vpn [up|down|status]
set -euo pipefail
ANCHOR="com.apple/container-vpn"
vpn_if() {
route -n get default 2>/dev/null | awk '/interface:/ {print $2}'
}
# Bridge that holds the gateway address; only exists while a container is running.
bridge_for() {
local gw="$1" i
for i in $(ifconfig -l); do
[[ "$i" == bridge* ]] || continue
ifconfig "$i" | grep -q "inet $gw " && { echo "$i"; return; }
done
echo "bridge100"
}
rules() {
local tun="$1" name subnet base gw br
container network ls | awk 'NR > 1 {print $1, $2}' | while read -r name subnet; do
base="${subnet%/*}"
gw="${base%.*}.1"
br="$(bridge_for "$gw")"
echo "# network $name ($subnet) via $br" >&2
echo "pass out quick on $tun route-to $br inet from any to $subnet no state"
done
}
up() {
local tun
tun="$(vpn_if)"
if [[ "$tun" != utun* ]]; then
echo "Default route is via '${tun:-none}', not a VPN tunnel; nothing to do." >&2
exit 0
fi
echo "VPN interface: $tun" >&2
rules "$tun" | sudo pfctl -a "$ANCHOR" -f - 2>/dev/null
sudo pfctl -s info 2>/dev/null | grep -q 'Status: Enabled' || sudo pfctl -e 2>/dev/null
status
}
down() {
sudo pfctl -a "$ANCHOR" -F all 2>/dev/null
echo "Removed rules from anchor $ANCHOR" >&2
}
status() {
sudo pfctl -a "$ANCHOR" -vsr 2>/dev/null
}
case "${1:-up}" in
up) up ;;
down) down ;;
status) status ;;
*) echo "Usage: $(basename "$0") [up|down|status]" >&2; exit 1 ;;
esac
To run a container with external / internaet networking access, just run the script before starting any container. Hope this helps someone else.
container system start
container-vpn up
Start any container
Test result
container run --rm alpine ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=55 time=10.318 ms
64 bytes from 1.1.1.1: seq=1 ttl=55 time=11.172 ms
^C
--- 1.1.1.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 10.318/10.745/11.172 ms
Activity
kennytm commentedon Mar 13, 2026
it seems to loss internet connection only for destinations that needs to be routed through the VPN.
for instance, when i set up a WireGuard peer with
AllowIPs = 1.1.1.1/32on the Mac, then:rsteneteg commentedon Mar 25, 2026
I have the same problem on my Mac, I use a vpn for connecting to my workplace from home, and the vpn does not allow split tunnel, so everything must be routed over the vpn, but the subnet the containers use are not allowed over the vpn.
If I use Docker Desktop for mac it works both with and without the VPN active.
jglogan commentedon Mar 26, 2026
@jkchen1095 @rsteneteg could you provide the output of this command?
If there some other software than
mDNSResponderlistening on IPv4:*:53 then you're probably looking at a dupe of #402.What I want to check is whether this is a routing issue or a potential DNS issue. @kennytm tested with ping to IP addresses so that could mean a routing issue, or that the ICMP packets are getting blackholed for some other reason.
I run
containerwith a VPN active pretty much 100% of the time. Mostly full-tunnel but sometimes split tunnel.rsteneteg commentedon Mar 26, 2026
Hi,
This the the output before I connect the vpn
and this is after
Even if I use IP rather than dns it also don't work.
My works VPN only allows specific CIDRs to pass through the vpn :/ and the containers are not in those approved CIDRs
menthena commentedon Apr 29, 2026
Similarly I have the same issue. With my personal Mac, I am able to curl as expected.
sudo lsof -i :53output is empty.Workplace Macbook is behind ZScaler, and seeing "Could not contact DNS servers".
Unfortunately unable to kill the ZScaler process.
container CLI version 0.12.1 (commit: e9891b3)ThomasSchoeller commentedon May 22, 2026
Problem is VPN client changes the default route and than NAT does not work anymore.
in my case my VPN interface is utun6. Setting an explicit NAT rule fixes it for me.
echo "nat on utun6 from 192.168.64.0/24 to any -> (utun6)" | pfctl -a "com.apple.internet-sharing" -N -f -goafabric commentedon Jul 7, 2026
I bumped into the same problems with Zscaler.
External and als Containers Internal DNS is blocked.
External can be overriden with the mentioned --dns 8.8.8.8, but internal is then still non functional.
For container machine this workaround is not availaible, so here the container image needs to be patched.
Would be great if we could get a solution.
Because the docker people eventually got it working.
Otherwise for now apple containers as amazing as it is already, cannot be used with a zscaler corporate proxy.
@goafabric remindme
dwsteele commentedon Jul 14, 2026
Same issue with NordVPN.
smparekh commentedon Jul 22, 2026
Same issue with tailscale, although it is intermittent
drewbroadley commentedon Jul 28, 2026
I've got the same issue in #1986 where I've reported a DHCP ip lease change causing the same issues as above.
It's a blocker to using Apple Containers.
acdha commentedon Jul 31, 2026
At least part of the problem is that the container system always uses the default hardware interface for the
ipv4Gatewayandipv6Gateway, which fails when you have a VPN which prevents split-tunneling by restricting all traffic other than the VPN itself. There doesn't seem to be a documented way to change that gateway.pjezek commentedon Aug 21, 2026
It might not help every one, but in my case ipv4 is also affected by VPN (Forticlient with full tunnel). Workaround was to switch to ipv6:
ThomasSchoeller commentedon Aug 28, 2026
Hey @acdha
Have you tried my workaround in #1307 (comment)
this works perfectly for me. only after reboot or updates i have to redo adding the fw rule as it is not permanent (haven't looked in how to do it).
Cheers
Thomas
hfoffani commentedon Oct 17, 2026
Thanks @ThomasSchoeller It works for me.
You run it like this:
container run --rm --dns 10.64.0.1 docker.io/library/alpine nslookup api.github.comAdd more DNS if you don't always exit through the VPN
container run --rm --dns 10.64.0.1 --dns 1.1.1.1 docker.io/library/alpine nslookup api.github.comalthough it adds a few rounds of failures.
Here's script I've added to my
~/.local/binpmarques commentedon Oct 29, 2026
One of the laptops I use has a GlobalProtect VPN and although I came across a few suggestions and scripts in this repo, nothing seemed to work. After some back and forth with one LLM, I managed to get it working.
The is the script the LLM came up with
~/.bin/container-vpn
To run a container with external / internaet networking access, just run the script before starting any container. Hope this helps someone else.
container system startcontainer-vpn upTest result