How to open some ports on Ubuntu?

I know little about Linux.Today I create a VPN server on My ubuntu according to https://github.com/philplckthun/setup-simple-ipsec-l2tp-vpn But when I finish the installation. I use my iphone to connect the ipsect 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 "iptables" command to open these ports.but it failed.Maybe I don't known how to use this command correctly。So I want to know how can I open this ports on my ubuntu server? And if this ports have been opened successfully, can it be proved by the windows cmd window through telnet the port?


Solution 1:

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:

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

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