[英]How to open port on Debian
我嘗試打開端口5431所以輸入:
sudo iptables -A INPUT -p tcp --dport 5431 --jump ACCEPT
iptables-save
當我在鏈iptables -S
打印規則時,輸出是:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -p tcp -m tcp --dport 5431 -j ACCEPT
所以我試圖通過我的機器上的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
從上面可以看出,5431仍未開放。 怎么打開這個端口?
@編輯
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
您沒有打開端口,只是讓指向此端口的數據包不被防火牆過濾。
程序應該打開端口(也就是listening
)。 防火牆只決定數據包是否進入特定端口(可能是打開或關閉),但與如何處理數據包無關。
我使用了@Xenwar注釋,但必須指定端口才能使其工作: nc -l -p 5431
。
現在:
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
剛注意到nmap關閉了netcat的nc -l
; /
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.