Skip to content

Instantly share code, notes, and snippets.

@dcarley
Created October 21, 2011 13:12
Show Gist options
  • Save dcarley/1303820 to your computer and use it in GitHub Desktop.
Save dcarley/1303820 to your computer and use it in GitHub Desktop.
IPtables negating ports in a rule
[root@puppet ~]# cat /etc/redhat-release
CentOS release 5.7 (Final)
[root@puppet ~]# service iptables stop
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
[root@puppet ~]# iptables -t filter -A INPUT -p tcp -m tcp -m multiport --dports 80,443 -m comment --comment "foo" -j ACCEPT
[root@puppet ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp multiport dports ! 80:443 /* foo */
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment