My first steps as a developer
Grzegorz Borowiak <[email protected]>
| Newsgroups | gmane.linux.network.bridge.ebtables.devel |
|---|---|
| Message-ID | <[email protected]> |
OK, so I just committed to CVS revised among match and two new targets. In among I've added all your suggestions, namely: - IP/MAC pairs - negation - variable size: this was the toughest part. Uuufff...! :-) Two new targets are idnat and isnat. They are "industrialized" versions of dnat and snat, like among is "industrialized" version of generic -d/-s. With isnat, you specify 3/4 of IPv4 address with --isnat-sub argument and a table, which maps vaules of the last byte of IPv4 to certain MAC addresses or to '!', meaning DROP. Since that, all packets which fulfill the following conditions: - are of protocol IPv4 or ARP - first 3 bytes of their source IP address are equal to these specified with --isnat-sub - last byte of the source IP address is mapped to anything with --isnat-list are: - snatted, if their last IP address byte is mapped to a MAC address - dropped, if their last IP address byte is mapped to a '!' All other packet are treated with target specified with --isnat-default-target. For example: ebtables -t nat -A POSTROUTING -j isnat --isnat-sub 213.192.68. \ --isnat-list 12=00:00:53:19:ad:2c,17=00:e0:7d:21:23:d3,42=00:50:bf:43:3f:12,13=!,14=!,15=! does the same as: ebtables -t nat -A POSTROUTING -p IPV4 --ip-src 213.192.68.12 -j snat --to-source 00:00:53:19:ad:2c ebtables -t nat -A POSTROUTING -p ARP --arp-ip-src 213.192.68.12 -j snat --to-source 00:00:53:19:ad:2c ebtables -t nat -A POSTROUTING -p IPV4 --ip-src 213.192.68.17 -j snat --to-source 00:e0:7d:21:23:d3 ebtables -t nat -A POSTROUTING -p ARP --arp-ip-src 213.192.68.17 -j snat --to-source e0:7d:21:23:d3 ebtables -t nat -A POSTROUTING -p IPV4 --ip-src 213.192.68.42 -j snat --to-source 00:50:bf:43:3f:12 ebtables -t nat -A POSTROUTING -p ARP --arp-ip-src 213.192.68.42 -j snat --to-source 00:50:bf:43:3f:12 ebtables -t nat -A POSTROUTING -p IPV4 --ip-src 213.192.68.13 -j drop ebtables -t nat -A POSTROUTING -p ARP --arp-ip-src 213.192.68.13 -j drop ebtables -t nat -A POSTROUTING -p IPV4 --ip-src 213.192.68.14 -j drop ebtables -t nat -A POSTROUTING -p ARP --arp-ip-src 213.192.68.14 -j drop ebtables -t nat -A POSTROUTING -p IPV4 --ip-src 213.192.68.15 -j drop ebtables -t nat -A POSTROUTING -p ARP --arp-ip-src 213.192.68.15 -j drop but is much less CPU-consuming. idnat is of course symmetrical. I did not change Config.in and Makefile, I preffered not to mess that. I'll change them after your comments. If you like these targets, I'm going to create industrialized versions of arpreply nad mark (iarpreply and imark) in the same manner. -- Grzesław ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf