Solved

MAC and IP binding in CentOS 6.3

Posted on 2013-05-29
4
637 Views
Last Modified: 2013-07-14
I have a application which is running on CentOS 6.3 under tomcat web server and other computer in our LAN  can access this application. Is this possible to bind MAC and IP of  computers so that other computers in our LAN cannot make connection to to our application.
0
Comment
Question by:edreamers
  • 2
4 Comments
 
LVL 21

Expert Comment

by:Mazdajai
Comment Utility
You can setup host (ip) based ACL via hosts.allow or hosts.deny -

http://linux.about.com/od/commands/l/blcmdl5_hostsal.htm

You can do mac address filtering in ip tables but it is not recommended as it is high maintenance -

http://techgurulive.com/2008/09/22/how-to-do-mac-address-packet-filtering-using-iptables/
0
 

Author Comment

by:edreamers
Comment Utility
Thanks Mazdajai for reply, I working on the solution you provided. Will comment after testing. Thanx
0
 
LVL 19

Accepted Solution

by:
Redimido earned 500 total points
Comment Utility
I would rather do this:

#/bin/bash
LAN=eth0
MAC=00:02:A5:EC:00:8B
IP=10.0.0.110

# If the mac is arriving with a different ip than authorized, drop it:
 iptables -A INPUT -i ${LAN} -m mac --mac-source ${MAC} -s! ${IP} -j DROP
 iptables -A INPUT -i ${LAN} -m mac --mac-source ${MAC} -s ${IP} -j ACCEPT
#end of script

you can also have a file pairing ip's and mac addresses.

say you have the file mac_ip.txt (mac address, then a space, then the ip address)
-------------------------------------------------------------------
00:02:A5:EC:00:8B 10.0.0.110
00:12:B5:EC:00:1A 10.0.0.112
...
etc
-------------------------------------------------------------------

then a simple script like this do the job:
-------------------------------------------------------------------
#/bin/bash
LAN=eth0
while read mac ip; do
   iptables -A INPUT -i ${LAN} -m mac --mac-source ${MAC} -s! ${IP} -j DROP
   iptables -A INPUT -i ${LAN} -m mac --mac-source ${MAC} -s ${IP} -j ACCEPT
done < mac_ip.txt
-------------------------------------------------------------------

hope this helps
Gabriel
0
 

Author Comment

by:edreamers
Comment Utility
I've tried all but not able to control things the way I want. So I am migrating to Windows Platform. Thanx every one for their support.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
​Being a Managed Services Provider (MSP) has presented you  with challenges in the past— and by meeting those challenges you’ve reaped the rewards of success.  In 2014, challenges and rewards remain; but as the Internet and business environment evol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now