Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional : Block output if vpn is down #5

Open
slobberbone opened this issue Jan 20, 2018 · 0 comments
Open

Optional : Block output if vpn is down #5

slobberbone opened this issue Jan 20, 2018 · 0 comments

Comments

@slobberbone
Copy link

Hi,
Thank for your great work about this container !
Is it possible to add the possibility to force to block all traffic if the vpn goes doown ?

From my point of view : add a environment for enable this feature and another one to set the vpn ip (additionnal of OPENPVN_CONFIG which look like cn.norvpn.com.tcp.443, another one like OPENVPN_SERVER_IP=cn.nordvpn.com for exemple,
Once done, you need install iptables (and dnsutils to check)

and apply these rules :

iptables -A OUTPUT -j DROP
iptables -A INPUT -i tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -j ACCEPT
iptables -A INPUT -s $OPENVPN_SERVER_IP -j ACCEPT
iptables -A OUTPUT -o tun0 -j ACCEPT
iptables -A OUTPUT -d $OPENVPN_SERVER_IP -j ACCEPT

Then to check if it works :

a loop :
#!/bin/bash
while true
do
dig @ns1.google.com -t txt o-o.myaddr.l.google.com +short
done

and run killall openvpn several time you will see, you never have another public ip than the vpn one ...

I think it's better to add this in your project than fork it ... what do you think about that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant