Are you with wired or wireless connection?
Set up firewall rules in System Preferences > Security > Firewall, service by service you need on.
If you are behind a wireless or wired router and other potential firewalls, set the ports you need open also there.