Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
In my LAN, the host with IP 220.127.116.11 has some Winblows virus that is generating outgoing traffic on my network. I donṫ know where this PC is, since it wasnṫ given a DHCP name. I issued the following three commands but they didnṫ stop the traffic:
iptables -I INPUT -s 192.168.0.113 -j DROP
iptables -I OUTPUT -s 192.168.0.113 -j DROP
iptables -I FORWARD -s 192.168.0.113 -j DROP
I wanna try blocking it by its MAC address. How do I do that?
do this (make sure you have the ipt_mac module loaded, too)
iptables -A INPUT -p ALL -m mac --mac-source <insert MAC of offending computer here> -j DROP
this matches the source of the packet to a given MAC, then drops it if it matches (might be obvious, but just in case ). you can also put this in the FORWARD/OUTPUT chain to stop stuff (depends on your iptables).
it's definitely odd that that rule doesn't work. i have a rule like that to match the MAC of my remote computer and it works fine. here's are some rules (verbatim; except for changed MAC) i have in my iptables:
# allows DHCPACK for setup of w-lan
$IPTABLES -A INPUT -p UDP -i wlan0 --dport 67 --sport 68 -m mac --mac-source <remote MAC> -j ACCEPT
# allow ssh in from horatio
$IPTABLES -A INPUT -p TCP -i wlan0 --dport 22 -m mac --mac-source <remote MAC> -j ACCEPT
# only let established/related ssh connections to chimaera in from horatio
$IPTABLES -A INPUT -p TCP -i wlan0 -m state --state ESTABLISHED,RELATED -m mac --mac-source <remote MAC> -j ACCEPT
# allows w-lan valid outgoing through, but stops new/invalid connections through wlan0
$IPTABLES -A FORWARD -i ppp0 -o wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i wlan0 -o ppp0 -m state ! --state INVALID -m mac --mac-source <remote MAC> -j ACCEPT
these rules all work on my router/firewall box. it's odd that the rule didn't work, but maybe it has something to do with the cisco stuff that tarballed has been talking about.