For those websites you want to route to the WAN, do you need to specify one LAN client or all LAN Clients?looks like I need to create my own IPSET list.
A few LAN clients (subnet 192.168.1.192/28)For those websites you want to route to the WAN, do you need to specify one LAN client or all LAN Clients?
I will look into what is required to modify an existing script to allow the user to specify exception rules for LAN clients. The revised script will need to give you the ability to specify a LAN IP address as the source. How do you want to create the destination IPSET list? You can do it using the dnsmasq method, ASN method or the manual method. You can read the methods on the GitHub page. Knowing what method you want to use will allow me to focus on the modifications that fit the method.A few LAN clients (subnet 192.168.1.192/28)
Envoyé de mon BLA-L29 en utilisant Tapatalk
I think it will be manual because will be various ASNsI will look into what is required to modify an existing script to allow the user to specify exception rules for LAN clients. The revised script will need to give you the ability to specify a LAN IP address as the source. How do you want to create the destination IPSET list? You can do it using the dnsmasq method, ASN method or the manual method. You can read the methods on the GitHub page. Knowing what method you want to use will allow me to focus on the modifications that fit the method.
I think it will be manual because will be various ASNs
Envoyé de mon BLA-L29 en utilisant Tapatalk
You can use the existing functionality of x3mRouting to achieve your goal. This will get you up and running until I have more time to add some automation to perform some of the manual steps in the next release.I think it will be manual because will be various ASNs
Envoyé de mon BLA-L29 en utilisant Tapatalk
sh /jffs/scripts/x3mRouting/load_DNSMASQ_ipset.sh WIMIPCOM whatismyipaddress.com
#!/bin/sh
logger -st "($(basename "$0"))" "Started Policy Routing Rules for VPN Client $VPN_ID"
VPN_ID=${dev:4:1}
sh /jffs/scripts/x3mRouting/load_DNSMASQ_ipset.sh WIMIPCOM whatismyipaddress.com
# Range Example
iptables -D PREROUTING -t mangle -i br0 -m iprange --src-range 192.168.2.152-192.168.2.155 -m set --match-set WIMIPCOM dst -j MARK --set-mark 0x8000/0x8000 2>/dev/null
iptables -A PREROUTING -t mangle -i br0 -m iprange --src-range 192.168.2.152-192.168.2.155 -m set --match-set WIMIPCOM dst -j MARK --set-mark 0x8000/0x8000
# Single LAN Client Example
iptables -D PREROUTING -t mangle -i br0 --src 192.168.2.152 -m set --match-set WIMIPCOM dst -j MARK --set-mark 0x8000/0x8000 2>/dev/null
iptables -A PREROUTING -t mangle -i br0 --src 192.168.2.152 -m set --match-set WIMIPCOM dst -j MARK --set-mark 0x8000/0x8000
logger -st "($(basename "$0"))" "Completed Policy Routing Rules for VPN Client $VPN_ID"
#!/bin/sh
# Purge the routing rule when the VPN Client goes down
logger -st "($(basename "$0"))" $$ Starting Script Execution
iptables -D PREROUTING -t mangle -i br0 --src 192.168.2.152 -m set --match-set WIMIPCOM dst -j MARK --set-mark 0x8000/0x8000
logger -st "($(basename "$0"))" $$ Ending Script Execution
chmod 755 /jffs/scripts/x3mRouting/vpnclientX-route-up
chmod 755 /jffs/scripts/x3mRouting/vpnclientX-route-pre-down
iptables -nvL PREROUTING -t mangle --line
liststats
They can be used together. When you install openvpn-event from x3mRouting, it creates the file /jffs/scripts/x3mRouting/openvpn-event and adds a one line entry in /jffs/scripts/openvpn-event to call the one in x3mRouting (sh /jffs/scripts/x3mRouting/openvpn-event).Hello
I need further clarifications on how it works. I already have vpnclientX-route-up (just to send an email when vpn connects) and vpnclient1-route-pre-down (used by VPNFailover script) in /jffs/scripts folder.
Can both scripts (ones from x3mrouting folder and ones from scripts folder) be used simultaneously ? Or one folder supeseeds the other ? Is there any conflict' risk ?
Thanks
Thanks for the ideas. Full integration with the GUI in the future would be ideal. But a huge effort as well.First of all I'd like to thank you for making this script/tool, much appreciated. I am only using the third - IPSET Shell Scripts - method and have some general suggestions for future improvements, I am new to ASUS-merlin so my suggestions may not necessarily be optimal for all situations, suggestions are purely based on my needs:
Thank you again.
- Allow manual IPSET based routing through WAN for specific LAN clients only, or a range of clients - I understand, as a workaround, you've provided a manual way of doing this a couple of posts earlier already, thanks again. My request is this being a feature, built into the script natively
- If no domain names are harvested from dnsmasq.log, don't create an empty list, or ask user to confirm if they'd like to create an empty list. Perhaps there may be situations where a domain is expected to appear in dnsmasq later and the cron job will harvest it later so let the user decide.
- Allow the option to do nslookup instead of harvesting the dnsmasq for domains (bit like how Skynet does when you want to add a domain to whitelist, it does a nslookup automatically). I'm not sure if this may be relevant for other, definitely was relevant for me.
- Allow this functionality through the SSH terminal session interactively (through the script) instead of relying on manually running scripts to create forwarding rules and manually adding items to nat-start, openvpn events etc.
- For creation/deletion of manual IPSET list, allow adding comments in the file that contains list of IP addresses. Is this already possible perhaps, I just don't know about it?
- Finally, if the script functionality can be done through GUI, that would be perfect!
Thanks for the ideas. Full integration with the GUI in the future would be ideal. But a huge effort as well.
You may want to look at pfSense firmware. It has all of the features available through the GUI us script writers have written addons for the Asuswrt-Merlin firmware. Especially if your use case requires Selective Routing. I first experimented with pfSense to get higher OpenVPN throughput from AES-NI. I then found the pfBlockerNG package and Firewall GUI have all of the features to support selective routing in addition to advertising and malicious host blocking. The equivalent to skynet are the snort and suricata packages.
The firewall as an "Alias" feature to create lists. For example, I can create an alias for LAN clients or host names. In the firewall GUI, I can then create a rule to route the alias to the tunnel I prefer or exceptions for domain names. I use pfBlockerNG to create a list of host names or IP addresses manually, from existing sources and using ASN. You then kick off a job in the GUI to populate the lists. Graphical reports are available in pfBlockerNG, similar to what pi-hole provides, along with dashboard stats.
I converted an Windows 7 PC to a pfSense appliance and use an RT-AC68U as the access point.
This post has some referencesThanks for the pfsense suggestion, I'll take a look.
# route VPN Client 1 traffic from 192.168.22.152-192.168.22.157 matching IPSET list WIMIPCOM to the WAN
x3mRouting.sh 1 0 WIMIPCOM src_range=192.168.22.152-192.168.22.157
# route VPN Client 1 traffic from LAN client range 192.168.22.152-192.168.22.157 matching IPET list containing the US AWS region to the WAN
x3mRouting.sh 1 0 AMAZON_US aws_region=US src_range=192.168.22.152-192.168.22.157
# VPN Client Bypass: route VPN Client 1 traffic from 192.168.22.152 matching IPSET list WIMIPCOM to the WAN
x3mRouting.sh 1 0 WIMIPCOM src=192.168.22.152
# route all traffic matching IPSET list WIMIPCOM to VPN Client 1 (manually created list)
x3mRouting.sh ALL 1 WIMIPCOM
# VPN Client Bypass: route all VPN Client 1 traffic matching IPSET list WIMIPCOM to the WAN
x3mRouting.sh 1 0 WIMIPCOM
# route all traffic matching IPSET list NETFLIX created from AS2906 to VPN Client1
x3mRouting.sh ALL 1 NETFLIX asnum=AS2906
# route all traffic matching IPSET list NETFLIX created from domain names to VPN Client1
x3mRouting.sh ALL 1 NETFLIX domain=amazonaws.com,netflix.com,nflxext.com,nflximg.net,nflxso.net,nflxvideo.net
# route all traffic matching IPSET list SKY created from scanning dnsmasq for domains containing sky.com to VPN Client1
x3mRouting.sh ALL 1 SKY domain=sky.com autoscan
That example I posted is not available yet. It is in development for the next release.I have an Asus RT-AC86U router, which I have flashed with AsusWrt Merlin 384.15 firmware. I have set it up to run an OpenVPN client, connected to a NordVPN server. That part works fine. But there are certain websites that discriminate against VPNs by blocking connections -- sites like macys.com, for example. This makes my wife mad, and she tells me to turn off the VPN.
Using the Merlin firmware I can successfully enter an IP address and tell the router to bypass the VPN for that address and go straight to the website over the WAN. The frustrating thing is that some sites, like Macy's, use many servers and dynamic load balancing, so you don't know what IP address "macys.com" will resolve to. So sometimes the VPN bypass works, and sometimes not.
What I'd like to be able to do is to enter the destination of "www.macys.com" into the Merlin routing rules instead of "23.204.249.0/24" (plus who-knows how many other macy's addresses). But I don't believe that functionality exists in Merlin. Is it possible to accomplish what I want using scripts to deal with the problem of different website names having multiple (and perhaps changing) IP addresses from time to time?
UPDATE -- I see the following example from the post prior to mine, posted by Xentrk. Is this routing example related to what I am wanting to do?
# route all traffic matching IPSET list NETFLIX created from domain names to VPN Client1
x3mRouting.sh ALL 1 NETFLIX domain=amazonaws.com,netflix.com,nflxext.com,nflximg.net,nflxso.net,nflxvideo.net
Thanks for any help or suggestions,
Tom
sh /jffs/scripts/x3mRouting/load_DNSMASQ_ipset_iface.sh 0 NETFLIX netflix.com,nflxext.com,nflximg.net,nflxso.net,nflxvideo.net
Here is an example of the next update planned for x3mRouting.
Code:# route VPN Client 1 traffic from 192.168.22.152-192.168.22.157 matching IPSET list WIMIPCOM to the WAN x3mRouting.sh 1 0 WIMIPCOM src_range=192.168.22.152-192.168.22.157 # route VPN Client 1 traffic from LAN client range 192.168.22.152-192.168.22.157 matching IPET list containing the US AWS region to the WAN x3mRouting.sh 1 0 AMAZON_US aws_region=US src_range=192.168.22.152-192.168.22.157 # VPN Client Bypass: route VPN Client 1 traffic from 192.168.22.152 matching IPSET list WIMIPCOM to the WAN x3mRouting.sh 1 0 WIMIPCOM src=192.168.22.152 # route all traffic matching IPSET list WIMIPCOM to VPN Client 1 (manually created list) x3mRouting.sh ALL 1 WIMIPCOM # VPN Client Bypass: route all VPN Client 1 traffic matching IPSET list WIMIPCOM to the WAN x3mRouting.sh 1 0 WIMIPCOM # route all traffic matching IPSET list NETFLIX created from AS2906 to VPN Client1 x3mRouting.sh ALL 1 NETFLIX asnum=AS2906 # route all traffic matching IPSET list NETFLIX created from domain names to VPN Client1 x3mRouting.sh ALL 1 NETFLIX domain=amazonaws.com,netflix.com,nflxext.com,nflximg.net,nflxso.net,nflxvideo.net # route all traffic matching IPSET list SKY created from scanning dnsmasq for domains containing sky.com to VPN Client1 x3mRouting.sh ALL 1 SKY domain=sky.com autoscan
An added feature includes automatic configuration to run the x3mRouting script @ route-up event and to remove the routing rule @ route-pre-down event.
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!