LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 09-20-2006, 07:07 AM   #1
collen
Member
 
Registered: Jun 2003
Location: /
Distribution: Fedora/Debian
Posts: 86

Rep: Reputation: 15
Iptables multiple ip nrs block/allow


Did find some input oin the form about ip range use in iptables
but it's not what i', looking for..


i need to setup a rule to allow 5 differnt ip's with several services...

now i have to enter every ip into a seperate rule..

can i make a chain of differend ip's ??

-current-

iptables -A INPUT -i eth0 -s 192.168.2.8 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth0 -s 192.168.2.98 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth0 -s 192.168.2.201 -p tcp --dport 80 -j ACCEPT

- want to -

CHAINNAME 192.168.2.8
CHAINNAME 192.168.2.98
CHAINNAME 192.168.2.201

iptables -A INPUT -i eth0 -s CHAINNAME -p tcp --dport 80 -j ACCEPT

like making the CHAINNAME a variable orso ??
this is only for port 80, but i need it for other ports as well..

is there a beter way to insert a block of ip's into ip tables ??

Cheers

Collen
 
Old 09-21-2006, 10:51 AM   #2
Aeiri
Member
 
Registered: Feb 2004
Posts: 307

Rep: Reputation: 30
Looking at your IPs, you could just allow the whole network ("192.168.2.0/24"), but you said you didn't want IP ranges.

If this is a bash file you are adding this to, you could write a quick script that does something like:

Code:
iplist="192.168.2.8 192.168.2.98 192.168.2.201"
for ip in $iplist; do iptables -A INPUT -i eth0 -s $ip -p tcp --dport 80 -j ACCEPT
Also, you said multiple services... you can also do multiple ports in one fell swoop using the "multiport" module, like so:

Code:
iptables -A INPUT -i eth0 -s whatever -p tcp -m multiport --dports 17,23,42,80 -j ACCEPT
 
  


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 whole IP range with iptables jonfa Linux - Security 6 11-19-2008 07:37 AM
IPtables block destination IP mgichoga Linux - Networking 2 05-02-2006 07:22 PM
IPTables and PPTPD :S (to block or not to block) thewonka Linux - Networking 0 03-24-2005 06:58 PM
IPtables - Block all except what I allow ]SK[ Linux - Software 4 02-10-2005 06:14 AM
IPTables to block IP protocol ppuru Linux - Security 3 06-26-2004 02:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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