Answer the question
In order to leave comments, you need to log in
How to route some sites using IPSET and DNSMASQ to a specific interface?
Help configure the correct routing of some sites to a different interface using ipset and dnsmasq. I have already looked through everything that I found in the manuals, but still something is not working, or rather, the necessary domains do not go through the selected interface.
cat /etc/resolv.conf
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 02:42:c6:27:b3:b1 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.6/24 brd 192.168.2.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fd45:e02f:827e:0:42:c6ff:fe27:b3b1/64 scope global mngtmpaddr dynamic
valid_lft forever preferred_lft forever
inet6 fe80::42:c6ff:fe27:b3b1/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 12:42:c6:27:b3:b1 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.105/24 brd 192.168.0.255 scope global dynamic wlan0
valid_lft 6951sec preferred_lft 6951sec
inet6 fe80::5617:c487:bc95:a666/64 scope link
valid_lft forever preferred_lft forever
4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
link/none
inet 10.114.114.2/24 brd 10.114.114.255 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::51f9:2967:8ef2:bac7/64 scope link flags 800
valid_lft forever preferred_lft forever
ipset create vpnlist hash:ip timeout 3600
ip rule add fwmark 1 table 1
ip route add default dev tun0 table 1
iptables -w -A PREROUTING -t mangle -m set --match-set vpnlist dst,src -j MARK --set-mark 1
Answer the question
In order to leave comments, you need to log in
Is it all on the same host? Isn't that a router?
Then not PREROUTING but OUTPUT
If there is a VPN (and it is, judging by tun0) - then it's better to take a socks proxy (danted for example) and some extension like foxy proxy. No need to collect IP (which tend to change, especially if the site is on a cloudflare thread).
Alternative - we take quagga or bird, we make statics with the necessary next-hop. No ip rules / sets/ tables are needed for this.
UPD: read more carefully. ipset is created with hash:ip, and for some reason the match is made with src/dst. Why not --match-set vpnlist dst ?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question