Redirecting the default gateway

A very common use of a VPN is to route all the traffic over a secure tunnel. This allows one to safely access a network, or even the Internet itself, from within a hostile environment (for example, a poorly protected Internet cafe).

Redirecting the default gateway is achieved by adding the line push “redirect-gateway [def1 local bypass-dhcp bypass-dns]” to the server configuration file.

The parameters to redirect-gateway listed previously are optional, but they can play a very important role:

  • No parameters added: In this case, OpenVPN will replace the existing default gateway (0.0.0.0/0) with the address of the OpenVPN server itself. An extra route to the OpenVPN server itself is also added so that the OpenVPN traffic ...

Get Mastering OpenVPN now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.