Ubuntu – Port forward in terminal only

command linenetworkingport-forwardingserverssh

I have an old Ubuntu server (13.04), and want to open a port for this online game server style software for a mate. I need a port open, and to tell it that port (I know how to tell the game that port).

For the sake of argument, let the port I want to open be 12345.

How do I do such, with no access to a GUI, only a Bash shell. Both how to open the port, and how to fiddle with the firewall so that port is visible to the world.

Thanks!

EDIT: I can port forward it internally (iptables esque), but I don't know what firewalling software I have installed. Is there an easy way to find that out? Also, how do I port forward the router as well, all from the terminal. Sorry for the earlier lack of detail

Best Answer

sudo iptables -A INPUT -i eth0 --proto tcp --dport 12345 -j ACCEPT

this will allow incoming traffic to the network interface eth0 for tcp port 12345. You didn't specify if you were referring to tcp or udp.

You can list the rule with:

sudo iptables -L -n
Related Question