They are not blocking UDP protocol totally but only SIP/UDP protocol SIP/TCP protocol is open and accessible on my ISP.
If you are using a SIP client to connect to a specific server, try a VPN policy rule for the IP address of the SIP server.
Make sure you use UDP - OpenVPN's TCP support can be problematic with SIP (or that's at least what an engineer recently told me at a customer meeting - I was a bit skeptical but didn't argue with him...)
Hello I've tried that and it partially working so is there anyway I can also add port with my sip server address? Like 114.x.x.x:5060
#!/bin/sh
sleep 2
ip route flush table 10
ip route del default table 10
ip rule del fwmark 10 table 10
ip route flush table 12
ip route del default table 12
ip rule del fwmark 12 table 12
ip route flush cache
iptables -t mangle -F PREROUTING
tun_if="tun11"
tun_ip=$(ifconfig $tun_if | grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}')
ip route add default via $tun_ip dev $tun_if table 10
ip rule add fwmark 10 table 10
ip route add default via $(nvram get wan_gateway) dev eth0 table 12
ip rule add fwmark 12 table 12
echo 0 > /proc/sys/net/ipv4/conf/$tun_if/rp_filter
iptables -t mangle -A PREROUTING -i br0 -j MARK --set-mark 12
iptables -t mangle -A PREROUTING -i br0 -p udp --dport 5060 -j MARK --set-mark 10
exit
So if anyone of you want to do the same thing this is what I end up doing:
Setup OpenVPN on your router and make sure it's working, after that make a "openvpn-event" script to handle all the routing, make sure you add "route-nopull" in your OpenVPN "Custom Configuration" box.
( I am not the creator of this script I just found it on the Forum here and just edit it a little bit for my issue )
VPN_ID=1 # VPN Client #; Change to the appropriate VPN Client to be used (1-5, if available)
DPORT=5060 # Port number (or CSV list of ports) to be routed via VPN Client #
TAG_MARK=0x${VPN_ID}000
PRIO=999${VPN_ID}
ip rule del prio $PRIO 2> /dev/null
ip rule add from 0/0 fwmark $TAG_MARK/$TAG_MARK table 11$VPN_ID prio $PRIO
ip route flush cache
iptables -t mangle -D PREROUTING -i br0 -p udp -m multiport --dport $DPORT -j MARK --set-mark $TAG_MARK/$TAG_MARK 2> /dev/null
iptables -t mangle -A PREROUTING -i br0 -p udp -m multiport --dport $DPORT -j MARK --set-mark $TAG_MARK/$TAG_MARK
As previously posted; the script template you have used is flawed and should not be used see https://www.snbforums.com/threads/a...through-vpn-settings.41047/page-2#post-348358
For Selective Port routing do not add 'route-nopull' to the OpenVPN Client 'Custom Configuration' but simply modify
/jffs/scripts/nat-start
e.g.
Code:VPN_ID=1 # VPN Client #; Change to the appropriate VPN Client to be used (1-5, if available) DPORT=5090 # Port number (or CSV list of ports) to be routed via VPN Client # TAG_MARK=0x${VPN_ID}000 PRIO=999${VPN_ID} ip rule del prio $PRIO 2> /dev/null ip rule add from 0/0 fwmark $TAG_MARK/$TAG_MARK table 11$VPN_ID prio $PRIO ip route flush cache iptables -t mangle -D PREROUTING -i br0 -p tcp -m multiport --dport $DPORT -j MARK --set-mark $TAG_MARK/$TAG_MARK 2> /dev/null iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport --dport $DPORT -j MARK --set-mark $TAG_MARK/$TAG_MARK
NOTE: For advanced Selective routing, rather than have explicit PREROUTING rules for IPs/Ports/MAC addresses, they can be defined in custom IPSETs, although you do lose the ability to visually quickly identify/track the number of successful matching 'hits'.
Thanks for telling me about my flawed script but unfortunately the new way you told me is way above my current knowledge so can you please tell me in steps what I need to do here thanks.
I just want to route the traffic on UDP port 5060 via VPN and EVERYTHING ELSE on my network via WAN , I do want to use my ISP's public IP and DNS and also I want to access my router via WAN.
The script I posted above allowed me to do all of this but how can I change it to the new way you told me.
Thanks for replying.
I'm just confused that do I have to make a new nat-start script with your script contents and remove the openvpn-event script and route-nopull from openvpn configuration ?
Or just remove route-nopull from configuration box and use both scripts?
ip rule add from 0/0 fwmark 0x1000/0x1000 table 111 prio 9991
iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport --dport 5060 -j MARK --set-mark 0x1000/0x1000
#!/bin/sh
ip rule add from 0/0 fwmark 0x1000/0x1000 table 111 prio 9991
iptables -t mangle -A PREROUTING -i br0 -p udp -m multiport --dport 5060 -j MARK --set-mark 0x1000/0x1000
Oct 15 04:53:28 rc_service: httpd 480:notify_rc stop_vpnclient1
Oct 15 04:53:29 openvpn[22585]: event_wait : Interrupted system call (code=4)
Oct 15 04:53:29 openvpn[22585]: vpnrouting.sh tun11 1500 1557 10.211.2.5 10.211.2.6 init
Oct 15 04:53:29 openvpn-routing: Configuring policy rules for client 1
Oct 15 04:53:29 openvpn[22585]: /usr/sbin/ip route del 222.97.145.240/32
Oct 15 04:53:29 openvpn[22585]: /usr/sbin/ip route del 0.0.0.0/1
Oct 15 04:53:29 openvpn[22585]: ERROR: Linux route delete command failed: external program exited with error status: 2
Oct 15 04:53:29 openvpn[22585]: /usr/sbin/ip route del 128.0.0.0/1
Oct 15 04:53:29 openvpn[22585]: ERROR: Linux route delete command failed: external program exited with error status: 2
Oct 15 04:53:29 openvpn[22585]: Closing TUN/TAP interface
Oct 15 04:53:29 openvpn[22585]: /usr/sbin/ip addr del dev tun11 local 10.211.2.5 peer 10.211.2.6
Oct 15 04:53:29 openvpn[22585]: SIGTERM[hard,] received, process exiting
No, its not a permissions problem....vpnrouting.sh cleans up and deletes the added routes.....then openvpn tries to delete the same routes and complains when it can't find them. Just ignore the error.By the way when I manually stop the VPN I see two errors in the web log and according to my search it's due to some permission issues so anyway I can fix them? I dont think I am getting any issues due to that but I just dont like errors hehe
Also just for my own understanding if I call this script with "openvpn-event" instead of "nat-start" is there any issues in doing that?
Because I assume "nat-start" only run once on reboot so what if the VPN get disconnected or I disconnect it myself will the "nat-start" script runs again like "openvpn-event" or it's not needed?
NOTE: Ideally you should create a separate script such as 'VPNPortRouting.sh' (which is then called from both nat-start and vpnclient1-route-up) to ensure that your Selective Port routing tagging will hopefully survive any unexpected event.
#!/bin/sh
sh /jffs/scripts/VPNPortRouting.sh
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!