请教"网络唤醒"

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
junhn.yang
帖子: 55
注册时间: 2007-08-16 16:21
联系:

Re: 请教"网络唤醒"

#31

帖子 junhn.yang » 2009-09-24 13:39

windwiny 写了:...

以前听人说过某种网卡要先启动WIN让它激活再换到LINUX系统才能用

我用现在D的笔记本,也很差, 关机几个小时后, 要先启动WIN让它激活键盘再启动到LINUX下才能用...


谢谢,我也听说过你说这个,但我这台计算机现在只有linux了.  你加我的QQ,我有方法让你不要那样先进W再去L才能上网了.
上次由 junhn.yang 在 2009-09-24 13:42,总共编辑 1 次。
junhn.yang
帖子: 55
注册时间: 2007-08-16 16:21
联系:

Re: 请教"网络唤醒"

#32

帖子 junhn.yang » 2009-09-24 13:41

冲浪板 写了:“在同一网段”与“目标机器和我们登录的机器在同一局域网中”
你接受哪个?

你问我,是吧.  同一网段,不路由嘛. 同一个局域网中,如果有多个网段却要经过路由...

所以当然同一网段可靠性要高些嘛.
头像
冲浪板
论坛版主
帖子: 7513
注册时间: 2007-05-06 8:19

Re: 请教"网络唤醒"

#33

帖子 冲浪板 » 2009-09-24 13:43

其实你试试:windows关机,把电源断掉,再接上电源,wol看看?多数不灵。
junhn.yang
帖子: 55
注册时间: 2007-08-16 16:21
联系:

Re: 请教"网络唤醒"

#34

帖子 junhn.yang » 2009-09-24 13:44

冲浪板 写了:其实你试试:windows关机,把电源断掉,再接上电源,wol看看?多数不灵。

这台服务器不行,昨天我试过了.  但我另外的服务器350的却可以.这个我想和主板设计有关吧.
头像
冲浪板
论坛版主
帖子: 7513
注册时间: 2007-05-06 8:19

Re: 请教"网络唤醒"

#35

帖子 冲浪板 » 2009-09-24 13:53

junhn.yang 写了:
冲浪板 写了:“在同一网段”与“目标机器和我们登录的机器在同一局域网中”
你接受哪个?

你问我,是吧.  同一网段,不路由嘛. 同一个局域网中,如果有多个网段却要经过路由...

所以当然同一网段可靠性要高些嘛.
....如果交换机的CAM TABLE里面没有这个MAC的记录, 交换机会把这个FRAME FLOOD到所有的端口, 包括我们想要开机的端口, 从而达到从INTERNET WOL的目的....
junhn.yang
帖子: 55
注册时间: 2007-08-16 16:21
联系:

Re: 请教"网络唤醒"

#36

帖子 junhn.yang » 2009-09-24 14:12

在人路过吗.?
头像
qiang_liu8183
论坛版主
帖子: 10699
注册时间: 2006-09-10 22:36
系统: Arch Debian
来自: 北京

Re: 请教"网络唤醒"

#37

帖子 qiang_liu8183 » 2009-09-24 14:15

楼主

检查一下BIOS电源管理Power Management Setup项是Wake on LAN还是Wake on PCI Card
看破、放下、自在、随缘、念佛
真诚、清净、平等、正觉、慈悲
junhn.yang
帖子: 55
注册时间: 2007-08-16 16:21
联系:

Re: 请教"网络唤醒"

#38

帖子 junhn.yang » 2009-09-24 14:20

qiang_liu8183 写了:楼主

检查一下BIOS电源管理Power Management Setup项是Wake on LAN还是Wake on PCI Card

哥哥.这个是HP的服务器, 不是台式机,我也打电话问了HP技术支持.他们回答是这样的. 这个问题我也给他们说了.但那个技术支持给我说.他不懂Linux 所以我才来这里求助
头像
冲浪板
论坛版主
帖子: 7513
注册时间: 2007-05-06 8:19

Re: 请教"网络唤醒"

#39

帖子 冲浪板 » 2009-09-24 14:33

部分内容可能有用:

远程开机,现在有两种方法,本地同一广播域内开机,远程过路由开机。
先谈谈本地开机。
要打开mac地址是00-0E-7F-7B-BD-32这台主机,发起pc发出一个广播。通过sniffer的ip包。可以看到目的MAC地址是FF-FF-FF-FF-FF-FF,这是一个广播,再看目的ip地址,192.168.200.255,是ip广播,向下看,数据包是UDP,目的端口是2304,源端口不必理会。

那么说,发一个广播,只要端口是2304就可以开机吗?显然不是,开机是有针对性的,不是发一个这样的广播,所有的机器都开机。关键就在那个数据里面。看一下这个126字节的数据到底有什么,最初的6个子字节是全F,7到12字节就是要开机的MAC地址,然后循环出现,直到填充到126个字节为止。这才是确定开那一台机器的关键。

总结一下,要开机就必须让被开的机器,收到端口为2304的udp数据包,包的内容包含了被开机的MAC地址。但是没有开机的机器没有办法设定ip地址,怎么才能让其收到,于是广播就是最好的方式了。

那么远程过路由开机怎么办,又不能进行广播。
通过抓包可以发现,目的mac地址变成了网关的,目的ip地址变成了那台机器设定的静态ip,其它数据没有变化。那么这样可以开机吗?前面不是说过了,没有开机的机器是无法设定ip的,它如何才能把这个数据送到该网卡呢。
这里就牵扯到一些路由器,交换机,hub的一些原理。hub是把所有的数据都发送到所有端口(物理),所以效率不高;交换机呢,是根据已经注册的mac地址和端口(物理)的对应关系转发,那么没有开机的情况下,当然也没有注册mac地址了,但是交换机在对待没有注册的mac地址的时候,会把这个数据包发往所有的端口(物理),这样也没问题了。那么作为远程的关键导入点的路由器,是工作在3层,它要查找ip地址和mac的对应关系,就用arp协议,我们知道如果这台机器是down状态下,是不会应答arp广播的,那么这样说来无法开机了?结果却出人意料,机器却开机了,为什么?
分析一下,进入路由器,察看arp table,竟然有ip地址和mac的对应,稍作思考就明白,原来这台测试用的电脑刚刚做完开机测试,刚关机,开机的时候,即使我们什么都不做,windows机器也会去找微软的服务器的,这已经不是秘密,那么它必然找过网关,所以网关当然就知道了这个ip和mac的对应关系,根本就不用arp查找,直接就发出数据,机器接收到也就能开机了。为了证实这个想法,把路由器内的对应关系删除,果然不能开机了。
远程开机不能只开刚刚关闭的机器吧,症结就在ip和mac的关系上,那么绑定对应关系,问题迎刃而解。
junhn.yang
帖子: 55
注册时间: 2007-08-16 16:21
联系:

Re: 请教"网络唤醒"

#40

帖子 junhn.yang » 2009-09-24 15:27

有路过.有资料支持下哦.
头像
szyzln
帖子: 910
注册时间: 2008-10-31 15:28
来自: 中国上海
联系:

Re: 请教"网络唤醒"

#41

帖子 szyzln » 2009-10-15 10:40

:em03 高科技没用过。问题解决了我再来收场!
家乡:湖南张家界
wulongjie
帖子: 10
注册时间: 2009-05-30 19:48

Re: 请教"网络唤醒"

#42

帖子 wulongjie » 2009-11-25 9:21

问题还没解决????
替LZ郁闷中!~~~~~~
头像
ywz306
帖子: 102
注册时间: 2009-09-07 20:34
联系:

Re: 请教"网络唤醒"

#43

帖子 ywz306 » 2010-09-17 11:14

sudo ethtool eth0

看Wake-on: d
如果 wake-on 一项值为 d,表示禁用wake on lan 值为 g,表示启用 wake on lan

不知道配置文件在哪里,知道的话改一下就好了
sarrows
帖子: 4
注册时间: 2008-04-04 21:18

Re: 请教"网络唤醒"

#44

帖子 sarrows » 2011-05-23 22:25

如果还没解决的话,我来支招:
ubuntu:
sudo apt-get install ethtool

sudo ethtool eth0
显示出来的wol应该是d,也就是disabled
sudo ethtool -s eth0 wol g
模式就改过来了
sudo halt 试试
但是再次启动,就恢复到d了,所以,把那行命令写入
/etc/rc.local
就可保万无一失了。
coolpk
帖子: 12
注册时间: 2006-08-10 0:25

Re: 请教"网络唤醒"

#45

帖子 coolpk » 2011-08-04 22:42

看了上面的所有帖子,发现大家没有找到这个帖子: http://ubuntuforums.org/showthread.php?t=234588

用 google 搜索下列关键词: wake on lan ubuntu ,马上就能看到上面的贴子.

本人目前有20台ubuntu, 无论服务器,diy主机,均通过帖子中的方式进行管理,该方法很好,请LZ放心使用.

================================================
原文粘帖:

This is really common, but I haven't seen a ubuntu howto for it, people more or less peice it together from posts and blog entries and the like.

So, here it goes. First off, make sure your system supports WakeOnLAN (WOL), if you know your system well, you already know if it does or doesn't.

--

Automatic way:
This script does everything described in the Manual way, for you, except step 1 and step 4.
------------------------

The automatic method is super dialup friendly! thanks to gzip compression the filesize is a mere 1.5kb! almost half the extracted size of 3.4kb!


1. If you havent already, go to your BIOS, and turn on WakeOnLAN (it varies, look for it.) If your network card is onboard, your set for step 2, otherwise there is probably a cable that should go from your network card to your motherboard, though this is not always the case.


Before continuing, note the interface you want to do this to. Most people know how to do this, if you do not, look at step 2a of the manual method.

2. Download and extract this: You can do it with the GUI and run the extracted program in a terminal by double clicking it, or open a terminal and do the following:

**** Removed dead link ****

3. As the exit of the program notes, now you just need to get/use a wake on lan sending program, like wakeonlan.

4. Sit on your lazy *** and have fun

--

Manual way:
------------------------
1. If you havent already, go to your BIOS, and turn on WakeOnLAN (it varies, look for it.) If your network card is onboard, your set for step 2, otherwise there is probably a cable that should go from your network card to your motherboard, though this is not always the case.

2. Back in ubuntu, kubuntu, xubuntu, w/e, we now need to make a script that will run every time the computer is started, because this command only lasts until the computer is turned on again once.

2a. Find out what network device you want to have the computer wake-able from, usually all, which is just one. If you have more network devices in your system, 9 chances out of 10, you already know what they are called.
You can NOT wake up a laptop or computer that is only connected via wireless with wake-on-lan, unless the bios has a method for this, this is very rare, and I do not garuntee this howto will work in such cases.
In your terminal, type:
Code:
ifconfig
You'll get something like: (I have removed my mac address for security)
Code:
eth0 Link encap:Ethernet HWaddr 01:23:45:67:89:ab
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::215:f2ff:fe6f:3487/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:71495 errors:0 dropped:0 overruns:0 frame:0
TX packets:76190 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:23164212 (22.0 MiB) TX bytes:7625016 (7.2 MiB)
Interrupt:217 Base address:0xd400

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1290 errors:0 dropped:0 overruns:0 frame:0
TX packets:1290 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:161182 (157.4 KiB) TX bytes:161182 (157.4 KiB)
So, I want this system to be wake-able from eth0.

2b. Now we create the script.
Note: you must be an administrator on the system you are doing this to.
Code:
sudo -i
Enter your password at the prompt.
Change to the startup script directory and start editing a new file:
Code:
cd /etc/init.d/
pico wakeonlanconfig
Paste, or type this into the file, replacing eth0 with your network device, repeat the ethtool line as many times for your devices before the exit line:
Code:
#!/bin/bash
ethtool -s eth0 wol g
exit
Set the permissions of the file:
Code:
chmod a+x wakeonlanconfig
Make the script run on startup:
Code:
update-rc.d -f wakeonlanconfig defaults
You should see something like:
Code:
Adding system startup for /etc/init.d/wakeonlanconfig ...
/etc/rc0.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc1.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc6.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc2.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc3.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc4.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc5.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
Now we finish by running it, and making sure there are no errors.
Code:
/etc/init.d/wakeonlanconfig
This should produce no output and put you right back at the prompt you started at.

3. Use it. you'll need something to send wake-on-lan packets with, "wakeonlan" is in the repos. And you'll need the mac address of the system.

To get your MAC address, on the same system you just enabled WOL on, type:
Code:
ifconfig | grep HW
its the thing that looks like 01:23:45:67:89:ab , write it down.
turn off that system:
Code:
sudo halt
if your using wakeonlan from the repos, and you are on the same network as the computer your tying to wake up, replace 01:23:45:67:89:ab with your mac address and do, from another computer:
Code:
wakeonlan 01:23:45:67:89:ab
In MOST cases, you CAN SEND wake on lan packets from a wireless connected computer.
If that doesnt work, its likely the port on the system your trying to wake up isnt the default (9), try 7, or if your BIOS settings or book told you one, use that one.
Code:
wakeonlan -p 7 01:23:45:67:89:ab
If that STILL doesnt work, make sure wakeonlan is enabled in your bios and your hardware supports it.

*Note: It has been said that you need to disable -i from halt, however I have never had to do this, nor do I know how.

4. Sit on your lazy *** and have fun

Feel free to post any questions, suggestions, problems and I will tend to them ASAP.

Added notes:
* For this to work, most systems must be shut down properly, ie: with the power button or halt, or any of the ways to shut down. Unclean power-offs (like a power outage or holding the power button for 5s) seem to stop WOL from working untill the system is powered on and shut down properly. Though, there my be a few exceptions. This is a hardware issue with the BIOS. In my opinion, WOL should work regardless of how the system is powered off, but thats not the case. I suggest, if you have frequent power outages, that you have your BIOS set to Power ON after a power failure, most new systems allow this.
================================================
针对英文不好的同学,我大致整理好步骤如下:
1. sudo apt-get install ethtool wakeonlan
此命令用于安装 ethtool 和 wakeonlan 这些个工具: ethtool 用于修改网卡的wol状态; wakeonlan 用于唤醒主机

2. sudo -i
进入 root 模式

3.cd /etc/init.d/
pico wakeonlanconfig

进入 /etc/init.d/, 创建 wakeonlanconfig 文件. 我个人喜欢用nano, 原文是用 pico

4. 输入下面的内容,并保存退出:

#!/bin/bash
ethtool -s eth0 wol g
exit

5. chmod a+x wakeonlanconfig
修改 wakeonlanconfig 的属性,保证可以运行

6.update-rc.d -f wakeonlanconfig defaults
把脚本程序 wakeonlanconfig 添加到启动服务中,如果一切正常,会看到如下的输出:
Adding system startup for /etc/init.d/wakeonlanconfig ...
/etc/rc0.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc1.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc6.d/K20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc2.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc3.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc4.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig
/etc/rc5.d/S20wakeonlanconfig -> ../init.d/wakeonlanconfig

7. 现在好了,可以运行:/etc/init.d/wakeonlanconfig 来测试是否一切正常,如果正常,则什么也不会有显示

8.最后一步,你要确定本机的 mac 地址,用如下命令: ifconfig | grep HW

现在,你可以放心重启你的系统了,用命令都可以.

请LZ及各位同学测试一下,有问题可以留言.



================================================
回复