LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-28-2010, 05:20 AM   #1
ekalavya
LQ Newbie
 
Registered: Feb 2009
Posts: 23

Rep: Reputation: 0
ip mac binding in iptables


Hi,

I want to bind ip and mac in iptables and the script i gathered and working on is as under:

#!/bin/sh
IPTAB = "/sbin/iptables"
macadds = "xx:xx:xx:xx:xx:xx yy:yy:yy:yy:yy:yy zz:zz:zz:zz:zz:zz"
ipadds = "aaa:aaa:a:a bbb:bbb:b:b ccc:ccc:c:c"

$IPTAB -P INPUT DROP
$IPTAB -P OUTPUT ACCEPT

for ((i=0; i<3; i++))
do $IPTAB -A INPUT -m mac --mac-source $macadds -s $ipadds -j ACCEPT
done

When i run the above script, i get an error as "Bad argument yy:yy:yy:yy:yy:yy try iptables --help for more information"

Please help.

regards,
Ekalavya.
 
Old 07-28-2010, 09:16 AM   #2
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
Your script is not correct. You'll have to do something like:

Code:
#!/bin/bash
# this is for IPv6 addrs
IPTABLES=/sbin/ip6tables
ADDRS="xx:xx:xx:xx:xx:xx/aaa:aaa:a:a yy:yy:yy:yy:yy:yy/bbb:bbb:b:b zz:zz:zz:zz:zz:zz/ccc:ccc:c:c"

for I in $ADDRS
do
    $IPTABLES -A INPUT -m mac --mac-source `echo $I|cut -d/ -f1` -s `echo $I|cut -d/ -f2` -j ACCEPT
done
NOTE: I haven't verified this script. Please ensure that you don't blindly run it on a production system.

-Aaron
 
Old 07-29-2010, 05:21 AM   #3
ekalavya
LQ Newbie
 
Registered: Feb 2009
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by orgcandman View Post
Your script is not correct. You'll have to do something like:

Code:
#!/bin/bash
# this is for IPv6 addrs
IPTABLES=/sbin/ip6tables
ADDRS="xx:xx:xx:xx:xx:xx/aaa:aaa:a:a yy:yy:yy:yy:yy:yy/bbb:bbb:b:b zz:zz:zz:zz:zz:zz/ccc:ccc:c:c"

for I in $ADDRS
do
    $IPTABLES -A INPUT -m mac --mac-source `echo $I|cut -d/ -f1` -s `echo $I|cut -d/ -f2` -j ACCEPT
done
NOTE: I haven't verified this script. Please ensure that you don't blindly run it on a production system.

-Aaron
Hi,

Thank you for your reply.

Can you please let me know how to correct the above script in earlier version of iptables as our server is running FC4. Also, can you please clarify whether i can download and install ip6tables for fc4 and then try it out?.

Thanks & regards,

Ekalavya
 
Old 07-29-2010, 10:03 AM   #4
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
I was assuming that your IP addresses were IPv6 addresses. Feel free to change them to IPv4 and use regular old iptables if that's the case.

If you're using IPv6, otoh, I have no idea what utilities are required. Especially for a version of Fedora which went EOL a looooong time ago.
 
Old 07-30-2010, 03:24 AM   #5
ekalavya
LQ Newbie
 
Registered: Feb 2009
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by orgcandman View Post
I was assuming that your IP addresses were IPv6 addresses. Feel free to change them to IPv4 and use regular old iptables if that's the case.

If you're using IPv6, otoh, I have no idea what utilities are required. Especially for a version of Fedora which went EOL a looooong time ago.
Hi,

My intention of IP MAC binding is to avoid somebody changing their IP with others and use Internet.

Now, instead of loop i have entered manually the IP addresses and MAC addresses which is working fine. But even if somebody changes their IP, still they are able to access Internet which i am not able to understand and lead to confusion that IP MAC binding is not effective.

If you have any idea/solution, please let me know.

regards,
Ekalavya
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dhcp server reporting bogus mac id while binding. shellarchive Red Hat 3 06-19-2009 02:07 AM
MAC with IP binding in squid Proxy saas Linux - Newbie 4 01-02-2009 10:57 AM
Binding 2 NICs (MAC addresses) to 2 IP Addresses in same Subnet RedHat EL4.0 skhira Linux - Networking 13 02-24-2008 08:16 PM
Binding 2 NICs (MAC addresses) to 2 IP Addresses in same Subnet RedHat EL4.0 skhira Linux - Networking 1 02-09-2008 07:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:10 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