Solved

MAC and IP binding in CentOS 6.3

Posted on 2013-05-29
4
650 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
ID: 39206131
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
ID: 39248586
Thanks Mazdajai for reply, I working on the solution you provided. Will comment after testing. Thanx
0
 
LVL 19

Accepted Solution

by:
Gabriel Orozco earned 500 total points
ID: 39255217
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
ID: 39324305
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

​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…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

815 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

11 Experts available now in Live!

Get 1:1 Help Now