Check whether INPUT contains a rule accepting TCP port 22 without adding or deleting rules.
Which command is appropriate?
iptables -C checks whether a specified rule exists in a chain without changing it.
Detailed explanation
iptables -A INPUT -p tcp --dport 22 -j ACCEPTIncorrect. -A appends the allow rule.
iptables -D INPUT -p tcp --dport 22 -j ACCEPTIncorrect. -D deletes a matching rule.
iptables -L INPUT --dport 22Incorrect. -L does not take --dport as a direct filter in this form.
iptables -C INPUT -p tcp --dport 22 -j ACCEPTCorrect. -C checks for the exact rule.
Try it yourself
An example you can run in a temporary verification environment.
iptables --help 2>&1 | grep -E -- '^-C|check' | head -n 2Expected result
check ruleまたは-Cに関するhelp行Key points
- -C is check
- -A adds
- -D deletes
Notes
- Environment: iptables help / rule変更なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Protected account data
Sensitive authentication data stored separately from ordinary account records.
Service availability
Whether a service can start automatically or be activated on demand.
Packet filter
A host firewall rule set that permits or rejects network packets.