How can I open some ports on Ubuntu?

LinuxUbuntuPort

Linux Problem Overview


I know a little about Linux. Today I created a VPN server on my Ubuntu installation according to Set up a simple IPsec/L2TP VPN server for Ubuntu, Arch Linux and Debian.

But when I finish the installation, I use my iPhone to connect the IPsec VPN, bur it shows the VPN Server has no response.

The GitHub document shows

> Ports 1701, 500 and 4500 must be opened for the VPN to work!

So I have tried to open these ports on my Ubuntu server.

I use the iptables command to open these ports, but it failed. Maybe I don't known how to use this command correctly. How can I open these ports on my Ubuntu server?

And if these ports have been opened successfully, can it be proved by the Windows CMD window through telnet'ting the port?

Linux Solutions


Solution 1 - Linux

Ubuntu these days comes with UFW - Uncomplicated Firewall. UFW is an easy-to-use method of handling iptables rules.

Try using this command to allow a port:

sudo ufw allow 1701

To test connectivity, you could try shutting down the VPN software (freeing up the ports) and using netcat to listen, like this:

nc -l 1701

Then use telnet from your Windows host and see what shows up on your Ubuntu terminal. This can be repeated for each port you'd like to test.

Solution 2 - Linux

If you want to open it for a range and for a protocol

ufw allow 11200:11299/tcp
ufw allow 11200:11299/udp

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionelsonwxView Question on Stackoverflow
Solution 1 - LinuxshaneView Answer on Stackoverflow
Solution 2 - LinuxSanjeev RohilaView Answer on Stackoverflow