From wikistone
Jump to: navigation, search
(Created page with "==Quick Set== Make permanent: <pre>firewall-cmd --runtime-to-permanent</pre> or <pre>firewall-cmd --add-service=xxx --premanent</pre> -note: Note immediately active. Reset to...")
 
Line 1: Line 1:
 
==Quick Set==
 
==Quick Set==
−
Make permanent:
+
===Make Permanent===
 
<pre>firewall-cmd --runtime-to-permanent</pre>
 
<pre>firewall-cmd --runtime-to-permanent</pre>
 
or
 
or
 
<pre>firewall-cmd --add-service=xxx --premanent</pre>
 
<pre>firewall-cmd --add-service=xxx --premanent</pre>
−
-note: Note immediately active.
+
-note: Making a change with "permanent" is not immediately active.
  
−
Reset to perm rules:
 
−
</pre>firewall-cmd --reload</pre>
 
  
−
List stuff:
+
===Reset To Perm Rules===
 +
<pre>firewall-cmd --reload</pre>
 +
 
 +
 
 +
===List Stuff===
 
<pre>
 
<pre>
 
firewall-cmd --list-all-zones
 
firewall-cmd --list-all-zones
Line 15: Line 17:
 
</pre>
 
</pre>
  
−
Add / remove stuff:
+
 
−
Add:
+
===Add / Remove Stuff===
 +
====Add====
 
<pre>
 
<pre>
 
firewall-cmd --add-service=
 
firewall-cmd --add-service=
Line 22: Line 25:
 
firewall-cmd --add-protocol= {protocol name, eg: smb2}
 
firewall-cmd --add-protocol= {protocol name, eg: smb2}
 
</pre>
 
</pre>
−
Remove:
+
 
 +
 
 +
====Remove====
 
<pre>firewall-cmd --remove ...</pre>
 
<pre>firewall-cmd --remove ...</pre>
  
−
Zones:
+
 
 +
 
 +
==Zones==
 
<pre>
 
<pre>
 
firewall-cmd --get-zones
 
firewall-cmd --get-zones
Line 38: Line 45:
 
</pre>
 
</pre>
  
−
Custom services:
+
Default Zone: If no zone is specified, the default zone is assumed.
 +
 
 +
To set a target zone for subsequent commands, declare a target zone:
 +
<pre>
 +
firewall-cmd --set-target=DROP
 +
firewalld-cmd --~blablabla~
 +
</pre>
 +
 
 +
 
 +
==Custom Services==
 
Clone/add and edit here: /usr/lib/firewalld/services
 
Clone/add and edit here: /usr/lib/firewalld/services
 
<pre>
 
<pre>
Line 54: Line 70:
 
<pre>firewall-cmd --zone=drop --add-icmp-block-inversion --permanent</pre>
 
<pre>firewall-cmd --zone=drop --add-icmp-block-inversion --permanent</pre>
  
−
ICMP Services:
+
 
 +
===ICMP Stuff===
 +
<pre>
 +
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>
 +
</pre>
 +
 
 +
 
 +
===ICMP Services===
 
<pre>firewall-cmd --get-icmptypes</pre>
 
<pre>firewall-cmd --get-icmptypes</pre>
 
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
 
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===
 +
<pre>
 +
firewall-cmd --add-masquerade
 +
firewall-cmd --remove-masquerade
 +
firewall-cmd --zone {zone} --query-masquerade
 +
</pre>
 +
 +
 +
===Port Forwarding===
 +
<pre>firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=12345 (-–permanent)</pre>
 +
 +
 +
===Tort Forwarding To Other IP===
 +
<pre>firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=10.1.2.3:12345 (--permanent)</pre>
 +
 +
 +
 +
==Lockdown==
 +
Lockdown prevents changes to the firewall by services.
 +
<pre>firewall-cmd --lockdown=on</pre>
 +
Allowing services individually...
 +
<pre># firewall-cmd --add-lockdown-whitelist-command='/usr/bin/python -Es /usr/bin/firewall-cmd*' [--permanent]</pre>
 +
 +
 +
 +
==CONFIG==
 +
'''/etc/firewalld/firewalld.conf'''
 +
<pre>
 +
DefaultZone=dmz
 +
</pre>
 +
 +
 +
'''/etc/sysconfig/network-scripts/ifcfg-xxx'''
 +
<pre>
 +
 +
</pre>

Revision as of 16:03, 20 July 2021

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