简体   繁体   English

为什么魔术包可以通过 lan 而不是 wan 唤醒?

[英]Why the magic packet can wake_on_lan via lan instead of wan?

My simple home internet environment:modem(pppoe) + router + pc.我简单的家庭网络环境:modem(pppoe) + router + pc。 The modem is a FTTH device which is fiber to the home (FTTH),the delivery of a communications signal over optical fiber.调制解调器是一种 FTTH 设备,它是光纤到户 (FTTH),通过光纤传输通信信号。
Setting in BIOS:在 BIOS 中设置:

Advanced--Realtek Lan Controller--enabled
        --Realtek Pxe Option Rom--enabled
Advanced--APM--Power on by PCI-E 

Setting in router:在路由器中设置:

the ip (192.168.31.52) and mac address are binded together

The start_lan.py script in my android's qpython3:我的 android 的 qpython3 中的start_lan.py脚本:

from wakeonlan import send_magic_packet
send_magic_packet('mac address of my pc') 

Turn on wifi in my android phone and run start_lan.py from android's qpython3,my pc waked on lan via lan,succeeded!在我的 android 手机中打开 wifi 并从 android 的 qpython3 运行start_lan.py ,我的电脑通过 lan 在 lan 上唤醒,成功!
Then i want to wake on lan via wan(external internet environment),there are two status to discuss,one status keep router in the web structure,the other don't.然后我想通过WAN(外部互联网环境)唤醒局域网,有两种状态要讨论,一种状态保持路由器在web结构中,另一种不。
Status 1:状态一:

modem(pppoe) + pc
#Remove router 

Status 2:状态二:

Keep the web structure as same as wake_on_lan via lan.

Set port forwarding on my router:  

    name  protocol      external port        inner ip address   inner port
    wan   TCP and UDP   30000                192.168.31.52       9
    #the default port for wake on lan is 9.

When request my pc's public ip on the port 30000,it will be forwarded into 192.168.31.52 on the port 9. 

Both of the two status use almost the same start_wan.py script in my android's qpython3: For status 1:这两种状态都在我的 android 的 qpython3 中使用几乎相同的start_wan.py脚本: 对于状态 1:

from wakeonlan import send_magic_packet
send_magic_packet('mac address of my pc',ip_address='public ip') 

For status 2:对于状态 2:

from wakeonlan import send_magic_packet
send_magic_packet('mac address of my pc',ip_address='public ip',port=30000) 

Execute the script,my pc can't be waken?Does the FTTH device matter?执行脚本,我的电脑无法唤醒?FTTH设备重要吗? How to fix it?如何解决?

Some ISP only open the well-known ports for users,change the port nmuber more small.有的 ISP 只为用户开放知名端口,将端口 nmuber 改得更小。

Set port forwarding on my router:在我的路由器上设置端口转发:

name  protocol      external port        inner ip address   inner port
wan   TCP and UDP   9                     192.168.31.52       9

It is verified that both status can use same code snippet such as below:经验证,两种状态都可以使用相同的代码片段,如下所示:

from wakeonlan import send_magic_packet
send_magic_packet('mac address of my pc',ip_address='public ip',port=9) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM