Routing traffic on specific interface over OpenVPN with FreeBSD

I'd like to setup OpenVPN between a FreeBSD client and an (Arch) Linux server such that

  • All Internet-bound traffic explicitly sent from FreeBSD over the tunnel device is routed through OpenVPN


  • The default gateway/route on the FreeBSD side remains untouched.

In other words, if I do something like curl --interface tun0 on FreeBSD, I want the request to to be routed through OpenVPN, but if I just do curl I want that to ignore the VPN tunnel.

Thus far, I've successfully established a basic connection between the two machines, and both sides can see each other.

I can go through the tunnel to fetch data from the Web server running on the remote machine:

$ curl <!DOCTYPE html> ... 

For completeness, I also tested what happens if I explicitly specify the interface, and it works:

$ curl --interface <!DOCTYPE html> ...  $ curl --interface tun0 <!DOCTYPE html> ... 

However, using the interface for any other host/IP fails:

$ curl --interface tun0 *hang*  $ curl --interface tun0  # (the IP I got for *hang* 

OpenVPN (on the FreeBSD side) doesn't print any RwRw when I do this, so I assume (and I think correctly) that FreeBSD's network stack is insufficiently configured to know how to route arbitrary traffic on tun0 through OpenVPN properly.

All the examples I've found to configure this kind of routing are Linux-specific; what do I do for FreeBSD?

I can make arbitrary changes on both the FreeBSD and Linux sides, if that makes configuration easier.

I initially intended to post this to, but the freebsd and openvpn tags aren't defined there so I'm posting here instead.


Category: freebsd Time: 2016-07-29 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.227 (s). 12 q(s)