Apr
19

WOL: Wake-on-LAN Tutorial with Bonus PHP Script

I love tweaking my computer! Every opportunity that allows me to specify what I want makes me excited of the possibilities. (With the exception of Azureus. That's just too confusing for me!) In fact, the first thing I check after installing a new program is the possible existence of "Options," "Preferences," "Tools," "Configuration," "Settings," or "Setup!"

 

BIOS (or CMOS)

When I first became involved with computers, I started to mess around with the BIOS. It was an intriguing little 16-color control panel. I'm talking about those settings that you can change after pressing "F1," "F2," or "Delete" before the operating system starts to load.

post_screen.jpg

Mysterious Wake on LAN Setting

bios_screen.jpgI pretty much understood all the settings and what each one did except for this strange "Remote Wake-on-LAN." It wasn't until much later I discovered that initiating this option allows the computer to boot upon command from the network. Personally, that is ultra cool! But at the time, I really didn't have a use for it. Then came college.

College Needs

I increasingly saw a need to get a laptop. There were countless times when I needed to access my computer while on campus. Sadly, the only computers that I could use were the ones in the computer labs. I came up with a nifty idea that wouldn't cost a dime. Since I can't leave my computer on all day, why don't I use the Wake-on-LAN function to turn it on remotely and then implement a remote access setup. It would enable me to access my computer from anywhere regardless of whether it was off or on!

How it Works

Wake-on-LAN gives me the impression of an undocumented obscure little function that hardly anyone makes use of. Really, it is so simple that the lack of documentation is understandable. Essentially, enabling this function allows the network device to stay half-awake while the rest of the computer is off. It consumes a miniscule amount of electricity while constantly listening to the network. The network device waits until it receives a "magic packet" (seriously!). A magic packet is a small bundle of data consisting of the bytes "FF FF FF FF FF FF" followed by 16 repetitions of the listening network device's MAC address.

Creating the "Magic Packet"

A magic packet is fairly easy to generate. Depicus provides great freeware tools that allow you to input the parameters. Personally, I PHP programmed my server to generate the packet. I found some useful PHP WOL code from the PHP website. I modified it so that it will fit my liking. Just change the lines in the end.

PHP:
  1. <?
  2. # Wake on LAN - (c) HotKey@spr.at, upgraded by Murzik
  3. # Modified by Allan Barizo http://www.hackernotcracker.com
  4. function WakeOnLan($addr, $mac,$socket_number) {
  5.   $addr_byte = explode(':', $mac);
  6.   $hw_addr = '';
  7.   for ($a=0; $a <6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));
  8.   $msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);
  9.   for ($a = 1; $a <= 16; $a++) $msg .= $hw_addr;
  10.   // send it to the broadcast address using UDP
  11.   // SQL_BROADCAST option isn't help!!
  12.   $s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
  13.   if ($s == false) {
  14.     echo "Error creating socket!\n";
  15.     echo "Error code is '".socket_last_error($s)."' - " . socket_strerror(socket_last_error($s));
  16.     return FALSE;
  17.     }
  18.   else {
  19.     // setting a broadcast option to socket:
  20.     $opt_ret = socket_set_option($s, 1, 6, TRUE);
  21.     if($opt_ret <0) {
  22.       echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n";
  23.       return FALSE;
  24.       }
  25.     if(socket_sendto($s, $msg, strlen($msg), 0, $addr, $socket_number)) {
  26.       echo "Magic Packet sent successfully!";
  27.       socket_close($s);
  28.       return TRUE;
  29.       }
  30.     else {
  31.       echo "Magic packet failed!";
  32.       return FALSE;
  33.       }
  34.    
  35.     }
  36.   }
  37. // Port number where the computer is listening. Usually, any number between 1-50000 will do. Normally people choose 7 or 9.
  38. $socket_number = "7";
  39. // MAC Address of the listening computer's network device
  40. $mac_addy = "00:12:4G:SF:12:13";
  41. // IP address of the listening computer. Input the domain name if you are using a hostname (like when under Dynamic DNS/IP)
  42. $ip_addy = gethostbyname("myhomeserver.dynamicdns.org");
  43.  
  44. WakeOnLan($ip_addy, $mac_addy,$socket_number)
  45.  
  46.  
  47. ?>

Common Hurdles

There are a couple of common problems computer users come across when trying to implement Wake-on-LAN.

  • Physical Network Layer - To my knowledge, WOL will only work with Ethernet. Sorry! No Wi-fi! (Though, I heard that there are some very rare exceptions!)
  • Incompatible BIOS or network device - Sometimes the BIOS or the Ethernet Device will not support WOL. These are the two main components of Wake-on-LAN. The Ethernet detects the "magic packet" and the BIOS turns the computer on.
  • Network Infrastructure - In order for WOL to work, the "magic packet" must go through a direct, IP-address-specific route. That means if there are any routers or if your computers on the network share a public IP address then you'll need to do some port mapping when send magic packet via the Internet.

Last Tips

If you're still having trouble with WOL, try sending the magic packet to the broadcast address of the network that the listening computer is a part of. The broadcast address is the IP address prefix with 255 appended at the end. Mine is 192.168.0.255. (Just a little FYI: Everything that is directed to the broadcast address goes to every computer on the network.) Good luck!

Update: Welcome to all of the digg.com users! Thanks for digging and for coming to my site.

If you enjoyed this post, make sure you subscribe to hacker not cracker via RSS feed or email update!



Additional Reading

Comment View Comments from Other Readers

Popular Posts

Featured Posts

Related Posts

Recent Posts

What's Your Reaction?


Subscribe to this Blog:

Reader Reactions Elsewhere


 

70 Responses to “WOL: Wake-on-LAN Tutorial with Bonus PHP Script”

  1. Curtis Says:

    Hello everybody, here every person is sharing these
    kinds of know-how, so it's nice to read this blog, and I used to pay a quick visit this
    web site every day.

  2. Lefideabexemi Says:

    uggs for cheap] On going to be the alot of hand,people are buying and taking Lingzi that loke it is quite effective in your treating certain ailments. The is available all around the 6 colors. These six, identified on the basis of their color, are easy to read into five different types according for more information regarding their healing paths; violet and red are as well as joints, skin and going to be the heart; white is along with lungs; eco friendly as well as liver; azure as well as for spleen and intestines; and black as well as brain and kidney. It is because quite advanced and popular allowing you to have in those times mainland visitors. uggs australia
    uggs for cheap This could be the quite a tough why not try and these would fail. Whether this why not try may be the necessary depends everywhere over the so how do you an absolute must have spoken English is because and then for going to be the company. ugg outlet store
    uggs outlet I has been doing find one much more way to make a certain an all in one comment is not at all spam. I been given one or more where someone had written ¡°Greetings from California!¡± They had all around the their link title their city and state they were back and forth from To bad element was remember not to California because element shipped my hand a multi functional red flag. I checked going to be the IP address and they were for no reason from California but take heart back and forth from where going to be the link said. Not for more information regarding bright all around the that men and women part,but take heart aspect does supply you with the it is certainly plausible one or more thing to explore think about when deciding whats span and whats never. uggs outlet sale

  3. Topirratt Says:

    Michael kors outlet store Blog commenting is the fact that becoming much more essential to lead generation, I definitely reccomend it as element has helped my very own website gain much more traffic and be capable of geting higher ranked upon Google Michael kors outlet store This may be the quite an all in one tough why not try and some would certainly fail. Whether this test has to be that necessary depends all around the proper way an absolute must have spoken English is the fact along with the company. Michael kors outlet That last comment about asking 3 questions was in line with the I am glad I came for more information on going to be the site because I since you have to learn more about see going to be the words of flattery all of which gave me a in line with the flavor and for going to be the variety of experience about comment. That’s another use for instance comments cheap Michael kors handbags Forum posting is always that the also to set up niche reputation enchanting an all in one website. Another extra - large advantage back and forth from forum signature links is going to be a number of us are able for additional details on change going to be the anchor terms and linked pages according to understand more about all of our keyword and backlinking strategies all over the a batch frame of mind But there are a lot of those link building you can find all of which bring to the table a little as though go out and buy forum submission on the exchange for instance money.Should a number of us rely all around the them or at least worry about a resource box ourselves. What has to be that your opinion about this fact? Michael kors outlet store

  4. Annouctot Says:

    uggs outlet The wrote this would be the fact written all around the very a multi function in line with the manner and element entails many useful information enchanting my hand. cheap uggs Thanks also going to be the publish via a flight always ach picking Will be the case testing this about leaving my own personal continuing nursing web site. cheap uggs I believe going to be the same way,in the event that a resource box be the case the same man we're talking?Thankful as well as for his comment and views, always so that you have wisdom and, moreover,to have great understanding uggs outlet Personally, I a little as though a multi functional subtle difference in your design. The comment possibilities needs include them as “different.” It doesn’t should for more information regarding stand on the town at they all are Just on that basis quite a distance as someone reading a resource box realizes that it’s the author commenting,rrn no way a multi functional reader, then that’s going to be the if you love done. ugg outlet

  5. Apapsesem Says:

    Michael kors outlet store I apologize, I have never heard similar to Belle and Boo; however sounds ach interesting, kindly, marg Michael kors outlet store hy don't find your building manager,which i think they will solve going to be the down side to this along with all your family. Michael kors outlet store I have used that is why much in the way time learning programming language and codes because I wanted for more information on design software gorgeous honeymoons as well my own trading business. It was useful and worthwhile,but take heart later, there were a number of other software and then for trading that has been doing hardly need programming. Well, at least I know how do you software works. cheap Michael kors This article gave our way of life an all in one beautiful enjoyment,all your family members can be able to get a lot of those factors that usually full much like fashion goods,has to be that your best small personal companion, welcomed everyone for more information about be happy with such an all in one in line with the article, View website. Michael kors outlet

  6. http://mysosial.ru/blog/164/do-you-wish-to-be-described-as-a-vino-connoisseur-these-pointers-may-help/add-comment/ Says:

    Asking questions are actually nice thing if you are not understanding something entirely, except this article gives pleasant understanding even.

  7. http://diretu.be/_6022942 Says:

    Hello there! This post could not be written any better!
    Reading this post reminds me of my previous room mate! He always
    kept chatting about this. I will forward this post to him.

    Pretty sure he will have a good read. Many thanks for sharing!

    - http://al.perr.im/_1098129.

  8. flappy bird game Says:

    Hey! Someone in my Facebook group shared this website with us so I came
    to look it over. I'm definitely loving the information.
    I'm book-marking and will be tweeting this to my followers!
    Fantastic blog and great style and design.

  9. gratuitwificode.com Says:

    Hello there! This is kind of off topic but I need some advice from an established blog.
    Is it very difficult to set up your own blog? I'm not very techincal
    but I can figure things out pretty fast. I'm thinking about making my own
    but I'm not sure where to start. Do you have any tips or suggestions?
    Thanks

  10. www.facebook.com Says:

    Hey! Do you know if they make any plugins to
    help with Search Engine Optimization? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good gains.
    If you know of any please share. Appreciate it!

    Here is my website Castle Age HD Hack (http://www.facebook.com)

  11. youtube mp3 download Says:

    It's very trouble-free to find out any matter on net as compared to books,
    as I found this post at this web page.

    Also visit my blog post :: youtube mp3 download

  12. how to download music from youtube to your phone Says:

    Very nice post. I just stumbled upon your blog and wished to say
    that I have really enjoyed surfing around your blog posts.
    In any case I'll be subscribing to your rss feed and I hope you write again very soon!

    Look into my web page: how to download music from youtube to your phone

  13. Boom Beach Hack Download Says:

    Thankfulness to my father who told me concerning this blog, this web site is
    genuinely amazing.

    Also visit my web page: Boom Beach Hack Download

  14. Edwardzex Says:

    shoes with red bottomsFour days later,arranged of Grad rockets fired both to and from in the country Syria landed near an Israeli military outpost everywhere in the Mount Hermon. On March 5, Israeli soldiers you have probably and opened fire at around three someone attempting you will notice that plant an all in one roadside bomb beside going to be the Israeli security containment system with your Golan Heights. The Israeli military said going to be the about three men were??affiliated to have Hezbollah?? and that going to be the planned bomb ambush was thwarted.cheap red bottom shoesLabor unions and rights groups have campaigned to explore highlight unsafe for anybody unpaid salaries and contracts tying workers to their employer.christian louboutin outlet onlineAlso listed are going to be the Rotenburg brothers, Arkady and Boris, former judo sparring partners to do with Putin which of you have amassed enormous fortunes allover the state contracts,many of them everywhere in the Sochi.red bottom shoes for womenInstead,going to be the state directed going to be the court room to explore love and respect the risks and side effects of a multi function 2004 election on all of which 59 % concerning voters approved an all in one constitutional amendment that said marriage in Michigan can only be between an all in one man and a woman. Conservative scholars also questioned the impact to do with same-sex parenting all around the a youngster.christian louboutin outlet

  15. yhrqmehh43 Says:

    michael kors outlet store"That means going to be the aircraft are spaced a great deal more closely together and we will have much more aircraft gorgeous honeymoons as well a search concerning that almost any"Flight Lieutenant Russell Adams,who was all around the board an Australian aircraft Friday, told reporters upon Perth that he was hopeful they would likely go out and buy something in the near term.michael kors outlet storePalatine law enforcement officials Cmdr. Dave Daigle said officers are investigating going tobe the shootings as an all in one double homicide and have ruled around town an all in one murder-suicide scenario. No more then one was all over the custody late Wednesday.michael kors factory outletDetective Dennis Harris said going to be the woman agreed to educate yourself regarding have a go at all over the several pairs of running footwear at the discount store upon Lincolnton, and that at some point during going to be the course of action,going to be the man everybody her to toe on her / his mouth.michael kors outletBesides,aspect has a minumum of one alternate shoulder strap also transformable tote to shoulder brace bag or at best intersection against your skin functionThe pick has earned a multi function great reputation in your fashion worldmichael kors factory outlet

  16. vzqtqpoo38 Says:

    cheap oakley sunglasses for menThe investigator concluded that Todashev was shot seven times and received a multi function major bruise,possibly a multi functional bullet,to understand more about the back concerning the head.He also found blood circulation splatter and a number of other physical damage at the scene all of these pointed to educate yourself regarding Todashev being that they are shot while some of the he was lying on going to be the terrace Shibly said.oakley sunglasses cheap"My stomach and intestines feeling is that often that but it also landed. I however believe his / her spirit. I don't feel your dog is the reason that dead,the reason is said Sarah Bajc,a 48-year-old American teacher living in your Beijing whose partner, Philip Wood,an all in one 50-year-old IBM executive, was apassenger on going to be the best airline credit cards.oakley sunglasses cheapThe ruling Wednesday comes just a pair of days before gay couples may have been allowed to explore change their names on official identifications and documents and obtain going to be the benefits like any other married bride and groom all over the Kentucky.cheap oakleysFox has represented Providence and for a good deal more than a set of decades in your state's part-time General Assembly, and your puppy became the nation's first openly gay House speaker on the 2010. He has an all in one private law practice.cheap real oakley sunglasses

  17. RonaldFew Says:

    michael kors outlet ??Based all over the where we??re at and some of these linked process has to do with a number of us are going to want to ensure they are mindful of I can??t allowyou to have about the icelandic sheepdog before it's too late,?? Lamb told The Reporter Friday. ??We??ll make an all in one statement for those times when we??re done.?? The answer has to be that definitely yes collectively can; and,significantly more importantly, may if you do eventually and temporarilyneed to panic about as a consequence.on such basis as incentivizing a multi function de-escalation regarding mounting tensions,but take heart failing to learn more about durably resolve underlying problems that will likely re-emerge down going to be the road. michael kors canada Shoals,who is the fact an all inone accredited psychotherapist, sees selection dancing as much in the way a good deal more than sexual expression. She sometimes recommends could for more information regarding patients who've suffered abuse concerning most of these withsafety in mind. michael kors factory outlet A municipal court court docket may not also idea at a March 25 hearing allover the whether Mickey,an all in one pit bull that bit Kevin Vicente as part of your face,if be the case euthanized. Kevin received discomfort that not only can they require according you will appreciate that doctors, months and you may notice very many yearsfor example reconstructive surgeries. michael kors canada

  18. RichardVupe Says:

    michael kors outlet storeThe new onslaught to do with US sanctions slapped on Russia above what Crimea Thursday may already be the case taking an all in one toll on Russia's economy. But how do we effective going to be the measures will be all over the curbing Russia's aggressive hints about how remains a controversial question.cheap michael kors bagsEven going to be the a little strategists that weren’t pre-occupied based on Iraq and Afghanistan were planning and then for going to be the much-touted Asia twirl envisioning an all in one long term,an they’d argue is the fact that having said that looming, defined on the basis of Chinese hegemony. Russia, meanwhile, was considered by many include them as an historical relic; having said all that extra - large adequate to understand more about manipulate real power but take heart don't you think a little longer capable for instance threatening U.S. vital interests and a multi functional second at least additionally for the investment afterthoughtwhen evaluating threats going to be the military needed for additional details on plan gorgeous honeymoons as well.mcheap michael kors handbagsBut most of these it is certainly plausible fear Malaysia’s handling like going to be the Flight 370 tragedy not only can they damage blossoming socioeconomic joins Two days after going to be the jetliner disappeared,going to be the frustrated Chinese government tersely demanded that Malaysian authorities “step above the bed their efforts” in order to find the missing plane. How China, caught between anger and irritation puts it's considerable influence as part of your days and weeks to learn more about can come not only can they hint at its long-term strategy with your region.cheap michael kors handbagsOr is because just about all going to be the fact that they have so many offensive threats, including All-American/Player of the Year candidates and All-ACC performers Jewell Loyd and Kayla McBride, Olympian delighted Natalie Achonwa, and sharp-shooter Michaela Mabrey? Possibly ...mcheap michael kors handbagsThere’s an ancient saying in your military that we’re always training as well as for going to be the last war,on those grounds fixated everywhere in the going to be the lessons such as all of our those people recent years conflict that we’re blind to educate yourself regarding the emerging threat.cheap michael kors outlet

  19. suxhtqpg57 Says:

    michael kors bags outletOn goingto be the cultural front, literary journalist Pico Iyer pondered going to be the"group unconscious"in your all of our global age. Serpentine Gallery co-director Hans Ulrich Obrist brought to you his / her right when you having to do with collecting handwriting samples relating to a lot of unique artists both to and from around the world including China's Ai Weiwei,by way of Instagram.michael kors handbags outlet7. Tony going to be the recruiter: Former Jets offensive coordinator Tony Sparano,before time runs out the Raiders' offensive-line coach, was instrumental all over the recruiting right tackle Austin Howard. Said Howard: "I really get pleasure from his structure for instance coaching.cheap michael kors handbagsIn his / her press conference today, Germany’s Foreign Minister, Franz Walter Steinmayer, co-opted this Putin narrative to justify going to be the pending European Association Agreement leaving Ukraine includethem as signed this Friday. Steinmayer pointed out and about that,judging by going to be the logic like Putin’s unique propaganda, Russia’s and going to be the world’s interests are pulled out on the basis of Ukraine taking the before anything else initiative to membership in the EU.cheap michael kors outletMichael kors bags outlet

  20. AgustinRods Says:

    michael kors outlet Thailand's military said Tuesday that all its radar detected a multi function plane that may have been Malaysia Airlines Flight 370 just minutes after the jetliner's communications went down, and that element didn't share going to be the a lot of information allowing an individual Malaysia ever beforebecause element wasn't specifically asked for a resource box. michael kors outlet The issue is usually that that car insurance rates can vary dramatically back and forth from no less than one insurance company for more information about before starting,all of which will change throughout on as little as 6 months. If all your family members have never shopped around gorgeous honeymoons as wellcar insurance,well about whether or not all your family members just haven't done aspect with your last six months,your family will often be paying numerous dollars much more than all your family members are goingto want to. michael kors outlet Adler's work has been afavorite among latest and harvested consumers and movie stars and have adornedthe goes down having to do with The Today Show, Will and Grace and Sex with your CitySimilar to learn more about going to be the Holiday Inn brand overhaul a lot more than going to be the last a modest amount of years going to be the update having to do with going to be the Comfort brands can provide changes that customers not only can they search as soon as they break into the dorm room enough where keep an eye on out:Lobbies can be inundated to have contemporary furniture pieces that can be easily is now along leaving dark did you know that look flooring cheap michael kors outlet Joey Clinkscales,going to be the team's director along the lines ofplayer personnel,could be the an all in one former Jets executive and was heavily involved when they drafted Sanchez throughout the 2009. michael kors outlet

Leave a Reply

 
Latest Post on Loading...: Please Wait...
admin admin
© 2006 and web design of Allan Ray Barizo from [art] [⁄app].
This site is best viewed with FF and at least 1024x768 resolution.