LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Allow more than one ip through specific port ? (https://www.linuxquestions.org/questions/linux-newbie-8/allow-more-than-one-ip-through-specific-port-914357/)

shipon_97 11-19-2011 02:22 AM

Allow more than one ip through specific port ?
 
Friends,

I can allow only one ip through specific port like the below way :

iptables -I INPUT \! --src 192.168.0.1 -m tcp -p tcp --dport 3000 -j DROP

But Now If I want to do the above restriction for more than one IP (like, 0.1, .0.2, 0.3) and reject all other ip , then how can I write the above rules .

Plz help ... ...

fukawi1 11-19-2011 02:32 AM

You can do it using the iprange module...

Quote:

iprange match options:
[!] --src-range ip[-ip] Match source IP in the specified range
[!] --dst-range ip[-ip] Match destination IP in the specified range

unSpawn 11-19-2011 04:16 AM

...and another option could be to use the "recent" module and then echo IP addresses into /etc/proc/net/ipt_recent/${LISTNAME}. 'man iptables' (search for "recent") for details.

shipon_97 11-20-2011 12:14 AM

Block a port for specific ips!
 
Thx fukawi1...

I give the below command to enable a series of IP to nrowse using 3000 port :

"iptables -A INPUT -m iprange --src-range 192.168.0.36-192.168.0.56 -p tcp --dport 3000 -j ACCEPT"

But it is not working . using the above rules everybody can use 3000 port . But If I use below :

"iptables -A INPUT -m iprange --src-range 192.168.0.36-192.168.0.56 -p tcp --dport 3000 -j REJECT"
Then its working ,the above ip's are not connected with 3000 port for 36 to 56 ip range .

Actually I want the above first one condition where I can give the acceptance some few ip (like 192.168.0.2,192.168.0.30,192.168.0.34) and reject all other ip . Would you plz help me giving example.
I am grateful to u ... ...


All times are GMT -5. The time now is 08:38 PM.