linux – 使用公共IP地址无法访问本地端口

我有一个linux服务器,它有公共IP和私有IP.因此,当我使用公共IP登录时,终端直接显示私有IP.

例:

$ssh root@55.27.XX.XX
root's password: 
root@10.1.4.20:~$hostname -I
10.1.4.20
root@10.1.4.20:~$wget -qO- http://ipecho.net/plain ; echo
55.27.xx.xx

现在,我安装了Nginx,我可以使用认的Nginx页面加载55.27.xx.xx.但是,当我用端口85安装PHPmyadmin时,它不允许我从公共IP访问该页面.

如果我使用卷曲10.1.4.20:85,我得到200 OK响应.但卷曲55.27.xx.xx:85,我得到超时.

与netcat命令相同:

root@10.1.4.20:~$nc -vz localhost 85
nc: connect to localhost port 85 (tcp) Failed: Connection refused
Connection to localhost 85 port [tcp/*] succeeded!
root@10.1.4.20:~$nc -vz 55.27.xx.xx 85
nc: connectx to 55.27.xx.xx port 85 (tcp) Failed: Operation timed out

可能服务器可能在一些路由器后面:

root@10.1.4.20:~$ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNowN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <broADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:55:00:tt:a6:76 brd ff:ff:ff:ff:ff:ff
    inet 10.1.4.20/16 brd 10.4.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 dddd::xxxx:ff:4534/64 scope link 
       valid_lft forever preferred_lft forever

我没有做任何端口转发步骤.我看到iptables -L的空白输出如下:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination  

从服务器,我无法ping google.com

ping www.google.com
PING www.google.com (xx.xx.xx.xx) 56(84) bytes of data.
^C
--- www.google.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2000ms

请建议从公共IP地址使用端口85访问PHPmyadmin需要做什么.

解决方法:

ip addr show的条目表明您的服务器只有一个本地地址:

inet 10.1.4.20/16 brd 10.4.255.255 scope global eth0

您需要检查将55.27.XX.XX地址映射到10.1.4.20的外部NAT设备,并为端口tcp / 85提供端口转发.

相关文章

Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一...
本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改l...
nginx不仅可以隐藏版本信息,还支持自定义web服务器信息 先看...
一 、此次漏洞分析 1 nginx HTTP/2漏洞 [nginx-announce] ng...
###进入nginx 目录cd /usr/local/nginx###递归显示 2 级目录...
在cmd命令窗口输入下面命令进行查看 tasklist /fi "ima...