LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-10-2012, 02:53 PM   #1
tkmbe
Member
 
Registered: Jun 2005
Location: Obera, Argentina
Distribution: OpenSuse 10.3, Debian 4.0, Debian 3.1
Posts: 38

Rep: Reputation: 15
Angry How do I allow only a specific ip with a specific mac on lan with iptables?


Hi

I've the following problem. I want to allow the network traffic of a machine only it the machine has a specific ip AND this ip has a specific mac.
For example allow only machine with ip 10.0.0.137 which has mac 08:2E:5F:81:0B:AB.
So I have the following statements for iptables with an additional queue created but it does not work. The host has no access to the world.
BTW: The machine which this script is running on is an ap and has ip 10.0.0.1 on the internal net and 10.24.88.240 on wifi net.
From the ap to world ok from the connected machine on lan it does not work :-(
Any hints?

Code:
${IPT} -F FORWARD 
${IPT} -P FORWARD DROP

${IPT} -F MACTABLE
${IPT} -N MACTABLE
${IPT} -P MACTABLE DROP

${IPT} -A FORWARD -s 10.0.0.137 -j MACTABLE
${IPT} -A FORWARD -d 10.0.0.137 -j MACTABLE

${IPT} -A MACTABLE -m mac --mac-source 08:2E:5F:81:0B:AB -j ACCEPT
iptables -A MACTABLE -j DROP
which gives me the following tables...

Code:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy DROP)
target     prot opt source               destination         
MACTABLE   all  --  10.0.0.137           0.0.0.0/0           
MACTABLE   all  --  0.0.0.0/0            10.0.0.137          

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain MACTABLE (2 references)
target     prot opt source               destination         
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           MAC 08:2E:5F:81:0B:AB 
DROP       all  --  0.0.0.0/0            0.0.0.0/0
 
Old 07-10-2012, 03:12 PM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

Your problem is likely with this rule:
Code:
${IPT} -A FORWARD -d 10.0.0.137 -j MACTABLE
For (incoming) packets with a destination 10.0.0.137, the source MAC address won't be 08:2E:5F:81:0B:AB.
 
Old 07-10-2012, 05:20 PM   #3
tkmbe
Member
 
Registered: Jun 2005
Location: Obera, Argentina
Distribution: OpenSuse 10.3, Debian 4.0, Debian 3.1
Posts: 38

Original Poster
Rep: Reputation: 15
Ups

changed to
${IPT} -A FORWARD -d 10.0.0.137 -j ACCEPT
and now it works!!

Thanks clifford and greetings!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
IPTABLES rerouting only specific ips to a specific internal pc paulspinsmash Linux - Networking 3 01-06-2011 09:59 PM
IsThere a fridge, that we can program at specific date/time to unfreeze specific food frenchn00b General 3 07-21-2009 11:26 PM
How to force specific domain or user specific emails to proces in sendmail 8.13.5 FC5 peanutsa Linux - Newbie 1 03-22-2009 05:33 AM
How to open port on iptables locked on a specific internal MAC address? blackman890 Linux - Security 2 10-05-2007 02:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration