[英]How to open port on Debian
I try to open port 5431 so typed: 我尝试打开端口5431所以输入:
sudo iptables -A INPUT -p tcp --dport 5431 --jump ACCEPT
iptables-save
when I print the rules in a chain iptables -S
then the output is: 当我在链
iptables -S
打印规则时,输出是:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -p tcp -m tcp --dport 5431 -j ACCEPT
so I tried to check open port by nmap from my machine: 所以我试图通过我的机器上的nmap检查开放端口:
mwalko@mwalko-X58A-UD3R:~$ nmap 10.1.2.30
Starting Nmap 7.01 ( https://nmap.org ) at 2018-04-20 16:46 CEST
Nmap scan report for static-30.vlan2.vlex.local (10.1.2.30)
Host is up (0.00027s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
5432/tcp open postgresql
Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds
and as can be seen above 5431 is still not open. 从上面可以看出,5431仍未开放。 How to open this port?
怎么打开这个端口?
@Edit @编辑
root@dell1950:/sbin# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 923/sshd
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 927/postgres
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 861/rpcbind
tcp6 0 0 :::22 :::* LISTEN 923/sshd
tcp6 0 0 :::5432 :::* LISTEN 927/postgres
tcp6 0 0 :::111 :::* LISTEN 861/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 861/rpcbind
udp 0 0 0.0.0.0:613 0.0.0.0:* 861/rpcbind
udp6 0 0 :::111 :::* 861/rpcbind
udp6 0 0 :::613 :::* 861/rpcbind
You are not opening the port, you are just letting the packet directed to such port not to be filtered by firewall. 您没有打开端口,只是让指向此端口的数据包不被防火墙过滤。
A program should open the port (aka listening
). 程序应该打开端口(也就是
listening
)。 Firewall just decides if packets go or not to a specific port (which could be open or close), but has nothing to do with how to handle packets. 防火墙只决定数据包是否进入特定端口(可能是打开或关闭),但与如何处理数据包无关。
I have used @Xenwar comment but had to specify port to make it work: nc -l -p 5431
. 我使用了@Xenwar注释,但必须指定端口才能使其工作:
nc -l -p 5431
。
Now: 现在:
mwalko@mwalko-X58A-UD3R:~$ nmap 10.1.2.30
Starting Nmap 7.01 ( https://nmap.org ) at 2018-04-23 08:40 CEST
Nmap scan report for static-30.vlan2.vlex.local (10.1.2.30)
Host is up (0.00022s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
5431/tcp open park-agent
5432/tcp open postgresql
Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds
Just noticed that nmap closes netcat's nc -l
;/ 刚注意到nmap关闭了netcat的
nc -l
; /
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.