102 votes
Accepted

How to open port for a specific IP address with firewall-cmd on CentOS?

Try this command firewall-cmd --permanent --zone=public --add-rich-rule=' rule family="ipv4" source address="1.2.3.4/32" port protocol="tcp" port="4567" accept' Check the zone file later to ...
88 votes

How to open port for a specific IP address with firewall-cmd on CentOS?

Create a new zone to accommodate this configuration. FirewallD zones are defined by source addresses and by interfaces. firewall-cmd --new-zone=special --permanent firewall-cmd --reload firewall-cmd -...
38 votes
Accepted

block all but a few ips with firewalld

The rich rules aren't necessary at all. If you want to restrict a zone to a specific set of IPs, simply define those IPs as sources for the zone itself (and remove any interface definition that may be ...
35 votes
Accepted

CentOS 7 firewall-cmd not found

Two possible options Your PATH does not contain /usr/bin firewall-cmd is not installed yum install firewalld
  • 115k
35 votes

CentOS 7 firewall-cmd not found

Looks to me like you don't have it installed/enabled. yum install firewalld systemctl unmask firewalld systemctl enable firewalld systemctl start firewalld
28 votes
Accepted

Is there a way to run just save with firewalld in RHEL7?

The version of firewalld in RHEL 7.0 has no "save" script and no way to copy the running firewall configuration to the permanent configuration. You save a firewall change with firewalld by adding --...
27 votes
Accepted

Debugging iptables and common firewall pitfalls?

In general: Viewing and modifying the firewall configuration requires administrator privileges (root) as does opening services in the restricted port number range. That means that you should either be ...
  • 74.1k
25 votes
Accepted

open all ports to specific IP with firewalld

Use a firewalld zone for this. Zones can be specified either by interface or by source IP address. In fact, by default, a zone which accepts all traffic already exists, and it is named trusted. By ...
17 votes
Accepted

Block ICMP timestamp & timestamp reply with firewalld

firewalld ships with a default set of predefined ICMP types you can use out of the box: # firewall-cmd --get-icmptypes destination-unreachable echo-reply echo-request parameter-problem redirect ...
  • 15k
17 votes

Debugging iptables and common firewall pitfalls?

Iptables/Firewall "introduction" A Firewall is basically a policy-based network filter. Linux firewalls are built around Netfilter; the kernel's network packet processing framework which is made of ...
  • 3,409
15 votes

firewalld vs iptables - when to use which

As firewalld is based on XML configuration, some might think that it's easier to configure the firewall in a programmatic manner. This can be achieved by iptables just as well, but with a different ...
11 votes

Is there a way to rate limit connection attempts with firewalld?

Try with: firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT_direct 0 -p tcp --dport 22 -m state --state NEW -m recent --set firewall-cmd --permanent --direct --add-rule ipv4 filter ...
11 votes
Accepted

firewalld: if I change the ssh service port, is it enough to allow the new port number, or should I add a new service?

I assume the port 22 is hardcoded in the ssh service definition for firewalld On my CentOS/Fedora systems the default service definitions are stored in xml files in /usr/lib/firewalld/services. The ...
  • 115k
11 votes
Accepted

How to check if firewalld is blocking an incoming ip address?

First, I strongly recommend that you use banaction = firewallcmd-ipset as this will provide much better performance when the ban list starts getting large. Now, with any of fail2ban's firewalld ...
11 votes

FirewallD : Allow connections only from certain IP addresses

Rich rules aren't the way to go about this. They'll just create confusion, now and later. Understand that a firewalld zone corresponds to a set of services that you may wish to allow, and the sources ...
11 votes
Accepted

firewalld is not working in CentOS 8: no rule at all is created in iptables

Because you don't see any iptables rule, doesn't mean firewalld is not working. Actually firewalld switched to using nftables as backend. So you can find your rules with for example: nft list ruleset ...
  • 9,670
10 votes
Accepted

centOS 7 firewallD remove direct rule

Eventually I find the remove command only work at one-time due to the rules are recorded in the direct.xml Thus, the solution is easy, edit the direct.xml and comment the corresponded lines or jsut ...
  • 564
10 votes
Accepted

firewalld not listing any active zones?

You activate a zone by binding a network interface or source IP address range(s) to it. Any firewall rules in the zone then apply to that network interface or IP address range(s).
9 votes

Alternative to Firewalld on memory critical servers?

Yes, you can use the old system. It's not less secure than firewalld (provided you write your firewall rules correctly). It also doesn't run a daemon, so it's not using a (relatively) large amount of ...
9 votes

Allow all rule for one interface using firewalld

The natural way is setting the right target to your zone: firewall-cmd --permanent --zone=YOUR_ZONE --set-target=ACCEPT Set the target of a permanent zone. target is one of: default, ACCEPT, DROP, %...
  • 91
8 votes

Allowing passive FTP connections in FirewallD (CentOS 7)

I did not researched the issue throughly, so I do not understand the details, but it seems this has something to do with how the active - passive connections are setup both for vsftpd on the server ...
  • 81
8 votes
Accepted

Firewalld blocks IPv6, ignores config

I ran into the same issue. After following the logic through the rules that firewalld puts in I found that the drop zone was blocking ipv6 icmp that is needed to find the ipv6 neighbors. There is a ...
  • 106
8 votes

firewalld stop outgoing traffic to a particular ip address

I don't like debugging firewall issues from a front-end and prefer to look at the actual rule sets with [sudo] iptables -L -v -n or [sudo] iptables-save. I think that will show that your rich rule is ...
  • 74.1k
7 votes

Access denied trying to enable or unmask firewalld

solution sudo systemctl unmask --now firewalld sudo systemctl enable firewalld sudo systemctl start firewalld
7 votes

Debugging iptables and common firewall pitfalls?

Common issues with different protocols DNS: DNS uses port 53 UDP by default, but messages that won't fit in a single UDP datagram will be transmitted using TCP instead (typically zone transfers and ...
  • 74.1k
7 votes
Accepted

Firewalld management

This looks like your problem: internal (active) interfaces: eth0 sources: 192.168.0.0/24 If you specify both interfaces and source IP addresses for a zone, then that zone matches for traffic ...
6 votes
Accepted

How to block an ip range in Firewalld

I am not a user of firewalld myself, but for most firewall implementations, particularly linux-based ones, whenever you see the option for a source or destination address you can simply provide a CIDR ...
  • 130k
6 votes
Accepted

Can multiple firewalld zones be active at any given time?

From my recent experience, you can have A DEFAULT zone Zones bound to (a) interface(s) So if you have multiple interfaces you can assign each to its own zone or all interfaces to one zone, ...
  • 468
6 votes
Accepted

How to create advanced rules with firewall-cmd?

You don't need to add or even have custom direct chains (though you can if you want to get really complicated. Just add to your existing chains directly. After IP version, table, chain and priority, ...
6 votes
Accepted

Firewall missing from AWS MarketPlace Centos7 image

You get exactly the image the description says: ... built with a minimal profile ... The image contains just enough packages to run within AWS, bring up an SSH Server and allow users to login. A ...
  • 74.1k

Only top scored, non community-wiki answers of a minimum length are eligible