Wikipedia definition of a firewall is, “either software-based or hardware-based and is used to help keep a network secure. Its primary objective is to control the incoming and outgoing network traffic by analyzing the data packets and determining whether it should be allowed through or not, based on a predetermined rule set. A network’s firewall builds a bridge between the internal network or computer it protects, upon securing that the other network is secure and trusted, usually an external (inter)network, such as the Internet, that is not assumed to be secure and trusted.” So what does that mean? Basically, a firewall filters all the information you’re trying to get and only gives you the good stuff.
How does a firewall work anyway? The predominate protocol in networks today is TCP/IP. Within TCP/IP there are over 65,000 ports possible. Well known or common protocols use ports that are assigned by IANA, but is not always required. For example, SMTP uses port 25. HTTP uses port 80. HTTPS uses port 443. HTTP and HTTPS can be configured to use different ports if necessary. Generally speaking, the higher numbered ports are not assigned to specific functions.
Some firewalls are optimized to perform action required on specific incoming port traffic. For example, many firewall manufactures make a specific product for email filtering which would only monitor port 25 traffic.
Firewall functions range greatly. In the most basic form, a firewall simply uses the rules set to grant or deny access traffic that passes through it. There are many different devices to fit each network’s needs. It’s best to consult an expert to determine which device(s) are right for your network.