LinuxQuestions.org
Help answer threads with 0 replies.
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 08-14-2012, 05:11 PM   #1
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Rep: Reputation: 1
block ssh in iptables accept for group of ips


hi,

i want to block my servers ssh access to all except few ips say, 5 ips. usually i do like

# iptables -I INPUT -p tcp --dport 22 -j REJECT

and allow my ips

# iptables -I INPUT -p tcp -s 192.168.1.1 --port 22 -j ACCEPT
# iptables -I INPUT -p tcp -s 192.168.1.2 --port 22 -j ACCEPT
# iptables -I INPUT -p tcp -s 192.168.1.3 --port 22 -j ACCEPT

SO ON
any simple rule not wrinting rule for each ip , i know using ! except in iptables as below

# iptables -I INPUT ! -s 192.168.1.1 --dport 22 -p tcp -j REJECT

issue with above rule is it will allow only one ip and blocks rest ...
please give me simple rule to full fil my need.

thank you.
 
Old 08-14-2012, 10:02 PM   #2
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Rep: Reputation: 34
IPSet is the way to go. You can create set of networks/ IP address and allow/block them as per your needs. Click the link for IPset IPSet
 
  


Reply

Tags
iq


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
Block bitmap for group 416 not in group (block 0) + group descriptors corrupted? quanta Linux - Server 1 12-08-2010 11:40 AM
how do i get full ssh block accept my ip adresses R03L Linux - Networking 8 04-23-2009 04:15 AM
How to block several IPs in one command using iptables? Ashkan_s Linux - Software 1 08-20-2008 05:30 PM
iptables: how to block IPs by country or registry mlnutt Linux - Security 4 09-14-2007 01:22 PM
i want to block a range of ips using iptables... Vasili Linux - Security 18 09-19-2006 07:31 AM

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

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