From 4a74d3103138c8aad06f52dc392d0b1d7db17f7d Mon Sep 17 00:00:00 2001 From: binhex Date: Fri, 13 Mar 2020 13:54:09 +0000 Subject: [PATCH] better detection of docker bridge interface --- run/root/iptable.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/run/root/iptable.sh b/run/root/iptable.sh index 7ea9a47..6557236 100644 --- a/run/root/iptable.sh +++ b/run/root/iptable.sh @@ -5,8 +5,10 @@ if [[ "${VPN_PROTOCOL}" == "tcp-client" ]]; then export VPN_PROTOCOL="tcp" fi -# identify docker bridge interface name (probably eth0) -docker_interface=$(netstat -ie | grep -vE "lo|tun|tap" | sed -n '1!p' | grep -P -o -m 1 '^[^:]+') +# identify docker bridge interface name by looking at routing to +# vpn provider remote endpoint (first ip address from name +# lookup in /root/start.sh) +docker_interface=$(ip route show to match "${remote_dns_answer_first}" | grep -P -o -m 1 '[a-zA-Z0-9]+\s?+$' | tr -d '[:space:]') if [[ "${DEBUG}" == "true" ]]; then echo "[debug] Docker interface defined as ${docker_interface}" fi