我是 ubuntu 新手,使用 ubuntu 服务器 12.04。当我运行nmap localhost
时,我得到以下输出:
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
3306/tcp open mysql
这意味着端口 443(https) 已关闭。我想打开它。所以我做了以下工作:
我运行了命令
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
为了保留更改,我使用 sudo sh -c "iptables-save > /etc/iptables.rules"
保存了文件
然后我在etc/network/interfaces
中添加了以下行:
pre-up iptables-restore < /etc/iptables.rules
post-down iptables-save > /etc/iptables.rules
重新启动系统后,我运行了sudo iptables -L
和线路
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:https
是可见的。
但是现在当我运行nmap localhost
时,我仍然没有看到 443 是开放的。
请帮忙!
我敢打赌,您没有侦听主机上的端口443。 试试这个:在一个终端运行sudo nc -lk 443
,然后运行你的nmap localhost
。 这可能与 iptables 防火墙规则无关。