Search code examples
iptablescentos6

Centos/RH6: iptables rule to allow all ports to specific IP


How do I open all ports to a specific source (inbound) IP address?

I am trying to allow health checking from a monitoring service. When IPtables is off the monitoring server is able to run it's checks, however it fails when IPtables is up.

I've tried creating specific rules for each service/port the monitoring server supposedly uses (ICMP, SNMP, etc), however with these in place the monitoring services are still failing to communicate with the server. This tells me the monitoring service is probably trying to run something outside the documented services/ports, so I'd like to allow it to hit any port/service on the target host.

This is what I have so far, but it's failed (based on this post http://www.webhostingtalk.com/showthread.php?t=338297):

iptables -A INPUT -s 192.168.1.1/32 -p udp -j ACCEPT
iptables -A OUTPUT -d 192.168.1.1/32 -p udp -j ACCEPT

iptables -A INPUT -s 192.168.1.1/32 -p tcp -j ACCEPT
iptables -A OUTPUT -d 192.168.1.1/32 -p tcp -j ACCEPT


Solution

  • I found the following solution works for whatever reason. Perhaps I had a typo elsewhere that I couldn't see...or trying to designate protocols explicitly was breaking something.

    -A INPUT -s 192.168.1.1/32 -j ACCEPT