If you are hosting an application or a webpage one of the most important things you need to consider is security and external/public access to your application over the internet. Nowadays almost all machines, whether its cloud or virtual servers, client desktops or personal laptops, all have firewalls enabled by default. Depending on whether you have a windows firewall or a mac firewall or a linux firewall you can find instructions on adding ‘inbound’ or ‘outbound’ rules to enable access to your application. Once you add those rules, if it’s an application that is hosted on your personal/home system you typically will have to add a firewall rule to your specific router also. However after you add the ‘right’ rules you find you still cannot access your application from the internet. What then?
One of the first things to do is determine the ‘external’ IP address of your machine. On linux or Mac OS machines open up a terminal/shell window and type the following command to get your external IP address:
dig +short myip.opendns.com @resolver1.opendns.com
If you are on a Windows machine, then open up the command prompt and enter the following similar command to get your external IP address:
nslookup myip.opendns.com resolver1.opendns.com
Another easy way to determine your external IP from any machine is to visit the following site from your browser https://www.whatismyip.org and that should also show your IP address.
Once you know your external IP address, you can then enter the following netcat command from your terminal or command prompt to determine if a specific port is open in the firewall(s)
nc -v <your external ip> <your port number>
The netcat command replaces the telnet command that most developers used to use to debug or test if a specific port was open.
Note: If you have your own domain name mapped to your external IP you can always replace the <your external ip> option above with <your domain name>