Hjälp med att få mitt Script till OVPN/Tomato att funka som det ska.

Permalänk
Medlem

Hjälp med att få mitt Script till OVPN/Tomato att funka som det ska.

Jag kan säga att jag rätt ny men efter att ha suttit och googlat och testat i ett par dagar nu så har jag fått det att funka delvis.
Men försöker jag mig på fler saker från här så börjar nått att funka medan det andra slutar att funka.

Det jag är ute efter med detta script som ligger i Firewall är:
Bara NASen skall gå över vpn. 192.168.1.102
Jag vill kunna specificera vilka portar jag vill lyfta ut från vpn, dessa skall då även funka att köra från remote.
Som det är nu så funkar allt utom att jag just inte kan nå saker från remote tex. port 8083.

Plexen funkar som den skall, även om jag har ett VPN-ip på resten av sakerna så skickar inte NAS detta ip till Plex-servern så jag tappar remote-access till den.
Är det någon som kan se vad jag har gjort för galet?

# This script configures "selective" VPN routing. Normally Tomato will route ALL traffic out
# the OpenVPN tunnel. These changes to iptables allow some outbound traffic to use the VPN, and some
# traffic to bypass the VPN and use the regular Internet instead.
#
# 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
#

#
# First it is necessary to 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 and 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"
#
# NOTE: Here I assume the OpenVPN tunnel is named "tun11".
#
#
ip route show table main | grep -Ev ^default | grep -Ev tun11 \
| while read ROUTE ; do
ip route add table 100 $ROUTE
done
ip route add default table 100 via $(nvram get wan_gateway)
ip rule add fwmark 1 table 100
ip route flush cache

#
# Define the routing policies for the traffic. The rules will be applied in the order that they
# are listed. In the end, packets with MARK set to "0" will pass through the VPN. If MARK is set
# to "1" it will bypass the VPN.
#
# EXAMPLES:
#
# All LAN traffic will bypass the VPN (Useful to put this rule first, so all traffic bypasses the VPN and you can configure exceptions afterwards)
# iptables -t mangle -A PREROUTING -i br0 -j MARK --set-mark 1
# Ports 80 and 443 will bypass the VPN
# iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport --dport 80,443 -j MARK --set-mark 1
# All traffic from a particular computer on the LAN will use the VPN
# iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range 192.168.1.2 -j MARK --set-mark 0
# All traffic to a specific Internet IP address will use the VPN
# iptables -t mangle -A PREROUTING -i br0 -m iprange --dst-range 216.146.38.70 -j MARK --set-mark 0
# All UDP and ICMP traffic will bypass the VPN
# iptables -t mangle -A PREROUTING -i br0 -p udp -j MARK --set-mark 1
# iptables -t mangle -A PREROUTING -i br0 -p icmp -j MARK --set-mark 1

# By default all traffic bypasses the VPN
iptables -t mangle -A PREROUTING -i br0 -j MARK --set-mark 1

# Route all 192.168.1.102 traffic over VPN except specific ports
iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport ! --dport 53,5000,5001,8083 -m iprange --src-range 192.168.1.102 -j MARK --set-mark 0

# All traffic from a particular computer on the LAN will use the VPN Test PC
iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range 192.168.1.20 -j MARK --set-mark 0

# Enables VPN for one specific machine, the plex server
#iptables -t mangle -A PREROUTING -i br0 -s 192.168.1.102 -j MARK --set-mark 0

#Allows plex server to register/communicate with plex.tv, all protocols, bypassing the VPN.
iptables -t mangle -A PREROUTING -i br0 -s 192.168.1.102 -d plex.tv -j MARK --set-mark 1

#Allows plex server to send packets from wooster from port 32400 to any address
iptables -t mangle -A PREROUTING -i br0 -s 192.168.1.102 -p tcp -m multiport --sport 32400,32443 -j MARK --set-mark 1

#Allow all traffic to plex ip addresses to bypass VPN (note potentially bypasses for other AWS sites)
iptables -t mangle -A PREROUTING -i br0 -d 184.72.0.0/16 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -i br0 -d 50.18.0.0/16 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -i br0 -d 184.169.0.0/16 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -i br0 -d 54.241.0.0/16 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -i br0 -d 54.176.0.0/16 -j MARK --set-mark 1

#Allow ports used by plex to bypass VPN
iptables -t mangle -A OUTPUT -p udp -m multiport --dport 17827,32400,32443,32410,32412,32413,32414,32469 -j MARK --set-mark 1

Skulle inte förvåna mig om det är dubbla budskap i denna kod men hoppas att någon kanske vet vad som är fel?
Som sagt nasen går över vpn, plex skickar inte vpn-ip till plex.tv (som det ska vara) men jag kommer inte åt port 5001 eller 8083 från remote.

Permalänk
Medlem

Eller är det kanske bättre att köpa sig ett publict-ip för att kunna komma åt nasen från remote?
Jag behöver verkligen inte köra den via vpn så skulle vara så mycket lättare och smidigare om man kunde lyfta ut dessa portar från tunneln.