Linux Remote Boot

Source: Internet
Author: User
Article Title: linux Remote Boot. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

I. Under what circumstances do I need to remotely start the instance?

If our servers are not deployed locally (normally, we host the servers in the IDC ),

In addition, there are more than one server in the data center. When one of the servers is disabled, we can remotely connect to a server without shutdown,

Then start the instance remotely.

2. software required for Remote Boot

It needs the software wakeonlan,

Where can I get it?

Its official site is: http://sourceforge.net/projects/wake-on-lan/

If you use an rpm package, you can download: http://dag.wieers.com/rpm/packages/wol/ from here

If you use fedora, you can run the yum command to install it:

Yum install wol

3. How to enable remote boot?

Do not rush to shut down your linux server first. Are you sure it supports remote boot?

Step 1: log on to the target server and run the ethtool command to print the NIC information.

[Root @ localhost lhd] # ethtool eth0

Settings for eth0:

Supported ports: [tp mii]

Supported link modes: 10 baseT/Half 10 baseT/Full

100 baseT/Half 100 baseT/Full

Supports auto-negotiation: Yes

Advertised link modes: 10 baseT/Half 10 baseT/Full

100 baseT/Half 100 baseT/Full

Advertised auto-negotiation: Yes

Speed: 100 Mb/s

Duplex: Full

Port: MII

PHYAD: 32

Transceiver: internal

Auto-negotiation: on

Supports Wake-on: pumbg

Wake-on: d

Current message level: 0x00000007 (7)

Link detected: yes

As you can see, ethtool lists all the NIC information. We only care about these two items:

Supports Wake-on: pumbg

Wake-on: d

If the value of wake-on is d, wake on lan is disabled.

If the value is g, wake on lan is enabled.

Because wake on lan is disabled on this machine, use the following command to enable it:

[Root @ localhost lhd] # ethtool-s eth0 wol g

Run the ethtool command to view the information and you will find that:

Wake-on: g

OK. The NIC of the target machine supports remote boot. The local MAC address is as follows:

[Root @ localhost lhd] # ifconfig

Eth0 Link encap: Ethernet HWaddr 00: 03: 0D: 1D: 1F: 97

Inet addr: 192.168.6.101 Mask: 255.255.255.0

Up broadcast running multicast mtu: 1500 Metric: 1

RX packets: 34470 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 35377 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 FIG: 1000

RX bytes: 31559763 (30.0 MiB) TX bytes: 5340032 (5.0 MiB)

Interrupt: 5 Base address: 0x2c00

Record the HWaddr 00: 03: 0D: 1D: 1F: 97 item.

Now you can try to disable the target machine.

Step 2: Start the instance

Now we need to log on to the machine with the wake on lan software installed, and run the following command on it:

Wol 00: 03: 0D: 1D: 1F: 97

Later, you will find that the target machine has been started and can be logged on.

4. Learn more:

1. The-s parameter of ethtool is used to modify the settings of the specified Ethernet device.

2. The default value of wol is d, which means disable.

The modified value is g, meaning that Wake on MagicPacket (tm)

It also has several values:

P Wake on phy activity

U Wake on unicast messages

M Wake on multicast messages

B Wake on broadcast messages

A Wake on ARP

If you are interested, you can view it through man ethtool.

3. After the machine is restarted, The eth0 settings will return to the Wake-on: d status,

How can this problem be solved?

Two methods: the first is our inertial thinking;

Append the/sbin/ethtool-s eth0 wol g command to the/etc/rc. local file,

It will be automatically executed after the next boot

Second: edit/etc/sysconfig/network-scripts/ifcfg-eth0

(Configuration file of eth0 Nic), add the last line:

ETHTOOL_OPTS = "wol g"

4. Limitations of network wake-up:

It can only be applied in the LAN, but cannot run through the Internet. Why?

After the machine is disabled, the machine is completely awakened by the NIC. At this time, the machine is disabled and no operating system is running,

In other words, tcp/ip protocol is not supported, and it cannot be run over the Internet.

That is to say, if we only have one machine in a LAN, we will not be able to use this function.

We must be able to log on to a machine in the lan and run wake on lan to wake up the target machine.

The prerequisite is that the target machine and the machine we log on to are in the same LAN.

5. Another point: the target machine to be remotely started must be plugged in, and the machine without power in can also be turned on only in movies.

The following describes how to use wakeonlan in linux:

Assume that the IP address of the remote computer to be awakened is 12.34.56.78, And the Mac address is 01: 02: 03: 04: 05: 06.

$ Wakeonlan-I 12.34.56.78 01: 02: 03: 04: 05: 06

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.