mac dst-mac src-macdeny ip from any to any MAC any 00:11:22:33:44:55 in recv em1
deny ip from any to any MAC 00:11:22:33:44:55 any out xmit em1
Thanks. Like this in my case?mac dst-mac src-mac
if you want to filter the outgoing packetsipfw(8)
man.freebsd.org
nano /etc/rules
# Local
${fwcmd} add allow all from any to any via lo0
${fwcmd) add deny ip from any to any MAC any 00:1E:8C:16:18:2B in recv igb3
${fwcmd} add deny all from any to 127.0.0.0/8
${fwcmd} add deny all from 127.0.0.0/8 to any
ipfw -a show
00100 8 792 allow ip from any to any via lo0
00200 0 0 deny ip from any to any MAC any 00:1e:8c:16:18:2b in recv igb3
00300 0 0 deny ip from any to 127.0.0.0/8
00400 0 0 deny ip from 127.0.0.0/8 to any
00500 2965670 571713649 nat 1 ip from table(0) to any out via igb2
00600 5005797 6034780188 nat 1 ip from any to any in via igb2
00700 16000900 13216854394 allow ip from any to any
00800 0 0 allow tcp from any to any 80
65535 89619 11647664 deny ip from any to any
net.link.ether.ipfw
.You also need to setnet.link.ether.ipfw
.
![]()
Filtering by MAC address
I am using freebsd FreeBSD as a gateway, and I am trying to do filtering by MAC addresses. For example, I want to allow the traffic from machine A with MAC address xx xx xx xx. So I created a sample firewall rule like below. #allow the traffic from that machine allow all ip from any to any MAC...forums.freebsd.org
Yes, I see this computer using nmap -Pn 10.44.1.178 . But tcpdump does not show packets from this address. However, this user with this MAC manually changes his static IP every day, and banning a new IP every day is unreasonable. Why would he do this if he doesn’t use the Internet?Or maybe he is using a tunneling program?The counter doesn't show any matching packets. Do you have access to that machine with mac 00:1e:8c:16:18:2b to test it?
We add rules:
${fwcmd} add deny ip from any to any MAC any FC:34:97:BD:169 in recv igb3
ipfw -a show
00100 0 0 allow ip from any to any via lo0
00200 0 0 deny ip from any to any MAC any fc:34:97:bd:16:d9 in recv igb3
Et voila:
The rules do not work!
For a long time, I couldn’t find anyone anywhere on the Internet who could really ban MAC using IPFW.I’ll probably have to install a computer with IPTABLES in front of the server with IPFW and ban the MAC there
Put it in a [code]...[/code] block, or [icode]...[/icode] for inline code. Besides using a monospaced font it also prevents the forum software from automagically converting emojis, urls, email addresses, etc.[ aside: how do we turn off this STUPID assumption that colon
D or colon ) etc become infantile emojis! ]
Thank you. This is all theory. In practice this doesn't work.I did this about 3 years ago. Someone recommended it on the forum. After that, absolutely all traffic via NAT stopped. That's why I commented it out:You need to enable the L2 filtering. Set net.link.ether.ipfw to 1
sysctl net.link.ether.ipfw=1
To make it permanent across reboots add it into /etc/sysctl.conf
# This file is read when going to multi-user and its contents piped thru
# ``sysctl'' to adjust kernel values. ``man 5 sysctl.conf'' for details.
#
# Uncomment this to prevent users from seeing information about processes that
# are being run under another UID.
#security.bsd.see_other_uids=0
net.inet.ip.fw.verbose=1
net.inet.ip.fw.verbose_limit=100
net.inet.ip.fw.one_pass=0
#net.link.ether.ipfw=1
You know you can add a filter to tcpdump(1)?tcpdump -i igb3 | grep 10.44.1.17
tcpdump -ni igb3 host 10.44.1.17
tcpdump -eni igb3 ether 11:22:33:44:55:66
You'll want to add -e
here too, so the output actually shows the MAC addresses of the packets.It's not theory. I've just test it in my network and it's working as expected.Thank you. This is all theory. In practice this doesn't work.I did this about 3 years ago. Someone recommended it on the forum. After that, absolutely all traffic via NAT stopped. That's why I commented it out:
For this rule work correctly , it was recommended rebuild the kernel and change policy IPFW to allow everyone everything (and the default is to deny everyone everything) . But I thought it would be easier to install Arch with iptables. By the way,in iptables I can easily change the policy, but in IPFW I need to rebuild the kernel and there is no confidence that after that it will work
ipfw -a list
commandOnce again, if you enable net.link.ether.ipfw=1 , all traffic via NAT stops. Try this on your server with NAT and I think all clients on your local network will not like it. And if you did this remotely via ssh, and the server is located far from you, you will get a big problem.Server was no longer visible via ssh, but it is located three meters from my computer, so it’s no big deal.The IPFW rules that you have are ok, you need to enable L2 filtering so the IPFW can block the MAC address that you have in rule 200.
Without net.link.ether.ipfw=1 IPFW will not filter the MAC address that's why you don't see any matching packets on that rule when you list it withipfw -a list
command
ipfw -q -f flush
ipfw nat 1 config if igb2
ipfw add 100 allow ip from any to any layer2 mac-type 0x0806
ipfw add 200 deny ip from any to any MAC any fc:34:97:bd:16:d9
ipfw add 300 nat 1 ip4 from any to me in via igb2
ipfw add 400 nat 1 ip4 from 10.44.1.0/24 to any out via igb2
ipfw add 500 allow ip from any to any
I did all this. It doesn’t work without rebuilding the kernel. If you really want to help me, please provide real working rules and not links to man
Once again, if you enable net.link.ether.ipfw=1 , all traffic via NAT stops. Try this on your server with NAT and I think all clients on your local network will not like it.
iptables -A INPUT -m mac --mac-source 00:0F:EA:91:04:08 - j DROP