LinuxQuestions.org
Review your favorite Linux distribution.
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 12-23-2003, 05:43 AM   #1
PcHammer
Member
 
Registered: Jan 2001
Location: Ljubljana Slovenija
Distribution: Slackware
Posts: 70

Rep: Reputation: 15
Mac address restriction


I would like to force all users to connect using DHCP, and to block users who specify their own IP.
I have setup a dhcp based on MAC address so every user get theri own ip but since i have Win98 users can change their IP.

So do I have any way to set this up ??


Regards, PcHammer
 
Old 12-25-2003, 11:48 AM   #2
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
iptables -t nat -I PREROUTING -i eth~ -s 192.168.1.x -m mac --mac-source ! 00:66:88:FF:GG:DD -j DROP

(If the mac address for the ip number isn't a match drop it...)

You can also put the rule in the INPUT or FORWARD chains.
Dropping them in the nat PREROUTING chain will only effect NEW connections.
This means they are checked only on their 1st packet, not every packet.

There may be a lot of entries, so I suggest using a separate chain so it can be edited more easily, eg

iptables -t nat -N mac_check
iptables -t nat -I PREROUTING -i eth~ -j mac_check
iptables -t nat -I mac_check -p udp --dport 67 -j RETURN
iptables -t nat -A mac_check -s 192.168.1.x -m mac --mac-source 00:66:88:FF:GG:DD -j RETURN
iptables -t nat -A mac_check ... (ip number & correct macs)
iptables -t nat -A mac_check ... etc
iptables -t nat -A mac_check -j DROP

(If the number/mac is matched, go back to PREROUTING & continue...
otherwise get dropped at the end of the new chain.)

A suggestion, put the busiest machines at the beginning of the list!

Last edited by peter_robb; 12-25-2003 at 11:57 AM.
 
Old 12-30-2003, 07:17 AM   #3
PcHammer
Member
 
Registered: Jan 2001
Location: Ljubljana Slovenija
Distribution: Slackware
Posts: 70

Original Poster
Rep: Reputation: 15
Thank you very much it's working great.

But now if i may have one more question, as I have a lot of ips and i would like to use one file where ip and mac address would be stored:
192.168.1.x 00:01:BG:12:45

IPtables rule would be like this than:
iptables -t nat -I PREROUTING -i eth0 -s $IP -m mac --mac-source ! $MAC -j DROP

As i'm not to good in shell programing, i would like to know how can this be done.


regards, PcHammer
 
Old 12-30-2003, 08:28 AM   #4
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Sure, it'll take me a little while too..
it's not my strong point either..

They will need to be in a separate chain so that they don't interfere with existing/future PREROUTING rules...
The info will end up in dhcpd.conf, so maybe a script to build/append to all three files from one master would be good..

How do you start iptables?
From /etc/init.d or from a script?
 
Old 12-31-2003, 02:22 AM   #5
PcHammer
Member
 
Registered: Jan 2001
Location: Ljubljana Slovenija
Distribution: Slackware
Posts: 70

Original Poster
Rep: Reputation: 15
Great and tnx.
And I start iptables from /etc/rc.d/rc.firewall ( slackware distro )


regards, PcHammer
 
  


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
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 07:55 AM
How to find IP address of a machine if I know their MAC Address dysenteryduke Linux - Networking 13 09-12-2005 10:21 AM
How to find MAC address of a specified IP address ? longtongfish Programming 1 07-12-2005 03:26 PM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 04:33 AM
DHCP Server MAC Address found, IP address not assigned wmburke Linux - Wireless Networking 17 11-17-2004 10:33 AM

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

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