Managing Open Ports

A guide to exposing ports from your Foundry instances

sudo foundrypf <port_number>

Replace <port_number> with the desired port number you want to forward to your instance's public IP. This will start a process that maintains the open port. You may keep it running in the background with nohup, and close the port with the following command:

sudo foundrypf -d <port_number>

Again, replace <port_number> with the corresponding port number whose forwarding you want to stop.

If you want to make sure the port forwarding is kept running in the background persistently even after a system reboot, or in case the process fails in the background due to network blips, you can create a systemd service for it.

Open a new service file using a text editor (like nano):

sudo nano /etc/systemd/system/examplefoundry.service

Add the following content into the service file:

[Unit]  
Description=Foundry Port Forwarding Service  
After=network.target
Wants=network-online.target

[Service]  
Type=simple  
User=root  
ExecStart=/usr/local/bin/foundrypf <port_number>  
Restart=always  
RestartSec=3

[Install]  
WantedBy=multi-user.target

Again, replace <port_number> with the actual port you want to keep forwarded persistently.

sudo systemctl daemon-reload  
sudo systemctl enable examplefoundry  
sudo systemctl start examplefoundry

Now, the foundrypf script will run as a service, and the specified port will be kept forwarded persistently. Adjust the <port_number> and service file name if you wish to set up multiple such services for different ports.

Note that lower-number ports are currently not supported on foundrypf. We recommend running applications on higher-number ports.

Last updated