elsonwx
elsonwx

Reputation: 1629

How can I open some ports on Ubuntu?

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?

Upvotes: 101

Views: 323275

Answers (3)

Mohi Dev
Mohi Dev

Reputation: 3386

You can open a port with this command

sudo ufw allow 22/tcp

And then check the firewall status with this

 sudo ufw status verbose

Upvotes: 4

shane
shane

Reputation: 2123

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.

Upvotes: 153

Sanjeev Rohila
Sanjeev Rohila

Reputation: 301

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

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

Upvotes: 30

Related Questions