Open A Port Or Service - FirewallD

  • Menu
  • Menu
  • Home
  • Blog
  • Community
  • Contribute
  • Documentation
    • Concepts
    • Architecture
    • Configuration
      • Directories
      • Runtime versus Permanent
      • firewalld.conf
    • Utilities
      • firewall-cmd
      • firewall-offline-cmd
      • firewall-config
      • firewall-applet
    • The daemon: firewalld
    • Zone
      • Predefined Zones
      • Connections, Interfaces and Sources
      • Configuration of Zones
      • Default Zone
      • Use of Zones
      • Options
      • Examples
    • Service
      • Options
      • Examples
    • IPSet
      • Options
      • Examples
    • Helper
      • Options
      • Examples
    • ICMP Type
      • Options
      • Examples
    • Direct Interface
      • Options
      • Examples
    • HowTo
      • Enable and Disable firewalld
      • Get firewalld State
      • Reload firewalld
      • Open a Port or Service
      • Add a Service
      • Debug firewalld
    • Manual Pages
      • firewalld(1)
      • firewall-cmd(1)
      • firewall-offline-cmd(1)
      • firewall-config(1)
      • firewall-applet(1)
      • firewalld.conf(5)
      • firewalld.zones(5)
      • firewalld.zone(5)
      • firewalld.policies(5)
      • firewalld.policy(5)
      • firewalld.service(5)
      • firewalld.ipset(5)
      • firewalld.helper(5)
      • firewalld.icmptype(5)
      • firewalld.richlanguage(5)
      • firewalld.direct(5)
      • firewalld.lockdown-whitelist(5)
      • firewalld.dbus(5)
    • External Resources
    • Working With The Source
  • Download
    • All Releases
  • Search
  • Documentation
  • HowTo
Open a Port or Service

There are different ways to open up a port (range) or service. These ways depend on the use case and the number of changes that are needed to make it work.

A simple port number or port range can be used in the cases where no additional changes are needed. For example, with opening port 80/tcp to allow access to a local http servicer on the standard port. For most of the more important services there is already a service defined in firewalld. Then there is no need to know about the default port number(s). The service can then simply be enabled in the used zone.

If there is a need to open different ports or to do additional changes, then using a service might be simpler. If you need to add a new or custom service, then please have a look at the howto “Add a Service”. It is also possible to adapt a builtin service according to the user’s needs, for example to change one of the used ports. But it is recommended to generate a new service in this case to make it more obvious that the service has been customized.

How to open port 80/tcp with firewall-cmd:

firewall-cmd --zone=public --add-port=80/tcp

This will open the port 80 with protocol tcp in the public zone of the runtime environment. The runtime environment is only effective until the machine has been rebooted or the firewalld service has been restarted. The zone option can be omitted here if the port should be added to the default zone.

firewall-cmd --permanent --zone=public --add-port=80/tcp

If you want to make this a permanent change also, then open the port also in the permanent environment. This means the port will be open also after a system reboot or firewalld service reload.

How to open a service with firewall-cmd:

firewall-cmd --zone=public --add-service=http

This opens the service in the public zone of the runtime environment.

firewall-cmd --permanent --zone=public --add-service=http

This also opens the service in public zone of the permanent environment.

Recent Posts

  • Policy Sets: A Home Router in Four commands
  • Strict Forward Ports
  • Strict Filtering of Docker Containers
  • firewalld 2.1.0 release
  • firewalld 2.0.0 release

Quick Links

  • Report a new issue
  • Browse issues

Tag » How To Open A Port On Linux