|
|
Set typesIP sets support the following type of sets:
BindingsIP sets allows you to bind an entry in a set to another set, which forms a relationship between the set element and the set it is bound to. The sets may have a default binding, which is valid for every set element for which there is no binding defined at all. The bindings have no special meaning at the set level.
However, you can benefit from them when using the Let's see an example: # ipmap set storing the IP addresses of two machines ipset -N servers ipmap --network 192.168.0.0/16 ipset -A servers 192.168.0.1 ipset -A servers 192.168.0.2 # portmap set storing the allowed ports for 192.168.0.2 ipset -N ports portmap --from 1 --to 1024 ipset -A ports 21 ipset -A ports 22 ipset -A ports 25 # Binding, which attaches ports to 192.168.0.2 ipset -B servers 192.168.0.2 -b ports # iptables rule using the set match ... iptables -A FORWARD -m set --set servers dst,dst -j ACCEPT iptables -A FORWARD -j DROPNow according to the iptables rules, sets and binding, the firewall will allow trough packets destined to any port on 192.168.0.1, while for 192.168.0.2 only the ports 21, 22 and 25 will be reachable. set match and SET target of iptablesIP sets can be used via the set match and SET target in iptables rules. You can match the packets against sets by the set match and can add or delete entries from/to a set by the SET target. Both extensions follow bindings up to six levels. Please note, there is no need for an entry to be added to a set in order that there be a binding defined for it. In the arguments of the extensions, the tokens src and dst can be used to specify which IP address or port to use from the packet to match the given set. |