From wikistone
Revision as of 16:04, 20 July 2021 by Bill (talk | contribs)
Jump to: navigation, search

Quick Set

Make Permanent

firewall-cmd --runtime-to-permanent

or

firewall-cmd --add-service=xxx --premanent

-note: Making a change with "permanent" is not immediately active.


Reset To Perm Rules

firewall-cmd --reload


List Stuff

firewall-cmd --list-all-zones
firewall-cmd --zone={zone} --list-all


Add / Remove Stuff

Add

firewall-cmd --add-service=
firewall-cmd --add-port= {n}/{tcp|udp}
firewall-cmd --add-protocol= {protocol name, eg: smb2}


Remove

firewall-cmd --remove ...


Zones

firewall-cmd --get-zones
firewall-cmd --get-active-zones

firewall-cmd --set-default-zone={zone}

firewall-cmd --zone={zone} --add-interface={ifname}
firewall-cmd --zone={zone} --change-interface={ifname}
firewall-cmd --zone={zone} --remove-interface={ifname}
firewall-cmd --zone={zone} --query-interface={ifname}

Default Zone: If no zone is specified, the default zone is assumed.

To set a target zone for subsequent commands, declare a target zone:

firewall-cmd --set-target=DROP
firewalld-cmd --~blablabla~


Custom Services

Clone/add and edit here: /usr/lib/firewalld/services

<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>SSH</short>
  <port protocol="tcp" port="22"/>
</service>


ICMP Inversion

What is blocked is allowed. What is allowed is blocked. Enable to allow all ICMP.

firewall-cmd --zone=drop --add-icmp-block-inversion --permanent


ICMP Stuff

firewall-cmd --get-icmptypes
firewall-cmd --info-icmptype=<icmptype>
firewall-cmd --query-icmp-block=<icmptype>
firewall-cmd --add-icmp-block=<icmptype>
firewall-cmd --remove-icmp-block=<icmptype>


ICMP Services

firewall-cmd --get-icmptypes

address-unreachable bad-header communication-prohibited destination-unreachable echo-reply echo-request fragmentation-needed host-precedence-violation host-prohibited host-redirect host-unknown host-unreachable ip-header-bad neighbour-advertisement neighbour-solicitation network-prohibited network-redirect network-unknown network-unreachable no-route packet-too-big parameter-problem port-unreachable precedence-cutoff protocol-unreachable redirect required-option-missing router-advertisement router-solicitation source-quench source-route-failed time-exceeded timestamp-reply timestamp-request tos-host-redirect tos-host-unreachable tos-network-redirect tos-network-unreachable ttl-zero-during-reassembly ttl-zero-during-transit unknown-header-type unknown-option


Masquerade & Forwarding

Forwarding requires masquerading being turned on!

Masquerading

firewall-cmd --add-masquerade
firewall-cmd --remove-masquerade
firewall-cmd --zone {zone} --query-masquerade


Port Forwarding

firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=12345 (-–permanent)


Tort Forwarding To Other IP

firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=10.1.2.3:12345 (--permanent)


Lockdown

Lockdown prevents changes to the firewall by services.

firewall-cmd --lockdown=on

Allowing services individually...

# firewall-cmd --add-lockdown-whitelist-command='/usr/bin/python -Es /usr/bin/firewall-cmd*' [--permanent]


CONFIG

/etc/firewalld/firewalld.conf

DefaultZone=dmz


/etc/sysconfig/network-scripts/ifcfg-xxx

ZONE=public