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 04-30-2012, 06:49 AM   #1
Zanto
LQ Newbie
 
Registered: Apr 2012
Location: Denmark
Distribution: Ubuntu 11.04 LTS x64
Posts: 4

Rep: Reputation: Disabled
Ubuntu Server: Block all MAC address with exceptions


Hi.

I'm sitting with a quite annoying problem.
Some kids are trying to get into my SSH, and it's filling my logs daily to be over 5 MB.

My server is running Ubuntu 11.04 LTS.
I want to do, so that only those I approve can use port 22, and the current users has dynamic IP addresses, so my only option is to filter on MAC address.
We cannot get a static IP address at all, our ISP doesn't accept that, and we got no other options for ISPs.

I've tried with IPtables, but it works quite bad to be honest.
I added my own MAC address to start off with, then I added my brother's MAC address, and for some reason, I couldn't connect on port 22 at all.

Anyone who knows how to do this?

NB: The server is a VPS.
 
Old 04-30-2012, 08:01 AM   #2
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
You can not filter based on MAC addresses over the Internet.

MAC filtering only works on the local network segment, as soon as you go though a router the only MAC address you will see is the MAC address of that router.

EDIT Handling dynamic IP's may not be that hard especially if your allocated an IP within a set IP block, you can just allow that IP block and most of the hack attempts will disappear.

Last edited by wildwizard; 04-30-2012 at 08:03 AM.
 
Old 04-30-2012, 08:51 AM   #3
Zanto
LQ Newbie
 
Registered: Apr 2012
Location: Denmark
Distribution: Ubuntu 11.04 LTS x64
Posts: 4

Original Poster
Rep: Reputation: Disabled
Then how can I do it, without telling them to register through NoIP or others?
I don't want to add a new IP every day...
 
Old 05-01-2012, 04:25 AM   #4
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
Say the IP's that you try and connect from change around but they look kinda like this list

192.168.20.123
192.168.20.32
192.168.20.98
192.168.21.100
192.168.21.34

Note how the first 2 are always 192.168

If you only see this level of variation you can allow 192.168.0.0/16, which will allow anything so long as the first 2 are 192.168

Your ISP will always allocate IP's from the same pool so you will see a pattern, you just need to find it and then allow it while blocking everything else.
 
Old 05-01-2012, 06:31 AM   #5
Zanto
LQ Newbie
 
Registered: Apr 2012
Location: Denmark
Distribution: Ubuntu 11.04 LTS x64
Posts: 4

Original Poster
Rep: Reputation: Disabled
I'm talking about external IPs, since my server is in Germany, while me and my brother is in Denmark.

So e.g. my IP is 85.218.131.21
Now, my problem is that both 218 and 131 is changing.
And I don't know what my brother's IP is atm.
 
Old 05-01-2012, 06:49 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,694

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Take a look at fail2ban.

http://www.fail2ban.org/wiki/index.php/Main_Page
 
Old 05-01-2012, 07:10 AM   #7
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by Zanto View Post
I'm talking about external IPs, since my server is in Germany, while me and my brother is in Denmark.

So e.g. my IP is 85.218.131.21
Now, my problem is that both 218 and 131 is changing.
And I don't know what my brother's IP is atm.
Ignore the fact that my example was RFC internal IP's the same thing applies no matter what.

85.218.131.21

and you say 218 changes, changes to what, what is the variability
the same with 131, what does it change to what are the limits

When you know the limits of the variability you will have the basis for a rule that allows from that ISP but only that ISP.
 
Old 05-01-2012, 07:15 AM   #8
Zanto
LQ Newbie
 
Registered: Apr 2012
Location: Denmark
Distribution: Ubuntu 11.04 LTS x64
Posts: 4

Original Poster
Rep: Reputation: Disabled
218 has been 320 and others.
While 131 has been both 195 and 210

I don't really see any patterns at all.
 
Old 05-01-2012, 08:38 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Zanto View Post
I don't really see any patterns at all.
It's 85.218.128.0/17 so you want "-m tcp -s 85.218.128.0/17 --dport 22 -m state --state NEW -j ACCEPT".
 
Old 05-01-2012, 09:09 AM   #10
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
The simple solution I've been using for years for this problem (yes, specifically the log flooding) is to use a different non-standard port for SSH. Yes, it is obscurity which does not improve security ... in a technical sense. But I say it helps in that without flooding logs, it's easier to see the real issues that might exist in the logs. And so it is a bit more secure in the administrative sense (something too often overlooked in security design).
 
Old 05-02-2012, 11:39 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Skaperen View Post
But I say it helps in that without flooding logs, it's easier to see the real issues that might exist in the logs.
...and that's why you got log reporting tools. You know, Logwatch or an equivalent.
 
Old 05-02-2012, 07:08 PM   #12
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by unSpawn View Post
...and that's why you got log reporting tools. You know, Logwatch or an equivalent.
And these know which incidents are just people looking for another computer to "0wn" and which incidents are someone specifically attacking you?
 
Old 05-04-2012, 11:02 AM   #13
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
You never tried Logwatch have you?
 
Old 05-04-2012, 08:47 PM   #14
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,976

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Kind of a bit if a risk but maybe set times for services so that it limits it to times when you would need access.

I am not sure if they are kids. All sorts of automated attacks run 24/7.
 
  


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
Block a mac address on proxy server. Satyaveer Arya Linux - Server 2 03-09-2012 04:54 AM
Block Mac Address on squid gpiw Linux - Newbie 4 06-03-2011 09:43 AM
how to block a specific MAC address venkat_eg Linux - General 2 02-05-2011 05:01 PM
can't block MAC Address using iptables Ameii83 Linux - Newbie 2 02-27-2007 06:31 AM
block mac address Ammad Linux - General 1 09-11-2005 01:00 PM

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

All times are GMT -5. The time now is 09:47 AM.

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