1OpenVPN fwmark Routing 2Sean Reifschneider, <jafo@tummy.com> 3Thursday November 27, 2003 4========================== 5 6These scripts can be used with OpenVPN up and down scripts to set up 7routing on a Linux system such that the VPN traffic is sent via normal 8network connectivity, but other traffic to that network runs over the VPN. 9The idea is to allow encryption of data to the network the remote host is 10on, without interfering with the VPN traffic. You can't simply add a route 11to the remote network, becaues that will cause the VPN traffic to also try 12to run over the VPN, and breaks the VPN. 13 14These scripts use the Linux "fwmark" iptables rules to specify routing 15based not only on IP address, but also by port and protocol. This allows 16you to effectively say "if the packet is to this IP address on this port 17using this protocol, then use the normal default gateway, otherwise use the 18VPN gateway. 19 20This is set up on the client VPN system, not the VPN server. These scripts 21also set up all ICMP echo-responses to run across the VPN. You can 22comment the lines in the scripts to disable this, but I find this useful 23at coffee shops which have networks that block ICMP. 24 25To configure this, you need to set up these scripts as your up and down 26scripts in the config file. You will need to set these values in the 27config file: 28 29 up /etc/openvpn/fwmarkroute.up 30 down /etc/openvpn/fwmarkroute.down 31 up-restart 32 up-delay 33 34 setenv remote_netmask_bits 24 35 36Note: For this to work, you can't set the "user" or "group" config options, 37because then the scripts will not run as root. 38 39The last setting allows you to control the size of the network the remote 40system is on. The remote end has to be set up to route, probably with 41masquerading or NAT. The network this netmask relates to is calculated 42using the value of "remote" in the conf file. 43 44Sean 45