troubleshooting Question

iptables - allow all but block one port to certain clients

Avatar of projects
projects asked on
LinuxLinux NetworkingLinux Security
63 Comments1 Solution1295 ViewsLast Modified:
I was given the following which is meant to NOT block anything on the server but, allow access to a certain port, 8443, only to certain IPs.
I haven't been able to get this to run on my server because I don't know enough about iptables. If someone could format this into a complete iptables file I could cut, paste, and start on my server, that would be most welcome.

# iptables --flush

# allow 192.168.1.5 tto 192.168.1.9 to access server port 8443

iptables -A INPUT -p tcp --src 192.168.1.5 --dport 8443 -j ACCEPT
iptables -A INPUT -p tcp --src 192.168.1.6 --dport 8443 -j ACCEPT
iptables -A INPUT -p tcp --src 192.168.1.7 --dport 8443 -j ACCEPT
iptables -A INPUT -p tcp --src 192.168.1.8 --dport 8443 -j ACCEPT
iptables -A INPUT -p tcp --src 192.168.1.9 --dport 8443 -j ACCEPT

# allow loopback to acces server
iptables -A INPUT -p tcp --src 127.0.0.1 --dport 8443 -j ACCEPT

# ignore requests from all other IPs
iptables -A INPUT -p tcp --dport 8443 -j DROP

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 63 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 63 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros