Even if I have a VPN configured to auto-connect in Linux, there is a brief moment where it is connected to the Internet, but not utilizing the VPN. Doesn't this provide a vulnerability? How can I protect myself?

  • 2
    What vulnerability ? and protect yourself from what exactly ? – amrx Aug 19 '16 at 10:32
  • 4
    Configure iptables rules that only allow traffic through the VPN tunnel interface. – multithr3at3d Aug 19 '16 at 21:48

Depending on your vpn software that's normal behaviour.

Configure a firewall that only allows connections to your vpn provider over the public network and force everything else to go over the vpn.

For instance:

iptables -A OUTPUT -d <VPN_SERVER> -j ACCEPT
iptables -A OUTPUT -s <VPN_ADDRESS> -d <VPN_NET> -j ACCEPT

Where VPN_SERVER is your VPN provider's public address, VPN_ADDRESS is your address on the tunnel interface and VPN_NET is the VPN network in CIDR notation.

You can also do this with routes instead. When you setup your internet interface, instead of loading a default gateway you load a static route to your vpn server. No host other than your local neighbors and your vpn server will be reachable until you get a default route from the vpn provider (through the vpn).

Both approaches get the job done, but the firewall approach includes an insurance policy for free.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.