PDA

Bekijk de volledige versie : HowTo: Routing all client traffic through the VPN



Tamadite
16-11-2008, 19:41
FOREWORD
For a couple of days ago I tried posting this HowTo under “WL-500g/WL-500gx Tutorials” where other tutorials are. Either forum’s administrators have not had the time to publish it or administrator’s rules have restrained this HowTo from being published. In any case, the result is the distortion of the intended structure of this forum leading it to find HowTos where there should not be.

SOURCE
-. “HowTo install OpenVPN server (http://wl500g.info/showthread.php?t=5312)" tutorial in this forum

ASUMPTIONS
-. Have read or installed OpenVPN server following the above source

HOW-TO 1: Automatically without user intervention
Create new server.conf and client.ovpn files as follows:

server.conf file

dev tun0
ifconfig 10.8.0.1 10.8.0.2
secret static.key
# Routing all client traffic (including web-traffic) through the VPN
push "redirect-gateway def1"
push "dhcp-option DNS 10.8.0.1"


client.ovpn file


remote myremote.mydomain
float
dev tun0
ifconfig 10.8.0.2 10.8.0.1
secret static.key
keepalive 10 60
redirect-gateway def1
route-method exe
route-delay 2
dhcp-option DNS 10.8.0.1


where myremote.mydomain is the WAN ip address or host name of your Router.

NOTES:
i) With Microsoft Vista, client.ovpn may be started as administrator (run OpenVPN GUI as administrator).


HOW-TO 2: By manipulating routing table on client
After following “HowTo install OpenVPN server (http://wl500g.info/showthread.php?t=5312)” tutorial one should gather the below parameters:

1) Internet IP address of the VPN Server. I will call it VpnSrvIp
2) Default gateway on VPN Client. I will call it GtwClntIp (see notes)

I assume far-end IP address of the VPN link is 10.8.0.1 as it is on the above mentioned tutorial.

Open a DOS prompt window and write the following:


route add VpnSrvIp MASK 255.255.255.255 GtwClnIp METRIC 1
route add 0.0.0.0 MASK 0.0.0.0 10.8.0.1 METRIC 1


It may happen that after a while Windows restructures the routing table giving priority to the Internet gateway. If so, run:



route change 0.0.0.0 MASK 0.0.0.0 10.8.0.1 METRIC 1



NOTES
i) If no DNS resolution edit file /etc/dnsmasq.conf and add line

interface=tun0and then restart the dnsmasq process (kill & invoke)
ii) One way to identify the default gateway (GtwClntIp) on a Windows XP machine is by running “route print” on a DOS prompt window. This easy the identification in case more than one NIC is present.
iii) More information: http://www.openvpn.net/index.php/documentation/howto.html

ffrr
08-05-2015, 16:31
I have followed the tour, Here is my "/etc/dnsmasq.conf"


user=nobody
resolv-file=/tmp/resolv.conf
no-poll
interface=br0
no-negcache
cache-size=512
dhcp-leasefile=/tmp/dnsmasq.log
dhcp-range=lan,192.168.1.101,192.168.1.254,86400
read-ethers
dhcp-option=lan,252,"\n"
dhcp-authoritative
interface=tun0

I kill the dnsmasq and restart it

killall dnsmasq && sleep 3 && dnsmasq

then restart the openvpn again, and connect the server from my pc
but I still have DNS problem
Here is my post-fireware below


#!/bin/sh
#OpenVPN access from WAN
iptables -D INPUT -j DROP
iptables -I INPUT -p udp --dport 1194 -j ACCEPT
iptables -t nat -I PREROUTING -i eth1 -p udp --dport 1194 -j DNAT --to-destination $4:1194
iptables -A INPUT -j DROP

iptables -I INPUT -i tun0 -j ACCEPT
iptables -I FORWARD -i tun0 -j ACCEPT
iptables -I FORWARD -o tun0 -j ACCEPT
iptables -I OUTPUT -o tun0 -j ACCEPT


I can't find where could be wrong, could someone please help, thank you.