jueves, 2 de diciembre de 2010

MAC problems in ubuntu; changes on each reboot

I'd a problem with ubuntu and my ethernet card:

It changes the MAC in each reboot, so when I did a WOL the MAC changes for another (randomly defined) and I had to reconfigure the client in each reboot...

It also had done another problem that solved here: MAC changed so ubuntu didn't recognize the ethernet card and created a new entry for it in 70-persistent-net-rules creating new sequentialy eth1, eth2, eth3, eth4... in each reboot. I said in a previous post how to avoid that sequence but this is a better way:
The problem appears to be that the kernel didn't recognize the ethernet adapter manufacturer (that have it's own code: the first 3 numbers of the MAC) and changed it for another randomly choiced number (so in each reboot you have a random new MAC).
 A bug -I think- in a driver called forcedeth:





There is too the MAC address

Download macchanger (it can be do too using ifconfig) via:



Or apptitude, or synaptic....

Make a file using it and wiving it a MAC number of your choice nd your ethernet name (mine is eth0, find it typing 'ifconfig' in console):




Save it. Copy it to /etc/init.d (you must be root, so do it graphically 'sudo nautilus' in console, to do in console go to file's directory and type 'sudo mv ./(filename) /etc/init.d/' without ' and changing (filename)  with you file name)

Change file  owner via file properties in nautilus or

sudo chown root:root (filename)

And make it executable via properties (giving it permissions of execution and read for all) or via console:


sudo chmod 755 (filename)

After this put it in your startup sequence:

sudo update-rc.d -f (filename) defaults 21

The 21 its the position in the startup sequence, this is important: i've tried 20 and didn't works and 80 and it worked to change the MAC but not for WOL.

This way you always will have the same MAC on your PC on startup.

Good luck

Wake On Lan

I've thought that as a way to improve my English I can write in English and tell to my brother to check it.... so you know... im sorry about my poor English.

Ubuntu tematic post:

Today i've enabled WOL on my server, to put it On remotely across internet (stop a PC is to type 'sudo halt' in a remote console, but to start it WOL is needed) -so it should stop being a public server an I could start it when I want to down/up load something in it via FTP or do whatever I've to do via ssh or VNC (yes, i'll put VNC too) -

Well... usually that's not a hard operation, you only have to enable the WOL in your server's BIOS -look in your motherboard's manual to see how to do it, changes between companies-, then tell your PC to ear to WOL. To do this, in ubuntu (to say your PC to wait for WOL signals) you must use ethtools. It's a program that isn't by default in ubuntu but is in repos, so you can instal it writing:


sudo apt-get install ethtools

Or using synaptic or apptitude or whatever you use. You have to run this command every time you start your computer:

sudo ethtool -s wol g

To know whats your ethernet name type 'ifconfig' in a console (whitout the '), press enter and it will say somethin like this:

eth0      Link encap:Ethernet  direcciónHW 00:12:34:56:78:90 
          Direc. inet:192.168.1.2  Difus.:192.168.1.255  Másc:255.255.255.0
          Dirección in... (a lot of stuff more)

So, in my case the command will be:

sudo ethtool -s eth0 wol g

This way you say to ubuntu to change (-s) your eth connection (, in my case is eth0) to WOL (wol) on 'Magic packet' (it's easy to do it by sending a special created UDP packet).

But wait, typing that command on every reboot is annoying... better to automatize it...

To do this you must make a new text file with this text inside:
#!/bin/bash
ethtool -s eth0 wol g
exit

Save it. Copy it to /etc/init.d (you must be root, so do it graphically 'sudo nautilus' in console, to do in console go to file's directory and type 'sudo mv ./(filename) /etc/init.d/' without ' and changing (filename)  with you file name)

Change file  owner via file properties in nautilus or

sudo chown root:root (filename)

And make it executable via properties (giving it permissions of execution and read for all) or via console:


sudo chmod 755 (filename)

After this put it in your startup sequence:

sudo update-rc.d -f (filename) defaults 80

80 means 'at the end of secuence' (the end is in 99). Really, we haven't any hurry to run it when start, we only have to run it always...

This way the computer should be ready to WOL, now we only have to configure a client (android client in my case) and the router (I asume you have done it before to configure 'amule', we have to redirect one port, whatever you want, to the WOL port -9 by default- of your PC)

In client side you need only this info: your stopped PC's IP, and MAC address. To get your MAC, like previously, type 'ifconfig' and :


eth0      Link encap:Ethernet  direcciónHW 00:12:34:56:78:90 
          Direc. inet:192.168.1.2  Difus.:192.168.1.255  Másc:255.255.255.0

In my case my MAC number is 00:12:34:56:78:90

At this point: I've had problem because my MAC changed on each reboot but I've solve it in a nice way :) It was an old 'solved' problem and it have a new solution. I have a post down here to explain how I've solve it.

I've use this application for android, pretty simple and clean, I like it  (this is its page with instructions to WOL in windows), but they are applications for all operating systems (I promisse that I'll do one, it appears to be easy to do one and a good starting point to android and UDP programing).

Name is for you to identify the PC to wake up.
MAC: the mac address
IP or Domain: PC's IP or domain (your external IP or your DynDNS domain are valids)
Port: The port you hace redirected or the PC's port to WOL (default 9)

Giving this information to it the client should be working.

Good luck

PS: I've find the main info to do the WOL in ubuntuforums in this thread