SSL and security
What is a DDoS attack?
A DDoS attack uses many machines to flood one target with traffic until it cannot respond. Learn how it works, the main types and how to reduce the damage.
· Mateo Cardenas
HomeGuidesSSL and securityWhat is a firewall and how does it work?
NIST defines a firewall as a device or program that controls the flow of network traffic between networks or hosts that employ differing security postures.1, source 1 RFC 2979 describes it as an agent that screens network traffic in some way, blocking traffic it believes to be inappropriate, dangerous, or both.2, source 2 CISA says firewalls provide protection against outside cyber attackers by shielding your computer or network from malicious or unnecessary network traffic.3, source 3
NIST also defines a firewall as a gateway that limits access between networks in accordance with local security policy.1, source 1 In another of its definitions, a firewall sits at the junction point or gateway between two networks, usually a private network and a public network such as the Internet.1, source 1 Another NIST definition says a firewall restricts data communication traffic to and from one of the connected networks, the one said to be inside the firewall, and so protects that network's system resources against threats from the network outside it.1, source 1 Security concerns about direct paths between the Internet and an internal network are often dealt with by inserting one or more firewalls on the path between them.2, source 2
When a computer is accessible through an internet connection or Wi-Fi network, it is susceptible to attack.3, source 3 A firewall lets you restrict outside access to your computer.3, source 3
Firewalls can also prevent malicious software from accessing a computer or network via the internet.3, source 3 They can be configured to block data from certain locations (computer network addresses), applications, or ports while allowing relevant and necessary data through.3, source 3 Firewall functions are disjoint from network address translation (NAT) functions, so neither implies the other, although sometimes one device provides both.2, source 2
A firewall either acts as a protocol end point and relay, acts as a packet filter, or does some combination of both.2, source 2 An SMTP client or server and a Web proxy agent are examples of a firewall acting as a protocol end point and relay.2, source 2 When a firewall acts as a protocol end point, it may perform extensive protocol validity checks.2, source 2 A firewall acting as a packet filter is not visible as a protocol end point.2, source 2
A packet-filtering firewall examines each packet and then passes it through to the other side unchanged, drops it entirely, or handles the packet itself in some way.2, source 2 Firewalls typically base some of their decisions on IP source and destination addresses and port numbers.2, source 2 A firewall may block packets from the Internet side that claim a source address of a system on the internal network.2, source 2 It may block TELNET or RLOGIN connections from the Internet to the internal network.2, source 2
A firewall may also require the use of an access negotiation and encapsulation protocol such as SOCKS to gain access to the Internet, the internal network, or both.2, source 2 On Linux, the kernel includes the netfilter subsystem, which is used to manipulate or decide the fate of network traffic headed into or through your server.4, source 4 All modern Linux firewall solutions use the netfilter system for packet filtering.4, source 4 When a packet reaches your server it is handed to the netfilter subsystem for acceptance, manipulation, or rejection based on the rules supplied from userspace via iptables.4, source 4
On Ubuntu, a terminating rule is a rule with a target that decides the fate of the packet, such as ACCEPT, DROP, or REJECT.4, source 4 firewalld policies apply firewall rules in a stateful, unidirectional manner.5, source 5 With firewalld you only need to consider one direction of the traffic, because the traffic's return path is implicitly allowed by its stateful filtering.5, source 5
Categories of firewalls include hardware and software.3, source 3 CISA says the decision to use a firewall is more important than deciding which type you use.3, source 3 Hardware firewalls are typically called network firewalls and are physical devices positioned between your computer and the internet or another network connection.3, source 3 Hardware-based firewalls are particularly useful for protecting multiple computers and controlling the network activity that attempts to pass through them.3, source 3
The advantage of hardware-based firewalls is that they provide an additional line of defense against attacks reaching desktop computing systems.3, source 3 The disadvantage of hardware-based firewalls is that they are separate devices that require trained professionals to support their configuration and maintenance.3, source 3
Most operating systems include a built-in firewall feature, and CISA says you should enable it for added protection, even if you have an external firewall.3, source 3 The advantage of software firewalls is their ability to control the specific network behavior of individual applications on a system.3, source 3 A significant disadvantage of a software firewall is that it is typically located on the same system that is being protected.3, source 3 With a software firewall on each computer in a network, you need to update and manage each computer's firewall individually.3, source 3
DigitalOcean Cloud Firewalls are a network-based, stateful firewall service for Droplets.6, source 6 They block all traffic that isn't expressly permitted by a rule.6, source 6 Their rules support an action of allow or deny, and deny rules take precedence over allow rules that match the same traffic.6, source 6
The default firewall configuration tool for Ubuntu is ufw.4, source 4 ufw was developed to ease iptables firewall configuration, and provides a user-friendly way to create an IPv4 or IPv6 host-based firewall.4, source 4 ufw is mainly used for host-based firewalls.4, source 4
ufw is not intended to provide complete firewall functionality via its command interface, but instead provides an easy way to add or remove simple rules.4, source 4 On Ubuntu, ufw is initially disabled by default.4, source 4
sudo ufw enable from a terminal prompt.4, source 4sudo ufw disable.4, source 4sudo ufw allow 22.4, source 4sudo ufw deny 22 for port 22.4, source 4With ufw, the command sudo ufw allow proto tcp from 192.168.0.2 to any port 22 allows SSH access from host 192.168.0.2 to any IP address on the machine.4, source 4 Replacing 192.168.0.2 with 192.168.0.0/24 allows SSH access from the entire subnet.4, source 4 Adding the --dry-run option to a ufw command outputs the resulting rules but does not apply them.4, source 4
Applications that open ports can include a ufw profile that details the ports the application needs, and the profiles are kept in /etc/ufw/applications.d.4, source 4 With a ufw application profile, you do not need to specify the protocol for the application, because that information is detailed in the profile.4, source 4
Firewall logs are essential for recognizing attacks, troubleshooting your firewall rules, and noticing unusual activity on your network.4, source 4 On Ubuntu, logging rules must be included in your firewall for logs to be generated, and they must come before any applicable terminating rule.4, source 4 To turn on logging with ufw, run sudo ufw logging on.4, source 4
firewalld is a simple, stateful, zone-based firewall.5, source 5 In firewalld, policies and zones are used to organize firewall rules.5, source 5 The network is logically divided into zones, and the traffic flowing between them can be governed by policies.5, source 5 Traffic ingresses one and only one zone, and traffic egresses one and only one zone.5, source 5
A zone defines a level of trust.5, source 5 Traffic within the same zone (intra-zone) is allowed by default, and traffic from zone to zone (inter-zone) is denied by default.5, source 5 Zones implicitly provide a policy for traffic destined to the host running firewalld (input).5, source 5
This implicit zone policy is useful for simple use cases where end-stations provide services, such as a web server, and explicit policies are not necessary there.5, source 5 To allow https for clients in the internal zone, run firewall-cmd --permanent --zone internal --add-service https and then firewall-cmd --reload.5, source 5 The reload makes the runtime and permanent configurations identical.5, source 5
Policies may apply firewall rules to all traffic types, including filtering input, forwarded, and output traffic and performing network address translations (NAT).5, source 5 Policies are associated with an ingress zone and an egress zone.5, source 5 The ingress zone is where the traffic originated (received), and the egress zone is where the traffic leaves (sent).5, source 5
Setting the default target of a policy to ACCEPT with --set-target allows all traffic, such as letting the internal zone access the internet.5, source 5 A strict network may allow only a subset of traffic, such as only http and https, and other traffic is rejected.5, source 5
The runtime configuration does not persist after a firewalld reload or restart, and at startup it is populated from the permanent configuration.5, source 5 During a firewalld reload, existing connections are maintained and experience no traffic interruption.5, source 5
A web application firewall (WAF) is an application firewall for HTTP applications.7, source 7 A WAF applies a set of rules to an HTTP conversation.7, source 7 The rules of a WAF generally cover common attacks such as Cross-site Scripting (XSS) and SQL Injection.7, source 7
While proxies generally protect clients, WAFs protect servers.7, source 7 A WAF is deployed to protect a specific web application or set of web applications, and can be considered a reverse proxy.7, source 7
WAFs may come in the form of an appliance, server plugin, or filter, and may be customized to an application.7, source 7 The effort to customize a WAF can be significant and needs to be maintained as the application is modified.7, source 7
The OWASP Core Rule Set (CRS) is a set of generic attack detection rules for use with ModSecurity or compatible web application firewalls.8, source 8 The OWASP CRS aims to protect web applications from a wide range of attacks, including the OWASP Top Ten, with a minimum of false alerts.8, source 8 It provides protection against many common attack categories, including SQL Injection, Cross Site Scripting, and Local File Inclusion.8, source 8
To install the OWASP CRS, you first select your engine and then install the rules.8, source 8 The CRS is free to use and is licensed under the Apache Software License version 2.8, source 8
The Cloudflare WAF checks incoming web and API requests and filters undesired traffic based on sets of rules called rulesets.9, source 9 It uses the Rules language, an expression syntax that lets you filter traffic by request properties such as IP address, URL path, headers, and body content.9, source 9 Cloudflare rate limiting rules define rate limits for incoming requests matching an expression, and the action to take when those rate limits are reached.9, source 9 Cloudflare custom rules let you create your own rules to protect your website and your APIs from malicious incoming traffic.9, source 9
Cloudflare managed rules are pre-configured managed rulesets that, Cloudflare says, give immediate protection when enabled.9, source 9 It also says these rulesets protect against web application exploits such as zero-day vulnerabilities, top-10 attack techniques, use of stolen or leaked credentials, and extraction of sensitive data.10, source 10 Each rule in a managed ruleset has a default action that depends on the severity of the rule, and you can adjust the behavior of specific rules.10, source 10
The Cloudflare OWASP Core Ruleset is Cloudflare's implementation of the OWASP ModSecurity Core Rule Set.10, source 10 It uses a scoring model, where each matching rule adds its score to a cumulative threat score and the WAF executes the configured action when the score exceeds the threshold.10, source 10 Cloudflare WAF Managed Rules run after HTTP DDoS Attack Protection, Custom Rules, and Rate Limiting Rules.10, source 10 A rule with a terminal action such as Block or Managed Challenge in any of those earlier phases prevents Managed Rules from evaluating that request.10, source 10
Cloudflare payload logging logs the request content that triggered supported managed rules and custom rules, so you can investigate rule matches and false positives.9, source 9
Firewalls do not guarantee that your computer will not be attacked.3, source 3 They primarily help protect against malicious traffic, not against malicious programs (malware).3, source 3 A firewall may not protect you if you accidentally install or run malware on your computer.3, source 3 CISA says using a firewall in conjunction with other protective measures, such as antivirus software and safe computing practices, will strengthen your resistance to attacks.3, source 3
Most commercially available firewall products, both hardware and software based, come preconfigured and ready to use.3, source 3 Because each firewall is different, you need to read and understand its documentation to determine whether the default firewall settings are sufficient for your needs.3, source 3 The default configuration is typically less restrictive, which could make a firewall more susceptible to compromise.3, source 3
RFC 2979 requires that a firewall not cause unintended failures of legitimate and standards-compliant usage that would work were the firewall not present.2, source 2 A firewall is entitled to block any sort of access that a site deems illegitimate, whether or not the attempted access is standards-compliant.2, source 2 Blocking ICMP often creates black holes for Path MTU Discovery, causing legitimate application traffic to be delayed or completely blocked when talking to systems connected via links with small MTUs.2, source 2
The only perfectly secure network is one that does not allow any data through at all, and the only problem with such a network is that it is unusable.2, source 2 Anything less than a network that allows no data through is a tradeoff between usability and security.2, source 2
A firewall controls network traffic flow between networks or hosts. It acts as an agent that screens network traffic, blocking traffic it believes to be inappropriate or dangerous. CISA says firewalls provide protection against outside cyber attackers by shielding your computer or network from malicious or unnecessary network traffic.
Both hardware and software firewalls exist. Hardware firewalls, typically called network firewalls, are physical devices positioned between your computer and the internet or another network connection. Software firewalls can control the specific network behavior of individual applications, and are typically located on the same system that is being protected.
Sometimes. Firewalls can prevent malicious software from accessing a computer or network via the internet, but they primarily help protect against malicious traffic, not malware. A firewall may not protect you if you accidentally install or run malware on your computer.
A web application firewall is an application firewall for HTTP applications. It applies a set of rules to an HTTP conversation. The rules generally cover common attacks such as Cross-site Scripting (XSS) and SQL Injection to protect servers and specific web applications.
Run sudo ufw enable from a terminal prompt. On Ubuntu, ufw is the default firewall configuration tool, and it is disabled by default.
No, firewall functions are disjoint from network address translation functions. Neither implies the other, although sometimes one device provides both.
Every fact on this page comes from one of these, checked before it goes live.
SSL and security
A DDoS attack uses many machines to flood one target with traffic until it cannot respond. Learn how it works, the main types and how to reduce the damage.
· Mateo Cardenas
SSL and security
An SSL certificate binds a public key to a domain name so browsers can verify the server. Learn what it holds, who issues it and how long it lasts.
· Mateo Cardenas
SSL and security
HTTPS is an encrypted version of HTTP that uses TLS to protect all communication between a client and a server.
· Mateo Cardenas
SSL and security
TLS lets a client communicate securely with a server over an untrusted network, and SSL is its precursor. Learn how it works and which versions to avoid.
· Mateo Cardenas