iptables

Collection: builtin

Full Name: parallax.builtin.iptables

Aliases: ansible.builtin.iptables, iptables

Synopsis

Manage iptables

Parameters

NameTypeRequiredDefaultDescription
tablestringfilterThis option specifies the packet matching table Choices: filter, nat, mangle, raw, security
statestringpresentWhether the rule should be absent or present Choices: absent, present
actionstringappendWhether the rule should be appended at the bottom or inserted at the top Choices: append, insert
rule_numstringInsert the rule as the given rule number
ip_versionstringipv4Which version of the IP protocol this rule should apply to Choices: ipv4, ipv6
chainstringyesSpecify the iptables chain
protocolstringThe protocol of the rule or of the packet to check
sourcestringSource specification
destinationstringDestination specification
tcp_flagsmapTCP flags specification
jumpstringThis specifies the target of the rule
gotostringThis specifies that the processing should continue in a user specified chain
in_interfacestringName of an interface via which a packet was received
out_interfacestringName of an interface via which a packet is going to be sent
fragmentstringThis means that the rule only refers to second and further fragments of fragmented packets
set_countersstringThis enables the administrator to initialize the packet and byte counters of a rule
source_portstringSource port or port range specification
destination_portstringDestination port or port range specification
to_portsstringThis specifies a destination port or range of ports to use
to_destinationstringThis specifies a destination address to use with DNAT
to_sourcestringThis specifies a source address to use with SNAT
synstringThis allows matching packets that have the SYN bit set and the ACK and RST bits unset Choices: ignore, match, negate
set_dscp_markstringThis allows specifying a DSCP mark to be added to packets
set_dscp_mark_classstringThis allows specifying a DSCP mark to be added to packets
commentstringThis specifies a comment that will be attached to the rule
ctstatelistctstate is a list of the connection states to match in the conntrack module
src_rangestringSpecifies a range of source addresses
dst_rangestringSpecifies a range of destination addresses
matchlistSpecifies a match to use
limitstringSpecifies the maximum average number of matches to allow per second
limit_burststringSpecifies the maximum burst before the above limit kicks in
uid_ownerstringSpecifies the UID or username to use in match by owner rule
gid_ownerstringSpecifies the GID or group to use in match by owner rule
reject_withstringSpecifies the error packet type to return while rejecting
icmp_typestringThis allows specification of the ICMP type
flushboolfalseFlushes the specified table and chain of all rules
policystringSet the policy for the chain to the given target Choices: ACCEPT, DROP, QUEUE, RETURN
waitstringWait for the xtables lock
chain_managementboolfalseIf true, the chain will be created if needed
numericboolfalseThis option makes iptables print numerical addresses and port numbers

Example

- name: Example iptables task
  iptables:
    chain: <your_chain>