Skip to content
SIEMBench
100% Client-Side Tool • Inputs Never Sent to Our Servers

Firewall Rule Builder (UFW / iptables / Cisco ACL)

Describe your rules once, put them in order, and copy the commands for UFW, iptables or Cisco IOS. The linter points out risky rules before you apply them.

New rule

allow in tcp from any to any

Ruleset 3

  1. 1. allow in tcp from 198.51.100.0/24 to any port 22

    SSH from admin network

  2. 2. allow in tcp from any to any port 80

    HTTP

  3. 3. allow in tcp from any to any port 443

    HTTPS

Security linter 0

No findings for this ruleset.

    • New rules go after existing ones. Use "ufw insert 1" or "ufw prepend" to place a block first.
    • A rule from any to any also creates an IPv6 rule when IPv6 is enabled in /etc/default/ufw.

    How to use this tool in a SOC investigation

    1. Add a deny rule for the hostile address or range from your alert.
    2. Put it above any allow rule that would match first, and read the linter warnings.
    3. Copy the UFW, iptables or Cisco commands into the change request for review.

    Example: A host at 203.0.113.45 is guessing SSH passwords. Add an inbound TCP deny from 203.0.113.45 to port 22 and move it above the SSH allow rule. If it is left below an allow from any address, the linter reports that it is never reached.

    Frequently asked questions

    Are the rules I build sent anywhere?

    No. Rules are built, checked and exported in your browser with no network requests. The tool cannot reach your firewall either, so nothing changes until you run the commands yourself. Review every line first, because a wrong rule can cut off a server.

    What is the difference between deny and reject?

    Deny drops the packet silently, so the sender waits until it times out. Reject answers with an error, so the sender learns at once. Deny gives scanners less information and is usual at an internet edge. Reject is friendlier inside a network, where a quick error saves troubleshooting time. Cisco IOS ACLs have only deny, and the interface setting "ip unreachables" decides whether an error is sent.

    Why does my UFW or iptables rule seem to be ignored?

    Order is the usual cause. Both read rules from the top and stop at the first match, so an earlier broad rule hides a later specific one. iptables -A and a plain ufw allow both append to the end. List the rules with numbers, and insert the new rule above the one that matches first. The linter marks rules that an earlier rule in the same set already covers.

    Do these rules protect IPv6?

    Only partly. UFW applies a rule from any to any to both IPv4 and IPv6 when IPv6 is enabled in /etc/default/ufw. The iptables commands cover IPv4 only, so the same policy has to be repeated with ip6tables. Cisco IOS needs a separate ipv6 access-list. A host that is closed on IPv4 and open on IPv6 is a common mistake.

    Stateful and stateless filtering

    A stateless filter judges each packet alone. To let a server download updates, it needs one rule for the outgoing request and another for the replies, and the reply rule has to be broad because the client port is random. An attacker who sends packets that look like replies will match it too.

    A stateful filter remembers connections. Linux does this with connection tracking (conntrack), which gives every packet a state. NEW starts a connection, ESTABLISHED belongs to one, and RELATED is connected to one, such as an ICMP error. A single rule then covers every reply:

    iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

    UFW adds this for you. With raw iptables you have to add it, and default deny without it breaks DNS lookups, package updates and every other outbound connection. The linter warns about that combination.

    A Cisco IOS access list is stateless. The established keyword only checks whether a TCP packet has the ACK or RST flag, which a sender can forge, and it does nothing for UDP. Use a zone-based firewall or a dedicated firewall where real connection tracking is needed.

    Rule order in UFW and iptables

    Both tools read rules from the top and stop at the first match. That makes order part of the policy. To allow one network and block everyone else, the allow must come first:

    1. allow tcp from 10.20.0.0/16 to any port 5432
    2. deny  tcp from any          to any port 5432

    Reversed, rule 1 blocks everyone and rule 2 is never reached.

    TaskUFWiptables
    List with numbersufw status numberediptables -L INPUT -n --line-numbers
    Add at the endufw allow ...iptables -A INPUT ...
    Insert at the topufw insert 1 ...iptables -I INPUT 1 ...
    Delete by numberufw delete 3iptables -D INPUT 3
    Default denyufw default deny incomingiptables -P INPUT DROP

    UFW is a front end. It writes iptables or nftables rules and adds sensible ones of its own, including replies, loopback and some ICMP. Avoid mixing hand-written iptables commands with UFW on one host, because the result is hard to reason about. Docker is a frequent surprise. It publishes container ports with its own rules, and traffic to them can bypass UFW entirely.

    Rate limits also differ. ufw limit has a fixed threshold and blocks an address that opens six or more connections within 30 seconds. The iptables export builds the same behavior with the recent module.

    Cisco extended ACLs, wildcard masks and the implicit deny

    An extended access list matches protocol, source, destination and port. Addresses use a wildcard mask, where a 0 bit must match and a 1 bit is ignored. It is the inverse of the subnet mask, so a /24 becomes 0.0.0.255 and a /22 becomes 0.0.3.255. Single addresses are written with host, and everything with any.

    ip access-list extended EDGE-FILTER-IN
     remark SSH from admin network
     permit tcp 198.51.100.0 0.0.0.255 any eq 22
     permit tcp any any range 8000 8080
     deny ip any any log

    Every list ends with an invisible deny ip any any. This implicit deny has two consequences. A list that contains only deny lines blocks all traffic, so a blocklist needs a final permit ip any any, which the export adds. The implicit rule also keeps no counters and logs nothing, so the export writes it out with log when you choose default deny.

    Direction is relative to the interface. in filters packets that arrive at the interface, and out filters packets that leave through it. A list on a router applies to traffic passing through, while UFW and iptables INPUT rules protect the host itself. Remarks are limited to 100 characters, and the export shortens longer comments.

    Applying rules over SSH without locking yourself out

    1. Have another way in. Confirm that a console, hypervisor or cloud serial connection works before you start.
    2. Save the current rules. Use iptables-save > before.rules, or copy the files in /etc/ufw.
    3. Schedule a rollback. Arrange for the old rules to return in a few minutes unless you cancel. On Debian and Ubuntu, iptables-apply does this. Anywhere else, use at:
    echo 'iptables-restore < /root/before.rules' | at now + 5 minutes
    1. Allow SSH first, from the address you are connected from, and set default deny last. The export uses this order.
    2. Test with a second session. Your existing one survives because it is already established, so it proves nothing.
    3. Cancel the rollback with atrm, and then save the rules so they survive a reboot.

    On Cisco IOS, reload in 10 restarts the router with its saved configuration unless you run reload cancel. Do not save until you have tested. Build a new named list and switch the interface to it instead of editing the live one line by line.

    What the linter checks

    The linter sees only this ruleset. It does not know your existing rules, cloud security groups or network address translation. A rate limit on SSH slows guessing but still leaves the service exposed, so it is flagged as well. Prefer a VPN or a management network, with keys instead of passwords.

    Comments are reduced to printable ASCII on one line and quoted for the shell, so a pasted comment cannot run a command. Addresses, ports and names are validated the same way. Presets use documentation addresses, which you need to replace with your own.

    Why is rate limiting missing from the Cisco output?

    An IOS access list can only permit or deny a packet. It has no counter per source. The tool exports the rule as a permit and adds a remark, so you know that the limit is missing. Use policing on an interface, or control plane policing to protect the router itself.