Wired equivalent for Wireless MAC Filter?

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2  Next
Author Message
aliarman
DD-WRT Novice


Joined: 26 Apr 2009
Posts: 8

PostPosted: Sun Jul 19, 2009 14:17    Post subject: Wired equivalent for Wireless MAC Filter? Reply with quote
I have both wired and wireless clients off of my 600N and I allow only the known MAC address to get on the wireless, using MAC Filter under Wireless tab. I would like to do the same for wired (LAN) clients. Is there a way to do this?

I did a search but I think the posts I found were for denying access for the known MAC addresses, whereas I need a method to allow access for the known MACs.

TIA
Sponsor
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Sun Jul 19, 2009 21:36    Post subject: Reply with quote
This can be done with iptables commands in your firewall script.

iptables -I FORWARD -i br0 -m mac --mac-source XX:XX:XX:XX:XX:XX -j ACCEPT

iptable -A FORWARD -i br0 -j DROP

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
aliarman
DD-WRT Novice


Joined: 26 Apr 2009
Posts: 8

PostPosted: Mon Jul 27, 2009 15:59    Post subject: Reply with quote
Thanks for the help.. I did this for my MACs that I want to allow, and saved it in Firewall thru the Administration/commands page; rebooted the router, but it doesn't seem to take affect. I am using Eko's 12476M on a WRT600n 1.1

I am also seeing a set of iptables commands suggested here: http://www.dd-wrt.com/phpBB2/viewtopic.php?t=53796

What are the difference? Should I give those a try?

Thanks a lot..



dd-wrt-firewall_script1.JPG
 Description:
 Filesize:  104.8 KB
 Viewed:  25288 Time(s)

dd-wrt-firewall_script1.JPG


phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Mon Jul 27, 2009 23:30    Post subject: Reply with quote
They're essentially the same, the thing I forgot is you need to load the kernel module before the rules.

insmod ipt_mac

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
aliarman
DD-WRT Novice


Joined: 26 Apr 2009
Posts: 8

PostPosted: Tue Jul 28, 2009 2:15    Post subject: Reply with quote
Added insmod ipt_mac, upgraded to Eko's 12548 std, even tried with sleep 30, but it's still not working for me. Here's nvram get rc_firewall output:

sleep 30
/sbin/insmod ipt_mac
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:1C:BF:D4:55:D7 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:1C:23:33:AE:83 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:12:17:AA:E6:2A -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:1A:4D:4F:A2:EF -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:08:5D:19:B7:7A -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:08:5D:1B:4D:50 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:08:5D:1B:4D:5E -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:16:E3:8F:F7:50 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:18:41:9a:dd:7f -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:22:41:71:2E:06 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:04:76:9D:78:EE -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:23:8B:4E:66:12 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:21:6b:0b:be:c2 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:0C:41:62:E8:B5 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:17:F4:79:BA:8A -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:17:AB:54:33:63 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:1f:a7:6e:26:a2 -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:18:39:3B:C8:4A -j ACCEPT
/usr/sbin/iptables -I FORWARD -i br0 -m mac --mac-source 00:1E:E5:F7:7F:62 -j ACCEPT
/usr/sbin/iptables -A FORWARD -i br0 -j DROP


I am wondering if there are any other settings that interact or are prerequisite for this.
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Tue Jul 28, 2009 3:11    Post subject: Reply with quote
You might want to stop using full paths because nvram is only 32KB and runs out quick. If you're trying to stop LAN to LAN traffic then you need to break all your ports into separate vlans so that they don't get switched. If you want to block LAN to WLAN traffic then you need to also load ebtables. The rules should be blocking LAN to WAN traffic but run this to make sure that the rules exist.

iptables -vnL FORWARD

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
aliarman
DD-WRT Novice


Joined: 26 Apr 2009
Posts: 8

PostPosted: Tue Jul 28, 2009 3:19    Post subject: Reply with quote
Thanks for quick response..

I am only trying to stop LAN to WAN traffic for those MACs that do not exist in the table. I'll try w/o the paths.

The iptables -vnL output is below.

Thanks again!!!



dd-wrt-firewall_script2.JPG
 Description:
 Filesize:  116.63 KB
 Viewed:  25220 Time(s)

dd-wrt-firewall_script2.JPG


phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Tue Jul 28, 2009 4:34    Post subject: Reply with quote
Now I see the problem. Change the DROP rule to be -I instead of -A and put it at the top of the rules.
_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
aliarman
DD-WRT Novice


Joined: 26 Apr 2009
Posts: 8

PostPosted: Tue Jul 28, 2009 4:44    Post subject: Reply with quote
It works!!! Excellent.. Thank you very very much...
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Tue Jul 28, 2009 7:37    Post subject: Reply with quote
I would make a script which uses the mac-entries that were supposed to be used for the wireless-connections.

Would look a lot neater....

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Tue Jul 28, 2009 8:09    Post subject: Reply with quote
Code:
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin

lsmod | grep -q ipt_mac || insmod ipt_mac
iptables -I FORWARD -i br0 -j DROP
nvram get wl0_maclist 2>/dev/null | /opt/bin/egrep -o '([[:xdigit:]]{2}[:-]){5}[[:xdigit:]]{2}' | while read mac
do
  iptables -I FORWARD -i br0 -m mac --mac-source ${mac} -j ACCEPT
done


Because "egrep -o" doesn't work properly in busybox you'll need to have optware installed.
I am in the process of registering with bugzilla and am going to post a ticket for it.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Wed Jul 29, 2009 11:09    Post subject: Reply with quote
The bug with "grep -o" has been fixed immediately in busybox after posting it.
When busybox will be updated in dd-wrt in a future version this code will run without the need to use /opt/bin/egrep

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
aliarman
DD-WRT Novice


Joined: 26 Apr 2009
Posts: 8

PostPosted: Sun Jan 10, 2010 18:19    Post subject: Conflict with Access Restrictions Reply with quote
I just found out that, after putting in the iptables based firewall rules for allowing only known MAC address to access the internet, my "Access Restrictions" rules for the same MACs are no longer effective. If I have an entry in the rc_firewall for a MAC address I can no longer control the hours that MAC address is allowed to use the internet.

Any comments/suggestions?
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Sun Jan 10, 2010 20:10    Post subject: Reply with quote
Insert them further down the chain, the 9 represents where in the chain to put it.

iptables -I FORWARD 9 -i br0 -m mac --mac-source XX:XX:XX:XX:XX:XX -j ACCEPT

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
aliarman
DD-WRT Novice


Joined: 26 Apr 2009
Posts: 8

PostPosted: Mon Jan 11, 2010 4:15    Post subject: Reply with quote
phuzi0n wrote:
Insert them further down the chain, the 9 represents where in the chain to put it.

iptables -I FORWARD 9 -i br0 -m mac --mac-source XX:XX:XX:XX:XX:XX -j ACCEPT


Thanks a lot.. Worked like a charm.
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum