Hello,
I launched a test server with Tor and OpenVPN and configured OpenVPN to use Tor. The Tor configuration is as the following:
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsOnResolve 1
DNSPort 10.8.0.1:53530
TransPort 10.8.0.1:9040
And Tor service is running:
# netstat -tulpen | grep tor
tcp 0 0 10.8.0.1:9040 0.0.0.0:* LISTEN 0 17809 982/tor
tcp 0 0 127.0.0.1:9050 0.0.0.0:* LISTEN 0 17807 982/tor
udp 0 0 10.8.0.1:53530 0.0.0.0:* 0 17808 982/tor
I used the following iptables rules:
# export OVPN=tun0
# iptables -A INPUT -i $OVPN -s 10.8.0.0/24 -m state --state NEW -j ACCEPT
# iptables -t nat -A PREROUTING -i $OVPN -p udp --dport 53 -s 10.8.0.0/24 -j DNAT --to-destination 10.8.0.1:53530
# iptables -t nat -A PREROUTING -i $OVPN -p tcp -s 10.8.0.0/24 -j DNAT --to-destination 10.8.0.1:9040
# iptables -t nat -A PREROUTING -i $OVPN -p udp -s 10.8.0.0/24 -j DNAT --to-destination 10.8.0.1:9040
It works. When a client connects to my server via OpenVPN client, then his\her connection tunneled via Tor.
On the real server, I’m using Tor as a proxy server and its Tor configuration is as the following:
SocksPort 172.20.2.54:9050
RunAsDaemon 1
DataDirectory /var/lib/tor
As you see, Tor is listening to 172.20.2.54
IP not 127.0.0.1
IP. Could this cause a problem? I mean, Tor must be listening to 127.0.0.1
for OpenVPN to use it?
Thank you.