Skip to content

Commit c8ba567

Browse files
committed
only block external dns when default route is pushed
1 parent 21ae2fc commit c8ba567

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

bin/ovpn_genconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ user nobody
330330
group nogroup
331331
EOF
332332

333-
#This was in the heredoc, we use the new function instead
334-
process_push_config "block-outside-dns"
333+
# only block outside dns when we take the default route
334+
[ "$OVPN_DEFROUTE" == "1" ] && process_push_config "block-outside-dns"
335335

336336
[ -n "$OVPN_TLS_CIPHER" ] && echo "tls-cipher $OVPN_TLS_CIPHER" >> "$conf"
337337
[ -n "$OVPN_CIPHER" ] && echo "cipher $OVPN_CIPHER" >> "$conf"

test/tests/conf_options/container.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,32 @@ then
199199
else
200200
abort "==> Config match not found: $CONFIG_REQUIRED_TCP_REMOTE_2 != $CONFIG_MATCH_TCP_REMOTE_2"
201201
fi
202+
203+
# Test non-defroute config
204+
205+
SERV_IP=$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)
206+
ovpn_genconfig -d -u udp://$SERV_IP -r "172.33.33.0/24" -r "172.34.34.0/24"
207+
# nopass is insecure
208+
EASYRSA_BATCH=1 EASYRSA_REQ_CN="Travis-CI Test CA" ovpn_initpki nopass
209+
easyrsa build-client-full client-fallback nopass
210+
ovpn_getclient client-fallback | tee /etc/openvpn/config-fallback.ovpn
211+
212+
CONFIG_REQUIRED_BLOCK_OUTSIDE_DNS=""
213+
CONFIG_MATCH_BLOCK_OUTSIDE_DNS=$(busybox grep 'push block-outside-dns' /etc/openvpn/openvpn.conf)
214+
215+
if [[ $CONFIG_MATCH_BLOCK_OUTSIDE_DNS =~ $CONFIG_REQUIRED_BLOCK_OUTSIDE_DNS ]]
216+
then
217+
echo "==> Config match found: $CONFIG_REQUIRED_BLOCK_OUTSIDE_DNS == $CONFIG_MATCH_BLOCK_OUTSIDE_DNS"
218+
else
219+
abort "==> Config match not found: $CONFIG_REQUIRED_BLOCK_OUTSIDE_DNS != $CONFIG_MATCH_BLOCK_OUTSIDE_DNS"
220+
fi
221+
222+
CONFIG_REQUIRED_REDIRECT_GATEWAY=""
223+
CONFIG_MATCH_REDIRECT_GATEWAY=$(busybox grep "redirect-gateway def1" /etc/openvpn/config-fallback.ovpn)
224+
225+
if [[ $CONFIG_MATCH_REDIRECT_GATEWAY =~ $CONFIG_REQUIRED_REDIRECT_GATEWAY ]]
226+
then
227+
echo "==> Config match found: $CONFIG_REQUIRED_REDIRECT_GATEWAY == $CONFIG_MATCH_REDIRECT_GATEWAY"
228+
else
229+
abort "==> Config match not found: $CONFIG_REQUIRED_REDIRECT_GATEWAY != $CONFIG_MATCH_REDIRECT_GATEWAY"
230+
fi

0 commit comments

Comments
 (0)