Hi,
I'm new to writing here, but I have been doing quit some reading
I have a problem that I unfortunately can not figure out myself.
I have the following setup:
192.168.2.0/24 subnet on a Asus AC-68U with a few computers, media-players (kodi), and a home-server/storage (ubuntu server).
On the Homeserver I have Plexe Media Server running, a bittorrent client, Sabnzd, Couchpotato and SickRage.
I have setup a Private Internet Access OpenVPN on the AC-68U. That works. I can route all traffic through the VPN, but off course that's not what I want. I would like to route the download clients and both the Raspberry's through the VPN and all other stuff should use the normal route.
After sifting through this great 19 pages topic: http://www.snbforums.com/threads/selective-routing-with-asuswrt-merlin.9311/ I have read so much information that It got me even more confused. The problems is that my iptables knowledge is very limited, so I am in need of some help
The network is setup like this:
Asus AC-68U firmware 378.53 192.168.2.1
KodiWK (Raspberry PI running openelec) 192.168.2.15
KodiSK (Raspberry PI running openelec) 192.168.2.16
Ubuntu Homeserver/Storage 192.168.2.5
The computer I am writing this on: 192.168.2.230
I have modified the script from Wysie that I found at: https://gist.github.com/Wysie/7487571
To this:
And put it in /jffs/scripts/openvpn-event
After rebooting the router, traffic from both the KodiWK and KodiSK as well as the Homeserver are routed through the VPN and the rest of my network attached devices use the normal internet route.
The problem is that Plex won't connect from the internet. The portforward TCP 32400 to 192.168.2.5 is set, without the VPN running it works, but As soon as the VPN is running Plex simply won;t connect.
As you can see in the image below, my normal public IP address does not show up in Plex, but in stead it shows my PIA OpenVPN IP. This should be my public ISP IP address.
Does anybody see what I am doing wrong. Please do consider that I am a iptables noob
Cheers,
Michel
I'm new to writing here, but I have been doing quit some reading
I have a problem that I unfortunately can not figure out myself.
I have the following setup:
192.168.2.0/24 subnet on a Asus AC-68U with a few computers, media-players (kodi), and a home-server/storage (ubuntu server).
On the Homeserver I have Plexe Media Server running, a bittorrent client, Sabnzd, Couchpotato and SickRage.
I have setup a Private Internet Access OpenVPN on the AC-68U. That works. I can route all traffic through the VPN, but off course that's not what I want. I would like to route the download clients and both the Raspberry's through the VPN and all other stuff should use the normal route.
After sifting through this great 19 pages topic: http://www.snbforums.com/threads/selective-routing-with-asuswrt-merlin.9311/ I have read so much information that It got me even more confused. The problems is that my iptables knowledge is very limited, so I am in need of some help
The network is setup like this:
Asus AC-68U firmware 378.53 192.168.2.1
KodiWK (Raspberry PI running openelec) 192.168.2.15
KodiSK (Raspberry PI running openelec) 192.168.2.16
Ubuntu Homeserver/Storage 192.168.2.5
The computer I am writing this on: 192.168.2.230
I have modified the script from Wysie that I found at: https://gist.github.com/Wysie/7487571
To this:
Code:
#!/bin/sh
# This script will route traffic from home network through VPN selectively.
# Based off the discussion at http://www.snbforums.com/threads/selective-routing-with-asuswrt-merlin.9311/page-8
# The setup is a Asus AC68U running Merlin 387.53. On the Asus I have a Private Internet Access OpenVPN
# installed and running. Furthermore 2 Paspberry PI's (KodiWK and KodiSK) and a HomeServer with a torrent client
# running a web interface as well as some other download clients.
# The aim is to have all traffic from the Kodi Raspberry's to go through the VPN, the HomeServer using the VPN,
# and to have all traffic from all other devices bypassing the VPN, There are however some exceptions. Since Plex
# uses port 32400, the Homeserver has to bypass the VPN when using that port. In addition, port 9091 has to
# bypass the VPN as well in order to access the HomeServer torrent client as well as some other download clients.
logger -t "($(basename $0))" $$ PIA-VPN Selective Customization Starting... " $0${*:+ $*}."
HomeServer="192.168.2.5"
KodiWK="192.168.2.15"
KodiSK="192.168.2.16"
# SHELL COMMANDS FOR MAINTENANCE.
# DO NOT UNCOMMENT, THESE ARE INTENDED TO BE USED IN A SHELL COMMAND LINE
#
# List Contents by line number
# iptables -L PREROUTING -t mangle -n --line-numbers
#
# Delete rules from mangle by line number
# iptables -D PREROUTING type-line-number-here -t mangle
#
# To list the current rules on the router, issue the command:
# iptables -t mangle -L PREROUTING
#
# Flush/reset all the rules to default by issuing the command:
# iptables -t mangle -F PREROUTING
#
# Disable Reverse Path Filtering on all current and future network interfaces:
#
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do
echo 0 > $i
done
#
# Delete table 100 and flush any existing rules if they exist.
#
ip route flush table 100
ip route del default table 100
ip rule del fwmark 1 table 100
ip route flush cache
iptables -t mangle -F PREROUTING
#
# Copy all non-default and non-VPN related routes from the main table into table 100.
# Then configure table 100 to route all traffic out the WAN gateway and assign it mark "1"
#
tun_if="tun11"
ip route show table main | grep -Ev ^default | grep -Ev $tun_if \
| while read ROUTE ; do
ip route add table 100 $ROUTE
logger -t "($(basename $0))" $$ PIA-VPN Table 100 added entry: $ROUTE
done
ip route add default table 100 via $(nvram get wan0_gateway)
ip rule add fwmark 1 table 100
ip route flush cache
# By default all traffic bypasses the VPN
iptables -t mangle -A PREROUTING -i br0 -j MARK --set-mark 1
logger -t "($(basename $0))" $$ Selective customisation for: "$"KodiWK $KodiWK
# By default KodiWK uses the VPN
iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range $KodiWK -j MARK --set-mark 0
logger -t "($(basename $0))" $$ Selective customisation for: "$"KodiWK $KodiSK
# By default KodiSK uses the VPN
iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range $KodiSK -j MARK --set-mark 0
logger -t "($(basename $0))" $$ Selective customisation for: "$"HomeServer $HomeServer
# By default HomeServer uses the VPN, and FORCES the use of the VPN tunnel
iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range $HomeServer -j MARK --set-mark 0
# except for some ports that should bypass the VPN:
# Transmission ------ TCP port 9091
# SickRage ---------- TCP port 8081
# SaBnzbd ----------- TCP port 8080
# CouchPotato ------- TCP port 5050
# Plex Media server - TCP port 3005,8324,32400,32469
# Plex Media Server - UDP port 1900,5353,32410,32412,32413,32414
iptables -I FORWARD -i br0 -s $HomeServer -o eth0 -j DROP
iptables -I FORWARD -i br0 -s $HomeServer -o eth0 -p tcp -m multiport --port 9091 -j ACCEPT
iptables -I FORWARD -i br0 -s $HomeServer -o eth0 -p tcp -m multiport --port 8091 -j ACCEPT
iptables -I FORWARD -i br0 -s $HomeServer -o eth0 -p tcp -m multiport --port 8080 -j ACCEPT
iptables -I FORWARD -i br0 -s $HomeServer -o eth0 -p tcp -m multiport --port 5050 -j ACCEPT
iptables -I FORWARD -i br0 -s $HomeServer -o eth0 -p tcp -m multiport --port 3005,8324,32400,32469 -j ACCEPT
iptables -I FORWARD -i br0 -s $HomeServer -o eth0 -p udp -m multiport --port 1900,5353,32410,32412,32413,32414 -j ACCEPT
# TCP and UDP Ports that will bypass the the VPN
iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport --port 22,9091,8091,8080,5050,3005,8324,32400,32469 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -i br0 -p udp -m multiport --port 1900,5353,32410,32412,32413,32414 -j MARK --set-mark 1
logger -t "($(basename $0))" $$ PIA-VPN Selective Customization completed.
And put it in /jffs/scripts/openvpn-event
After rebooting the router, traffic from both the KodiWK and KodiSK as well as the Homeserver are routed through the VPN and the rest of my network attached devices use the normal internet route.
The problem is that Plex won't connect from the internet. The portforward TCP 32400 to 192.168.2.5 is set, without the VPN running it works, but As soon as the VPN is running Plex simply won;t connect.
As you can see in the image below, my normal public IP address does not show up in Plex, but in stead it shows my PIA OpenVPN IP. This should be my public ISP IP address.
Does anybody see what I am doing wrong. Please do consider that I am a iptables noob
Cheers,
Michel