ipset question
I'm looking for a way to make my iptables rules more manageable, and so I am attempting to use ipset. However, I am not sure if it does what I
am trying to do. I have many subnets that need to be SNATed
differently depending upon their destination. As a test, I made two iphash sets and loaded in one of my sets of sources and one set of destinations. However, when I try to apply the iptables rule, I get the error:
iptables v1.3.0: Unknown arg `destination'
I am running 2.6.9 with the most current iptables, pom, and ipset from Jozsef Kadlecsik's website
(http://people.netfilter.org/kadlec/ipset/install.html)
below is my test data:
-N source iphash --hashsize 1024 --probes 8 --resize 50 --netmask 24 -A sources 10.2.2.0
-A sources 10.2.3.0
-A sources 10.2.8.0
-A sources 10.2.7.0
-A sources 10.2.11.0
-A sources 10.2.4.0
-N destination iphash --hashsize 1024 --probes 8 --resize 50 --netmask 24
-A destination 10.2.254.0
-A destination 10.2.250.0
-A destination 10.2.6.0
-A destination 10.2.251.0
-A destination 10.2.249.0
-A destination 10.2.10.0
-A destination 10.2.14.0
iptables -t nat -A POSTROUTING -m set --set sources src -m set --set destination dst -j SNAT --to-source <ipaddress>
I would appreciate any tips or pointers of what I've done wrong.
Brett
Hi,
Quoted 8 lines · Brett Oster
I'm looking for a way to make my iptables rules more manageable, and so I am attempting to use ipset. However, I am not sure if it does what I
am trying to do. I have many subnets that need to be SNATed
differently depending upon their destination. As a test, I made two iphash sets and loaded in one of my sets of sources and one set of destinations. However, when I try to apply the iptables rule, I get the error:
Quoted 5 lines
iptables v1.3.0: Unknown arg `destination'
I am running 2.6.9 with the most current iptables, pom, and ipset from Jozsef Kadlecsik's website
(http://people.netfilter.org/kadlec/ipset/install.html)
You are using the old ipset binary. From the URL above you can donwnload ipset 2.0. Do you have two binaries installed at different locations and the old one is found according to your PATH settings?
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Quoted 22 lines · Jozsef Kadlecsik
Hi,
Quoted 8 lines · Brett Oster
I'm looking for a way to make my iptables rules more manageable, and so I am attempting to use ipset. However, I am not sure if it does what I
am trying to do. I have many subnets that need to be SNATed
differently depending upon their destination. As a test, I made two iphash sets and loaded in one of my sets of sources and one set of destinations. However, when I try to apply the iptables rule, I get the error:Quoted 5 lines
iptables v1.3.0: Unknown arg `destination'
I am running 2.6.9 with the most current iptables, pom, and ipset from Jozsef Kadlecsik's website
(http://people.netfilter.org/kadlec/ipset/install.html)You are using the old ipset binary. From the URL above you can donwnload ipset 2.0. Do you have two binaries installed at different locations and the old one is found according to your PATH settings?
Quoted 7 lines
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear PhysicsH-1525 Budapest 114, POB. 49, Hungary
I have ipset 2.0, I compiled it when I compiled the new iptables and kernel, and I have no old binary on that system. As far as I can tell, ipset is working ok. I think my problem is that I am not sure how to correctly phrase the iptables line. I tried a few variations on this:
"iptables -t nat -A POSTROUTING -m set --set sources src -m set --set destination dst -j SNAT --to-source <IP ADDRESS>", however, I've not gotten it correct yet. Please let me know if what I'm trying to do is possible, and if it is, how to properly phrase it.
Thanks for your help.
Brett Oster
Quoted 18 lines · Brett Oster
Quoted 10 lines
Quoted 10 lines
I'm looking for a way to make my iptables rules more manageable, and so I am attempting to use ipset. However, I am not sure if it does what I
am trying to do. I have many subnets that need to be SNATed
differently depending upon their destination. As a test, I made two iphash sets and loaded in one of my sets of sources and one set of destinations. However, when I try to apply the iptables rule, I get the error:iptables v1.3.0: Unknown arg `destination'
Quoted 7 lines
Quoted 3 lines
I am running 2.6.9 with the most current iptables, pom, and ipset from Jozsef Kadlecsik's website
(http://people.netfilter.org/kadlec/ipset/install.html)You are using the old ipset binary. From the URL above you can donwnload ipset 2.0. Do you have two binaries installed at different locations and the old one is found according to your PATH settings?
Quoted 8 lines
I have ipset 2.0, I compiled it when I compiled the new iptables and kernel, and I have no old binary on that system. As far as I can tell, ipset is working ok. I think my problem is that I am not sure how to correctly phrase the iptables line. I tried a few variations on this:
"iptables -t nat -A POSTROUTING -m set --set sources src -m set --set destination dst -j SNAT --to-source <IP ADDRESS>", however, I've not gotten it correct yet. Please let me know if what I'm trying to do is possible, and if it is, how to properly phrase it.
It seems a mug of tee was missing from my engine and thus I misread your mail, sorry.
You cannot accomplis what you want with the way you tried, because iptables does not support to specify the same type of match two times. In another words you can list as many different matches as you want in an iptables command, but you cannot specify the same type of match two or more times.
Depending on exactly what you want, bindings of set elements to other sets may help you. Bindings form an AND relation expressing in the terms of matches. So if you can express your src AND dst condition generally as
sources set
src1 AND destination1 set (dst11, dst12, ...)
src2 AND destination2 set (dst21, dst22, ...)
...then create the sets, bind the elements of sources set to the proper destination sets and use the iptables command
iptables -t nat -A POSTROUTING -m set --set sources src,dst \ -j SNAT --to-source <IP ADDRESS>
The set match (and SET target) follows the bindings all along the way up to the built in limit. (If any src in the sources set may match with any dst from the destinations set, then specify the destination set as the default binding of the sources set.)
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary