Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| firewalld [2019/02/15 17:09] – [General] admin | firewalld [2020/05/17 08:47] (current) – [IPSET] dani | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| **IMPORTANT: | **IMPORTANT: | ||
| - | **NOTE:** To the most arguments, you can add '' | + | **NOTE:** To the most arguments, you can add '' |
| * List all options for '' | * List all options for '' | ||
| Line 319: | Line 319: | ||
| **IMPORTANT: | **IMPORTANT: | ||
| + | |||
| + | |||
| + | ===== Direct rules ===== | ||
| + | In some cases, a role is not possible to implement using standard firewalld command (including rich rules). In such a case, you can add direct rules (syntax of the corresponding firewall: '' | ||
| + | |||
| + | <WRAP center round tip 60%> | ||
| + | Check, if the rule in that sequence where you expect it (the sequence of rules is very important! You can use '' | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | You should not use direct rules, if you can do the same using other firewalld rules! | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ==== List all active direct rules ==== | ||
| + | |||
| + | <code bash> | ||
| + | firewall-cmd --direct --get-all-rules | ||
| + | </ | ||
| + | |||
| + | ==== Add a direct rule ==== | ||
| + | The syntax how-to add a direct rule is quite similar to the backend firewall (iptables, ebtables or nftables). Here an example: | ||
| + | |||
| + | <code bash> | ||
| + | firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 1 -i ens192 -j DROP | ||
| + | firewall-cmd --direct --add-rule ipv4 filter FORWARD 1 -i ens192 -j DROP | ||
| + | </ | ||
| + | |||
| + | Description (based on '' | ||
| + | |||
| + | <code bash> | ||
| + | firewall-cmd --direct --add-rule < | ||
| + | </ | ||
| + | ==== Remove a direct rule ==== | ||
| + | To remove a rich rule, the syntax is the same, except '' | ||
| + | |||
| + | <code bash> | ||
| + | firewall-cmd --permanent --direct --remove-rule ipv4 filter FORWARD 1 -i ens192 -j DROP | ||
| + | firewall-cmd --direct --remove-rule ipv4 filter FORWARD 1 -i ens192 -j DROP | ||
| + | </ | ||
| =====Forwarding ports===== | =====Forwarding ports===== | ||
| Line 336: | Line 377: | ||
| =====IPSET===== | =====IPSET===== | ||
| + | **Very important: | ||
| + | |||
| To setup a blacklist using ipset, you have to follow this example: | To setup a blacklist using ipset, you have to follow this example: | ||
| - If you want to add first an old (active) '' | - If you want to add first an old (active) '' | ||
| - | ipset save blockednets > blockednets.ipset | + | ipset save blockednets > ipsetsavelist.ipset |
| - | sed -e ' | + | sed -e ' |
| </ | </ | ||
| - Create the ' | - Create the ' | ||
| Line 350: | Line 393: | ||
| - Optionally add additional networks:< | - Optionally add additional networks:< | ||
| firewall-cmd --permanent --ipset=blockednets --add-entry=119.6.204.0/ | firewall-cmd --permanent --ipset=blockednets --add-entry=119.6.204.0/ | ||
| - | </ | ||
| - | - Optionally check the ipset list:< | ||
| - | firewall-cmd --ipset=blockednets --get-entries | ||
| </ | </ | ||
| - Shows the permanent entries in a ipset:< | - Shows the permanent entries in a ipset:< | ||