iptables and wireless card in promiscuous mode
Hello People,
I have a little question:
I have two laptops that have 802.11 wireless cards. I am developing some application that essentially perform sniffing functions using wireless cards in promiscuous mode. To test my code, I need those two laptops not to "see" each other (--> I do not want the wireless card of laptop A, which is operating in promiscuous mode to process packets coming from laptop B) and I tought to do it using iptables. so on laptop A i added the following rule:
iptables -A INPUT -mac --mac-source MAC_ADDRESS_LAPTOP_B -j DROP
and on laptop B I added the rule:
iptables -A INPUT -mac --mac-source MAC_ADDRESS_LAPTOP_A -j DROP
I just executed my first tests and the feeling I got is that, for example, the wlan card of laptop B still passes through the packet coming from laptop A.
Can anyone confirm this analysis? If I am right, can anyone give me a hint to possibly workaround this?
Thank you very much
Claudio
Quoted 7 lines
I have two laptops that have 802.11 wireless cards. I am developing some application that essentially perform sniffing functions using wireless cards in promiscuous mode. To test my code, I need those two laptops not to "see" each other (--> I do not want the wireless card of laptop A, which is operating in promiscuous mode to process packets coming from laptop B) and I tought to do it using iptables.
Promisc packet capture occurs before Netfilter filtering. So you can't prevent network adapter in promiscuous mode to sniff given packets using iptables. You must configure BPF to exclude the frames you don't want to see.
Signature · 2 lines
http://www.netexit.com/~sid/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines
Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!
see inlined:
Quoted 16 lines · Claudio Lavecchia
Hello People,
I have a little question:
I have two laptops that have 802.11 wireless cards. I am developing some application that essentially perform sniffing functions using wireless cards in promiscuous mode. To test my code, I need those two laptops not to "see" each other (--> I do not want the wireless card of laptop A, which is operating in promiscuous mode to process packets coming from laptop B) and I tought to do it using iptables. so on laptop A i added the following rule:
iptables -A INPUT -mac --mac-source
MAC_ADDRESS_LAPTOP_B-j DROPand on laptop B I added the rule:
Quoted 8 lines
iptables -A INPUT -mac --mac-source
MAC_ADDRESS_LAPTOP_A-j DROPI just executed my first tests and the feeling I got is that, for example, the wlan card of laptop B still passes through the packet coming from laptop A.
Can anyone confirm this analysis? If I am right, can anyone give me a hint to possibly workaround this?
Urrm.
You are likely doing the filtering in the wrong pipe. These rules will only
drop packets that are destined for the IP of the host they are on. You PROBABLY are trying to drop *all* traffic from the other laptop. Iptables can do this at the IP layer, however you will STILL be able to see the traffic across that card (from the other laptop) with any decent sniffer program since ip sniffers work below the IP layer, before iptables gets the packet to filter. Most decent network sniffers, however, can do mac address filtering on input.
If you would like to have the traffic dropped anyway, there are better places
to put these rules, even though many are strongly against filtering anywhere but in the filter table (including myself) the following would get the traffic off your iptables radar:
iptables -A PREROUTING -t mangle -m mac --mac-source MAC_ADDRESS_LAPTOP_A -j \
DROP
Although in truth I'm not sure that this is wise, it might serve your
purposes.
Alistair Tonner
RSO HP Unix support
Well,
In fact I really wanted my WLAN card set in promiscuous mode to drop all the packets coming from the other laptop, this means that I wanted a filter BEFORE the promiscuos mode filter. And by the way: how do I cancel a rule from the PREROUTING chain?
If I do the standard way, I get:
~ # iptables -D PREROUTING 1
iptables: No chain/target/match by that name
Thx
Claudio
Quoted 46 lines · Alistair Tonner
see inlined:
Quoted 16 lines · Claudio Lavecchia
Hello People,
I have a little question:
I have two laptops that have 802.11 wireless cards. I am developing some application that essentially perform sniffing functions using wireless cards in promiscuous mode. To test my code, I need those two laptops not to "see" each other (--> I do not want the wireless card of laptop A, which is operating in promiscuous mode to process packets coming from laptop B) and I tought to do it using iptables. so on laptop A i added the following rule:
iptables -A INPUT -mac --mac-source
MAC_ADDRESS_LAPTOP_B-j DROPand on laptop B I added the rule:
Quoted 10 lines
iptables -A INPUT -mac --mac-source
MAC_ADDRESS_LAPTOP_A-j DROPI just executed my first tests and the feeling I got is that, for example, the wlan card of laptop B still passes through the packet coming from laptop A.
Can anyone confirm this analysis? If I am right, can anyone give me a hint to possibly workaround this?
Urrm. You are likely doing the filtering in the wrong pipe. These rules will only drop packets that are destined for the IP of the host they are on. You PROBABLY are trying to drop *all* traffic from the other laptop. Iptables can do this at the IP layer, however you will STILL be able to see the traffic across that card (from the other laptop) with any decent sniffer program since ip sniffers work below the IP layer, before iptables gets the packet to filter. Most decent network sniffers, however, can do mac address filtering on input.
If you would like to have the traffic dropped anyway, there are better places to put these rules, even though many are strongly against filtering anywhere but in the filter table (including myself) the following would get the traffic off your iptables radar:
iptables -A PREROUTING -t mangle -m mac --mac-source
MAC_ADDRESS_LAPTOP_A-j \ DROPAlthough in truth I'm not sure that this is wise, it might serve your purposes.
Alistair Tonner
RSO HP Unix support
Quoted 5 lines · Claudio Lavecchia
Well,
In fact I really wanted my WLAN card set in promiscuous mode to drop all the packets coming from the other laptop, this means that I wanted a filter BEFORE the promiscuos mode filter.
if that makes sense to you, or anyone else on this list--more power to you.
Quoted 5 lines
And by the way: how do I cancel a rule from the PREROUTING chain? If I do the standard way, I get:
~ # iptables -D PREROUTING 1
iptables: No chain/target/match by that name
first--you need to specify a chain (here you also need to specify a table, as filter has no PREROUTING chain). second--you need to specify the whole rule.
a rule added with the command:
iptables -t nat -A PREROUTING -i $EXT_IF -p tcp --dport 80 \
-j DNAT --to-destination $WEB_SRVmust be deleted with the command:
iptables -t nat -D PREROUTING -i $EXT_IF -p tcp --dport 80 \
-j DNAT --to-destination $WEB_SRVthe other option would be to flush that chain and just add back the rules you want to keep (if any), as is often done in scripts:
iptables -t nat -F PREROUTING
iptables -t nat -A PREROUTING ...
and lastly--you could:
iptables-save > ipt.out
vi ipt.out [delete rule(s) you don't want any more] iptables-restore ipt.out
-j
--
"I'm having the best day of my life, and I owe it all to not going
to Church!"
--The Simpsons