Depends which if any firewall you use.
This from the Ubu help file.
You can optionally install a firewall to protect your computer against
unauthorised access by people on the Internet or your network. Firewalls
block connections to your computer from unknown sources, which helps to
prevent security breaches.
1.
Install the firestarter package from the “Universe” repository.
2.
To start Firestarter, choose System ? Administration ? Firestarter, and
enter your administrator password when prompted.
3.
The Firewall Wizard should run. If it does not, press Firewall ? Run Wizard.
4.
Follow the steps in the Firewall Wizard. After completing all of the
steps, the firewall should be configured and running.
5.
To check that your firewall is working correctly, make use of an online
firewall testing service such as ShieldsUP.
For help and advice on the advanced configuration of Firestarter, see
the Firestarter Online Manual.
More advanced users may wish to use the UFW firewall, which is installed
by default. See the UFW manual for more information.