LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-26-2013, 06:45 AM   #1
aholak
LQ Newbie
 
Registered: Feb 2013
Posts: 6

Rep: Reputation: Disabled
How can I only allow 170.169.xxx.xxx ip ranges via iptables?


Hi,

I have ssh port 22 that opened to everyone now.I want to allow just for 170.169.xxx.xxx ip blocks. How can I do that?

My current iptable rules for ssh is:
Quote:
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

Last edited by aholak; 02-26-2013 at 06:49 AM.
 
Old 02-26-2013, 06:46 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
http://www.cyberciti.biz/tips/linux-...-or-ports.html
 
Old 02-26-2013, 06:49 AM   #3
aholak
LQ Newbie
 
Registered: Feb 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
I read that article but couldn't understand. Shows only ips from 192.168.1.100 to 192.168.1.200

Same configration can be done?

Quote:
iptables -A INPUT -p tcp --dport 22 -m iprange --src-range 170.169.1.1-170.169.255.255 -j ACCEPT

Last edited by aholak; 02-26-2013 at 06:51 AM.
 
Old 02-26-2013, 07:23 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 2,957

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
Or:
Code:
# iptables -t filter -A INPUT -p tcp --dport 22 -s 170.169.0.0/255.255.0.0 -j ACCEPT
# iptables -t filter -A INPUT -p tcp --dport 22 -j DROP
 
1 members found this post helpful.
Old 02-26-2013, 07:24 AM   #5
aholak
LQ Newbie
 
Registered: Feb 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Or:
Code:
# iptables -t filter -A INPUT -p tcp --dport 22 -s 170.169.0.0/255.255.0.0 -j ACCEPT
# iptables -t filter -A INPUT -p tcp --dport 22 -j DROP
Wow, Thank you so much, now works as just I wanted.

Last edited by aholak; 02-26-2013 at 07:34 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Error, some other host already uses address xxx.xxx,xxx,xxx ryan462 Linux - Networking 20 01-25-2010 12:14 AM
http://www.spamhaus.org/query/bl?xxx.xxx.xxx.xxx (Server cannot send email now!) RMLinux Linux - Server 3 05-08-2009 03:06 AM
smbclient -M xxx.xxx.xxx.xxx Doesnt Work DiscreetControl Linux - Networking 7 12-28-2007 11:50 AM
Problem getting connection with a DLink Router after setting static IP 10.xxx.xxx.xxx kezira Linux - Networking 1 11-09-2005 11:27 PM
Host XXX.XXX.XXX.XXX is not allowed to connect to this MySQL server ocavid Linux - Newbie 2 03-16-2005 10:40 AM


All times are GMT -5. The time now is 05:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration