当你自我炫耀时,便会受到谄媚者的青睐

首页 » 阅读时间 » 科技 » EdgeMAX 如何检测端口映射是否出现问题

EdgeMAX 如何检测端口映射是否出现问题

发布时间:2022年11月20日 修改时间:2024年05月14日 已有 63477 人围观

检测入站连接

首先检测一下路由器出口是否是公网地址,不能是 RFC1918 里面的 10.0.0.0/8 (10.0.0.0-10.255.255.255), 172.16.0.0/12 (172.16.0.0-172.31.255.255) and 192.168.0.0/16 (192.168.0.0-192.168.255.255) 的地址;你可以通过控制面板上面的接口看到,也可以通过 CLI/SSH 命令行看到

show interfacesubnt@ubnt:~$ show interfacesCodes: S - State, L - Link, u - Up, D - Down, A - Admin DownInterface IP Address S/L Description--------- ---------- --- -----------eth0 2.2.2.2/30 u/u Interneteth1 192.168.1.1/24 u/D Localeth2 192.168.2.1/24 u/D Local 2lo 127.0.0.1/8 u/u

检测路由器的外网口是可以通过公网访问或者可以被 ping 通才可以做端口映射,运营商给的私有地址或者不能被公网访问或者 ping 通的公网地址不能使用

在某些互联网连接(通常为住宅)上,即使您有公共 IP 地址,运营商也许不允许在公共端口(例如 25(SMTP),80(HTTP)和 443(HTTPS))上托管服务。 可以使用 tcpdump 检查数据包是否到达您的路由器

在上面的例子中,添加一个端口转发,TCP 端口 8282 到这个私有地址 192.168.1.39,如果将公有端口转发为内部不同的端口,只需要设置不同的转发端口即可,列如 8282->443

eth0 = WAN

eth1 = LAN 192.168.1.0/24

在互联网环境中运行下面命令

sudo tcpdump -nv -i eth0 not port 22 and port 8282

输出的内容像下面這样(可能比较多)

ubnt@ubnt:~$ sudo tcpdump -nv -i eth0 not port 22 and port 8282tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes00:03:24.936592 IP (tos 0x0, ttl 128, id 23813, offset 0, flags [DF], proto TCP (6), length 52)1.1.1.1.60386  2.2.2.2.8282: Flags [S], cksum 0x333f (correct), seq 1306542023, win 8192, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 000:03:24.936928 IP (tos 0x0, ttl 128, id 23814, offset 0, flags [DF], proto TCP (6), length 52)1.1.1.1.60387 > 2.2.2.2.8282: Flags [S], cksum 0xc46c (correct), seq 1879477362, win 8192, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0

如果你没有看到上面的内容,那么可能是运营商阻止了此断开,尝试更换源端口

检查出站连接

如果你的接口是桥接口访问转发端口,你需要将桥接口设置为混杂模式

configure
set interfaces bridge br0 promiscuous enable
commit
save
exit

检查数据包是否从正确的接口出去,這里是 eth1 口,将 8282 改成转发端口

sudo tcpdump -nv -i eth1 not port 22 and port 8282ubnt@ubnt:~$ sudo tcpdump -nv -i eth1 not port 22 and port 8282tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes00:04:54.241129 IP (tos 0x0, ttl 127, id 25226, offset 0, flags [DF], proto TCP (6), length 52)1.1.1.1.60703 > 192.168.1.39.8282: Flags [S], cksum 0xd41a (correct), seq 3153276637, win 8192, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 000:04:54.241337 IP (tos 0x0, ttl 127, id 25227, offset 0, flags [DF], proto TCP (6), length 52) 1.1.1.1.60704 > 192.168.1.39.8282: Flags [S], cksum 0xaecc (correct), seq 582872416, win 8192, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 000:04:54.241506 IP (tos 0x0, ttl 127, id 25228, offset 0, flags [DF], proto TCP (6), length 52)

应该能看到像上面输出的内容

如果没有,请确保你已经在 Firewall/NAT-> Port Forwarding 上开启了防火墙

检查你的主机

最后,你可以使用 tcpdump 或者 wireshark 工具来检测端口转发的数据包是否达到你的设备,在这个例子中,192.168.1.39 是一个 airMax 设备

tcpdump -nv -i br0 not port 22 and port 8282XM.v5.6-beta4.22359.140521.1845# tcpdump -nv -i br0 not port 22 and port 8282tcpdump: listening on br0, link-type EN10M