DB section has been updated to add some SQL code.
A firewall can be hardware or software but its main aim is to monitor the traffic on a network, both inbound/outbound and only allow certain traffic.
These are not designed to stop viruses, anti virus software is the main defence here .
They are a primary method to secure against hackers gaining unauthorised access to systems/files.
Firewalls achieve this by:
Filtering out particular websites/IP Addresses
Monitoring the packets of information that are sent across the network
Opening/Closing Particular Network Ports
Offering Port forwarding ( where network traffic is sent to a particular machine)
This image shows some of the options available on a firewall setup page.