如何在Ubuntu上打开一些端口?

时间:2022-07-27 18:10:26

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.

我对Linux知之甚少。今天我根据https://github.com/philplckthun/setup-simple-ipsec-l2tp-vpn在我的ubuntu上创建一个VPN服务器但是当我完成安装时。我使用我的iphone连接ipsect vpn,bur显示VPN Server没有响应。

The github document shows

github文档显示

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

必须打开端口1701,500和4500才能使VPN正常工作!

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?

所以我试图在我的ubuntu服务器上打开这些端口。我使用“iptables”命令打开这些ports.but它失败了。也许我不知道如何正确使用这个命令。所以我想知道如何在我的ubuntu服务器上打开这个端口?如果这个端口已经成功打开,可以通过telnet端口通过windows cmd窗口证明吗?

2 个解决方案

#1


37  

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

Ubuntu最近带有ufw - 简单的防火墙。 ufw是一种易于使用的处理iptables规则的方法。

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:

要测试连接性,您可以尝试关闭VPN软件(释放端口)并使用netcat进行监听,如下所示:

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.

然后使用Windows主机上的telnet,查看Ubuntu终端上显示的内容。对于您要测试的每个端口,可以重复此操作。

#2


2  

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

如果要为范围和协议打开它

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

ufw允许11200:11299 / tcp ufw允许11200:11299 / udp

#1


37  

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

Ubuntu最近带有ufw - 简单的防火墙。 ufw是一种易于使用的处理iptables规则的方法。

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:

要测试连接性,您可以尝试关闭VPN软件(释放端口)并使用netcat进行监听,如下所示:

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.

然后使用Windows主机上的telnet,查看Ubuntu终端上显示的内容。对于您要测试的每个端口,可以重复此操作。

#2


2  

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

如果要为范围和协议打开它

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

ufw允许11200:11299 / tcp ufw允许11200:11299 / udp