Allow iptables to allow ip range only on specifc port
In this question I see a line like this that will allow me to say “allow these ip addresses to connect”
iptables -A INPUT -m iprange --src-range 10.50.10.20-80 -j ACCEPT
Now, I want to further secure this so that this rule only applies to specific ports. I’ve been using a command like this for my regular ports:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Can I combine these two to make a specific port allowed only for a range, like this
iptables -A INPUT -m iprange --src-range 10.50.10.20-80 --dport 12345 -j ACCEPT
Obviously I’m hesitant to just make iptables calls willy-nilly.
Thanks!
The last line you have in there should work, you just need to make sure you have a
-p protocol in there, as –dport doesn’t work as a option on its own.
iptables -A INPUT -m iprange --src-range 10.50.10.20-80 -p tcp --dport 12345 -j ACCEPT
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





