Firewall is an element of networking equipment

Firewall
A firewall is an element of networking equipment that keeps an eye on all the data flowing in and out and either allows or disallows packets of information depending on specified policies. The firewall’s job is to prevent harmful data from entering your network from outside sources like the internet. It can protect a business or home network from hackers and virus attacks.
Firewalls evaluate all incoming data packets according to criteria, blocking data from potentially dangerous or unauthorized sources.
Example:
Consider IP addresses to be home addresses and port numbers to be entry points into such homes. First, only authorized visitors (source IPs) are allowed into the house (destination IPs). Once inside, the residents are further divided into three groups (owner, kid, and guest) with different access levels to different rooms (destination ports). Children and visitors may use a restricted set of rooms, but the owner has access to all rooms (and (specific ports).
Kinds of Firewall
Next-generation firewalls (NGFW)
Integrate intrusion prevention, anti-virus scanning, encrypted traffic inspection, and more into your existing firewall setup. Specifically, it has DPI or deep packet inspection. Deep packet inspection analyzes the contents inside the packet, whereas standard firewalls scan the packet headers, allowing users to detect, classify, and block packets containing dangerous material.
Proxy firewalls
application-level filters on network traffic. Proxy servers are more like advanced routers than traditional firewalls. The firewall processes requests from clients after being checked against a set of security criteria to determine whether the request should be let through or denied.
Network address translation (NAT)
Through a firewall, many devices with separate network addresses may share a single IP address to access the internet. This makes it harder for hackers to get precise information about a network by scanning for IP addresses. In the same way, as proxy firewalls mediate between an internal network and the Internet, NAT firewalls do the same for a network of computers.
Stateful multilayer inspection (SMLI)
Firewalls examine incoming data at the network, transport, and application levels for similarities to previously authenticated data. In the same way as next-generation firewalls (NGFW) check each packet layer before letting it through, SMLI does the same. These firewalls (thus the name) use packet analysis to verify that only authorized senders and receivers are communicating.