Support for iptables
Append a rule to the specified table/chain.
CLI Example:
salt '*' iptables.append filter INPUT rule='-m state --state RELATED,ESTABLISHED -j ACCEPT'
Build a well-formatted iptables rule based on kwargs. Long options must be used (--jump instead of -j) because they will have the -- added to them. A table and chain are not required, unless full is True.
If full is True, then table, chain and command are required. command may be specified as either a short option ('I') or a long option (--insert). This will return the iptables command, exactly as it would be used from the command line.
If a position is required (as with -I or -D), it may be specified as position. This will only be useful if full is True.
If connstate is passed in, it will automatically be changed to state.
CLI Examples:
salt '*' iptables.build_rule match=state connstate=RELATED,ESTABLISHED \
jump=ACCEPT
salt '*' iptables.build_rule filter INPUT command=I position=3 \
full=True match=state state=RELATED,ESTABLISHED jump=ACCEPT
Check for the existance of a rule in the table and chain
CLI Example:
salt '*' iptables.check filter INPUT rule='-m state --state RELATED,ESTABLISHED -j ACCEPT'
CLI Examples:
salt '*' iptables.delete filter INPUT position=3
salt '*' iptables.delete filter INPUT rule='-m state --state RELATED,ESTABLISHED -j ACCEPT'
Flush all chains in the specified table.
CLI Example:
salt '*' iptables.flush filter
Return the current policy for the specified table/chain
CLI Example:
salt '*' iptables.get_policy filter INPUT
Return a data structure of the current, in-memory rules
CLI Example:
salt '*' iptables.get_rules
Return the current policy for the specified table/chain
CLI Examples:
salt '*' iptables.get_saved_policy filter INPUT
salt '*' iptables.get_saved_policy filter INPUT conf_file=/etc/iptables.saved
Return a data structure of the rules in the conf file
CLI Example:
salt '*' iptables.get_saved_rules
Insert a rule into the specified table/chain, at the specified position.
CLI Examples:
salt '*' iptables.insert filter INPUT position=3 rule='-m state --state RELATED,ESTABLISHED -j ACCEPT'
Save the current in-memory rules to disk
CLI Example:
salt '*' iptables.save /etc/sysconfig/iptables
Set the current policy for the specified table/chain
CLI Example:
salt '*' iptables.set_policy filter INPUT ACCEPT
Return version from iptables --version
CLI Example:
salt '*' iptables.version