Firewall: Difference between revisions
From Leo's Notes
This page was last edited on 16 May 2023, at 20:49.
No edit summary |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
Linux typically uses IPTables for its firewall. On most modern Linux distributions, IPTables is controlled through another program or manager such as firewalld, or CSF. | Linux typically uses IPTables for its firewall. On most modern Linux distributions, IPTables is controlled through another program or manager such as firewalld, or CSF. | ||
=== Opening a Port === | === Firewalld === | ||
{| class="wikitable" | |||
! | |||
! | |||
|- | |||
|See whether firewalld is running | |||
|firewall-cmd --state | |||
|- | |||
|List all rules | |||
|firewall-cmd --list-all | |||
|- | |||
|List all zones | |||
|firewall-cmd --list-all-zones | |||
|- | |||
|List all rules in a specific zone | |||
|firewall-cmd --list-all --zone=home | |||
|- | |||
|Allow a specific port | |||
|firewall-cmd --add-port <port-number/port-type> --permanent | |||
|- | |||
|Reload the firewall | |||
|firewall-cmd --reload | |||
|} | |||
==== Opening a Port ==== | |||
To allow a specific port access to your machine, you will (most likely) need to make IPTables {{code|ACCEPT}} traffic meeting the port criteria on the {{code|INPUT}} chain. | To allow a specific port access to your machine, you will (most likely) need to make IPTables {{code|ACCEPT}} traffic meeting the port criteria on the {{code|INPUT}} chain. | ||
| Line 18: | Line 42: | ||
}} | }} | ||
=== CSF === | |||
If using CSF: | If using CSF: | ||
{{highlight|lang=terminal|code= | {{highlight|lang=terminal|code= | ||
| Line 25: | Line 50: | ||
# csf -r | # csf -r | ||
}} | }} | ||
{{Navbox Linux}}[[Category:Linux]] | |||
[[Category:Networking]] | |||
Latest revision as of 20:49, 16 May 2023
Linux
Linux typically uses IPTables for its firewall. On most modern Linux distributions, IPTables is controlled through another program or manager such as firewalld, or CSF.
Firewalld
| See whether firewalld is running | firewall-cmd --state |
| List all rules | firewall-cmd --list-all |
| List all zones | firewall-cmd --list-all-zones |
| List all rules in a specific zone | firewall-cmd --list-all --zone=home |
| Allow a specific port | firewall-cmd --add-port <port-number/port-type> --permanent |
| Reload the firewall | firewall-cmd --reload |
Opening a Port
To allow a specific port access to your machine, you will (most likely) need to make IPTables ACCEPT traffic meeting the port criteria on the INPUT chain.
Simple IPTables:
# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
If using Red Hat's firewalld:
# firewall-cmd --permanent --add-port=80/tcp
# firewall-cmd --permanent --add-service=x
## Reload firewall rules
# firewall-cmd --reload
CSF
If using CSF:
# vi /etc/csf/csf.conf
## Edit 'TCP_IN' to include any TCP traffic IN, or TCP_OUT for traffic out.
## Reload CSF
# csf -r