What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Policy routing. No chain/target/match for ipset

avathar

New Around Here
Hello, i encounter a problem with setting up policy routing with iptables. I need to route traffic to some IPs through VPN from all devices in my LAN.

First of all i'm create ipset of this IPs:
Code:
#!bin/bash
ipset x
ipset create vpnset hash:net

for IP in `cat ipslist_collapsed_prefix`; do
    ipset add vpnset "$IP"
done
Next i'm tryin to MARK all packet from this IPS:
Code:
admin@RT-AC68U-E330:/# iptables -t mangle -A PREROUTING -m set --match-set vpnset src -j MARK --set-mark 100
And get error:
Code:
iptables: No chain/target/match by that name.
What I doing wrong?


 
Last edited:
I don't know what your problem is, but the very first line is a) a syntax error, and b) refers to a non-existent shell.

!#bin/bash
 
Hello, i encounter a problem with setting up policy routing with iptables. I need to route traffic to some IPs through VPN from all devices in my LAN.

First of all i'm create ipset of this IPs:
!#bin/bash
ipset x
ipset create vpnset hash:net

for IP in `cat ipslist_collapsed_prefix`; do
ipset add vpnset "$IP"
done​
Next i'm tryin to MARK all packet from this IPS:
admin@RT-AC68U-E330:/# iptables -t mangle -A PREROUTING -m set --match-set vpnset src -j MARK --set-mark 100​
And get error:
iptables: No chain/target/match by that name.

What I doing wrong?



First of all your shebang is wrong so the script probably doesn't even execute (which would mean the set "vpnset" was never created thus spitting the error when you run the iptables command)

Code:
#!/bin/sh
ipset x
ipset create vpnset hash:net

for IP in "$(cat ipslist_collapsed_prefix)"; do
    ipset add vpnset "$IP"
done
 
First of all your shebang is wrong so the script probably doesn't even execute (which would mean the set "vpnset" was never created thus spitting the error when you run the iptables command)

Code:
#!/bin/sh
ipset x
ipset create vpnset hash:net

for IP in "$(cat ipslist_collapsed_prefix)"; do
    ipset add vpnset "$IP"
done

it's just typo. ipset created successfully
Code:
admin@RT-AC68U-E330:/# ipset list | head -9
Name: vpnset
Type: hash:net
Revision: 6
Header: family inet hashsize 8192 maxelem 65536
Size in memory: 103692
References: 0
Number of entries: 24817
Members:
34.203.226.0
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Members online

Back
Top