Ubuntu에서 WOL기능 사용하는 방법
참고: https://necromuralist.github.io/posts/enabling-wake-on-lan/
WOL 활성화 여부 및 WOL 활성화 시킬 수 잇는 툴인 ethtool을 설치한다.
$ sudo apt install ethtool |
ip a 명령으로 WOL을 활성화할 유선랜을 확인한다.
WOL 활성화 여부를 확인한다.
$ sudo ethtool enp2s0 Settings for enp2s0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: Unknown Supports Wake-on: pg <-지원하는 WOL 종류다. WOL은 여러가지가 있으며 자세한 링크는 상단 '참고'링크 확인. Wake-on: d <-현재 WOL 활성화 여부 d는 Disable로 WOL이 설정되어 있지 않다는 의미이다. Current message level: 0x0000003f (63) drv probe link timer ifdown ifup Link detected: yes |
아래명령으로 매지패킷을 활용한 WOL 활성화 한다. 참고로 1회용이며, 다시 켜지면 WOL이 비활성화된다.
$ sudo ethtool --change enp2s0 wol g |
아래 명령으로 활성화 되었는지 다시 확인해 본다.
$ sudo ethtool enp2s0 Settings for enp2s0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: Unknown Supports Wake-on: pg Wake-on: g <- g모드로 WOL이 설정되어있다. g는 매지패킷을 모드이며, 다른 모드는 본 글의 상단 '참고'링크 확인. Current message level: 0x0000003f (63) drv probe link timer ifdown ifup Link detected: yes |
다른 컴퓨터로 테스트 하기
$ sudo apt install wakeonlan $ wakeonlan 38:d5:47:79:ab:0b |
컴퓨터 켜질 때, WOL 활성화 자동 수행하는 방법
WOL활성화 명령은 1회용이며, 컴퓨터가 다시 켜지면 비활성화 된다. 따라서 켜질 때 마다 매번 WOL을 활성화해야하는 불편함이 있다. 따라서 해당 명령을 서비스로 등록해서 컴퓨터가 켜질 때 자동으로 수행 되도록 해야 한다.
ethtool 명령의 경로를 알아낸다.
$ which ethtool /sbin/ethtool |
서비스를 생성한다.
$ sudo vi /etc/systemd/system/wol.service |
[Unit] Description=Enable Wake On Lan
[Service] Type=oneshot ExecStart = /sbin/ethtool --change enp2s0 wol g
[Install] WantedBy=basic.target |
서비스는 아래 링크 참조
https://www.shubhamdipt.com/blog/how-to-create-a-systemd-service-in-linux/
https://linuxhandbook.com/create-systemd-services/
생성한 서비스를 활성화한다.
$ sudo systemctl daemon-reload $ sudo systemctl enable wol.service |
이렇게 하면 컴퓨터를 껐다 켜도 다시 활성화된다.