Remote WoL with an android phone via SSH
=
###### tags: `Note`
## Use Cases
This guide is useful if:
1. Your router is using NAT but doesn't support port forwarding (virtual servers).
2. Your internet service provider (ISP) places you behind a Carrier-Grade NAT (CGNAT) and your router doesn't support VPN connections.
---
## Steps
0. **(Optional)** Install a VPN client on your Android device if you plan to wake up devices over a VPN.
1. Install **Termux** from the [Google Play Store](https://play.google.com/store/apps/details?id=com.termux) or [F-Droid](https://f-droid.org/en/packages/com.termux/).
2. In Termux, install the `wol` and `openssh` packages.
```bash
pkg update && pkg upgrade -y
pkg install wol openssh -y
```
3. Find your **VPN IP address** (`ip_vpn`) and your **LAN's broadcast IP address** (`ip_broadcast`). You can find these using the `ifconfig` command.
```bash
ifconfig
```
For example, in the image below, the VPN IP is `10.0.10.20` (under the `tun0` interface) and the LAN broadcast IP is `10.0.0.255` (under the `wlan0` interface).

4. Find your Termux username (`uname`) and set a password for the SSH connection.
```bash
whoami
passwd
```
5. Start the SSH server. It runs on port **8022** by default in Termux.
```bash
sshd
```
6. Find the **MAC address** (`mac`) of the computer you want to wake up. **Note:** The target computer and your Android device must be connected to the same local network. The MAC address must be in the `XX:XX:XX:XX:XX:XX` format.

7. Finally, from another device (like a laptop or another phone) connected to the same VPN or local network, run the following command. Replace the placeholders with your information.
```bash
ssh <uname>@<ip_vpn> -p 8022 "wol -i <ip_broadcast> <mac>"
```
Enter the password you set in **step 4** when prompted. Your device should now wake up.
Done.