0

I need ports open at home for syncthing, but want incoming connections blocked when on any other network. How do I do this with Ubuntu?

Without this feature I quite often end up turning off the laptop at home with the firewall off, then turning the laptop on at say work and having it connect automatically to a network where I wanted the firewall on, leaving a window of extra vulnerability while I get the firewall turned back on. Not ideal!


Prompted by: https://askubuntu.com/a/688912/79266

I'm currently using gufw. See also https://help.ubuntu.com/community/Gufw

P.S. Windows can do this.

Tim Abell
  • 465

1 Answers1

0

Solution would be:

  1. Identify the network address for your home network or any other you want to associate a port with.

  2. Tell ufw to allow traffic from that network via that port like so:

    sudo ufw allow from 15.15.15.0/24 to any port 873
    
    # another example
    
    sudo ufw allow from 192.168.1.215 proto udp to any port 88
    

Note:

The ports chosen are purely imaginary pick that which fits your setup, same situation for network address.

George Udosen
  • 36,677