Port forward in terminal only
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 videos on Youtube
Benji Marshall
Updated on September 18, 2022Comments
-
Benji Marshall over 1 year
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
-
Anders almost 11 yearsThe port is opened by the program, so start the server program using port 12345 with UDP and/or TCP. What firewall software do you use on the server? None, ufw, shorewall or something else? How are your server connected to internet? Directly or through a router with IPv4 with/without a NAT and firewall, with IPv6? Please add information about this so we can help you to answer your question. Using IPv6 would have been easier. ;-)
-
amc almost 11 yearsSo to clarify: using the answer provided by @tomodachi below should have opened the port, and should be accessible on your LAN. To open the port on your router and enable port forwarding you will need to login to your router (usually done through web interface). The specific instructions will vary by router model/brand, but look for "applications" or "port forward" in your router settings.
-
Benji Marshall almost 11 yearsGreat. How do I get to get to the router settings all in shell (I do have "links" to view web pages in terminal)?
-
-
Benji Marshall almost 11 yearsAwesome, but that is only part of my battle. Thanks for the help so far, can you look at my edit to OP where I explain what also needs doing. Thank you so far, though.