Comet Pro (GL-RM10): Share Wi-Fi uplink to the Ethernet port (NAT + DHCP) – working scripts

Comet Pro (GL-RM10): Share Wi-Fi uplink to the Ethernet port (NAT + DHCP) – working scripts

Hi all,

I wanted the target PC connected to the Comet Pro's Ethernet port to get internet through the Comet's Wi-Fi connection, e.g. on the road with no router or switch around. There is no built-in option for this (only Wi-Fi/Ethernet failover), but it works fine with the tools already on the device (iptables, dnsmasq) via SSH.

Tested on GL-RM10, firmware [FW-Version]. Unofficial, use at your own risk. Everything the scripts change is runtime-only; a reboot restores the original state.

How it works

  • The Comet stays connected to Wi-Fi (wlan0) as usual.
  • eth0 gets a private subnet (10.254.254.0/24 by default, with automatic fallback to 172.31.254.0/24 / 192.168.254.0/24 if it collides with the Wi-Fi network).
  • dnsmasq serves DHCP + DNS on eth0 only; traffic is NATed out via wlan0.
  • Works in any network the Comet itself is online in (no assumptions about the foreign network, no free IP needed).
  • KVM web UI, GL cloud and Tailscale on the Comet keep working.

Step 1 – Important: set Ethernet to Static in the web UI

With Ethernet in DHCP mode and a cable plugged into a PC (which runs no DHCP server), the firmware falls back to zeroconf (169.254.x.x) and installs a default route via eth0 that takes precedence over Wi-Fi. Result: after a reboot with the cable plugged in, the Comet is effectively offline.

Fix: Network settings → Ethernet Mode Static:

Field Value
IP Address 10.254.254.1
Netmask 255.255.255.0
Gateway 10.254.254.254 (dummy, required by the UI)
DNS Server 10.254.254.1

With this, Wi-Fi keeps priority and the Comet survives reboots with or without the cable. Verify:

ip route get 1.1.1.1

It must go dev wlan0.

Step 2 – Scripts

Store them in a persistent location, e.g. /root.

/root/share.sh

#!/bin/sh
# Internet sharing wlan0 -> eth0 (NAT + DHCP + DNS)
WAN=wlan0
LAN=eth0
NETS="10.254.254 172.31.254 192.168.254"

# stop running instance
[ -x /root/stopshare.sh ] && /root/stopshare.sh >/dev/null 2>&1

# stop firmware DHCP/zeroconf on eth0 and clean up eth0
for p in $(ps -ef | grep -E '[u]dhcpc|[z]cip|[a]utoip' | grep -w "$LAN" | awk '{print $2}'); do kill $p; done
ip addr flush dev $LAN
ip route flush dev $LAN 2>/dev/null

GW=$(ip -4 route show default dev $WAN | awk '{print $3}' | head -1)
[ -z "$GW" ] && { echo "ERROR: $WAN has no gateway"; exit 1; }

# pick a private subnet that does not collide with the Wi-Fi network
for N in $NETS; do
  ip route get $N.1 | grep -q " via " && { NET=$N; break; }
done
[ -z "$NET" ] && { echo "ERROR: no collision-free subnet found"; exit 1; }

# upstream DNS: from resolv.conf, otherwise gateway
DNS=$(awk '/^nameserver/{print $2; exit}' /etc/resolv.conf 2>/dev/null)
case "$DNS" in ""|127.*|::1) DNS=$GW ;; esac
echo "WLAN-GW: $GW  DNS: $DNS  LAN: $NET.0/24"

echo 1 > /proc/sys/net/ipv4/ip_forward

ip link set $LAN up
ip addr add $NET.1/24 dev $LAN

# NAT + firewall
iptables -t nat -A POSTROUTING -s $NET.0/24 -o $WAN -j MASQUERADE
iptables -I FORWARD 1 -i $LAN -o $WAN -j ACCEPT
iptables -I FORWARD 1 -i $WAN -o $LAN -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

# DHCP + DNS on eth0 only (lo excluded: port 53 on 127.0.0.1 is already in use)
dnsmasq -C /dev/null --user=root --group=root \
  --interface=$LAN --except-interface=lo --bind-dynamic \
  --no-resolv --server=$DNS \
  --dhcp-range=$NET.100,$NET.200,255.255.255.0,12h \
  --dhcp-option=3,$NET.1 --dhcp-option=6,$NET.1 \
  --dhcp-authoritative \
  --dhcp-leasefile=/tmp/share.leases \
  --pid-file=/tmp/share-dnsmasq.pid \
  --log-dhcp --log-facility=/tmp/share.log
sleep 1
pidof dnsmasq >/dev/null || { echo "ERROR: dnsmasq not running"; exit 1; }

# watchdog: keep the firmware from taking over eth0 again
(
  while true; do
    for p in $(ps -ef | grep -E '[u]dhcpc|[z]cip|[a]utoip' | grep -w "$LAN" | awk '{print $2}'); do kill $p; done
    ip route del default dev $LAN 2>/dev/null
    ip route del 0.0.0.0/32 dev $LAN 2>/dev/null
    for a in $(ip -4 -o addr show dev $LAN | awk '{print $4}' | grep -v "^$NET.1/"); do
      ip addr del $a dev $LAN
    done
    ip -4 addr show dev $LAN | grep -q "$NET.1/" || ip addr add $NET.1/24 dev $LAN
    sleep 5
  done
) >/dev/null 2>&1 &
echo $! > /tmp/share-watchdog.pid

ip route get 1.1.1.1 from $NET.100 iif $LAN
echo "OK"

/root/stopshare.sh

#!/bin/sh
# stop internet sharing
WAN=wlan0
LAN=eth0
NETS="10.254.254 172.31.254 192.168.254"

for f in /tmp/share-watchdog.pid /tmp/share-dnsmasq.pid; do
  [ -f $f ] && kill $(cat $f) 2>/dev/null
  rm -f $f
done

for N in $NETS; do
  while iptables -t nat -D POSTROUTING -s $N.0/24 -o $WAN -j MASQUERADE 2>/dev/null; do :; done
done
while iptables -D FORWARD -i $LAN -o $WAN -j ACCEPT 2>/dev/null; do :; done
while iptables -D FORWARD -i $WAN -o $LAN -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT 2>/dev/null; do :; done

ip addr flush dev $LAN
ip route flush dev $LAN 2>/dev/null

echo "Sharing stopped"

Usage

chmod +x /root/share.sh /root/stopshare.sh
/root/share.sh       # start
/root/stopshare.sh   # stop

Set the target PC to DHCP. It gets an address from 10.254.254.100 to .200, with gateway and DNS 10.254.254.1.

Notes

  • Not started automatically on purpose. After a reboot, sharing is off until you run share.sh again.
  • Firmware updates may change the behavior. Re-check ip route get 1.1.1.1 afterwards.
  • The target PC is not reachable from the Wi-Fi network (NAT). For remote access, install Tailscale on the target PC. Using the Comet's built-in Tailscale as a subnet router for 10.254.254.0/24 should also work, but I haven't fully tested it yet.
  • Windows puts the network behind the Comet into the "Public" profile. Keep that in mind for firewall rules.
  • I first tried a real L2 bridge / proxy-ARP + DHCP relay to put the PC into the same subnet as the Wi-Fi. That is not reliable: a Wi-Fi client can't bridge foreign MACs, and many networks (hotels, enterprise Wi-Fi) block relayed DHCP. NAT is the robust option.

Feature request for GL.iNet

Since the hardware and the needed tools are already on the device, a simple "Share Wi-Fi to Ethernet port" toggle in the web UI would be great, and it would also avoid the zeroconf default-route issue described in Step 1.

I have other solutions in play at the moment, but FWIW I have a legitimate use case for this. I have some PCs that are only connected through WiFi, which removes the possibility of Wake On LAN. This setup would allow the physical Ethernet port to be connected, WoL to be active, and allow me to "wake up" the PC remotely for updates before I'm physically there.

Update: Comet Pro (GL-RM10) as Tailscale subnet router for the target PC

Follow-up to my post about sharing the Comet Pro's Wi-Fi uplink to the Ethernet port (NAT + DHCP via share.sh).

In the notes I wrote that using the Comet's built-in Tailscale as a subnet router "should also work, but not fully tested". It's tested now and works: the target PC behind the Comet is reachable from any device in my tailnet (ping, RDP, SSH), without installing anything on the target PC.

Prerequisites

  • Sharing is set up as described in the first post (Ethernet on Static 10.254.254.1/24 in the web UI, share.sh running).
  • Tailscale on the Comet is logged in. I recommend doing the login via the Comet web UI, so the GL firmware manages the Tailscale connection itself.

Check on the Comet:

tailscale status

The Comet must show up with its 100.x.y.z address.

Why this works almost out of the box

The GL firmware already prepares Tailscale for LAN access. iptables -t nat -L POSTROUTING -n -v shows this rule:

MASQUERADE  *  eth0  100.64.0.0/10  0.0.0.0/0

Traffic coming from the tailnet (100.64.0.0/10) is masqueraded when it leaves via eth0. The target PC sees the Comet (10.254.254.1) as the source and needs no route back into the tailnet. ip_forward is already enabled by share.sh.

The only missing piece is advertising the route.

Step 1 – Advertise the subnet

On the Comet:

tailscale set --advertise-routes=10.254.254.0/24

Check:

tailscale debug prefs | grep -A2 AdvertiseRoutes

Step 2 – Approve the route in the Tailscale admin console

login.tailscale.com → Machines → the Comet → Edit route settings → enable 10.254.254.0/24.

Step 3 – Test from another tailnet device

With share.sh running and the target PC connected:

ping 10.254.254.100
mstsc /v:10.254.254.100
  • Windows, macOS and iOS clients accept subnet routes automatically.
  • Linux clients need tailscale set --accept-routes.

Tips

Fixed IP for the target PC

By default the target PC gets the first lease (10.254.254.100). To make it fixed, change the DHCP range in share.sh to a single address:

  --dhcp-range=$NET.100,$NET.100,255.255.255.0,12h \

Do NOT enable --accept-routes on the Comet itself

If another node in your tailnet advertises the Comet's Wi-Fi subnet (e.g. a home subnet router), the Comet would route traffic to its own Wi-Fi gateway into the tunnel and go offline. Tailscale's routing table 52 is checked before the main table. Keep it off:

tailscale set --accept-routes=false

Tailscale will show the health warning "Some peers are advertising routes but --accept-routes is false". That's expected and fine here.

Subnet fallback

share.sh falls back to 172.31.254.0/24 or 192.168.254.0/24 if the Wi-Fi network itself uses 10.254.254.0/24. If you want remote access in that rare case too, advertise all three:

tailscale set --advertise-routes=10.254.254.0/24,172.31.254.0/24,192.168.254.0/24

Windows firewall

Requests arrive with source 10.254.254.1 (local subnet), but Windows classifies the network behind the Comet as "Public". Make sure the RDP rule is enabled for the Public profile:

Get-NetFirewallRule -DisplayGroup "Remote Desktop" | ft DisplayName, Enabled, Profile

(On German Windows the group is called "Remotedesktop".)

After reboots and firmware updates

The advertised route is stored in Tailscale's state and should survive reboots. If the GL firmware ever re-runs tailscale up --reset, it's gone. Re-check with tailscale debug prefs | grep -A2 AdvertiseRoutes. Sharing itself (share.sh) has to be started manually after every reboot anyway.

Result

  • KVM access via the Comet as usual (local, GL cloud, Tailscale)
  • Internet for the target PC through the Comet's Wi-Fi
  • Direct RDP/SSH to the target PC from anywhere via Tailscale, no software on the target PC needed

Again, a native "Share Wi-Fi to Ethernet" toggle plus "Advertise Ethernet subnet via Tailscale" in the web UI would make this a one-click setup. GL.iNet, please consider it!

Hi, thanks for your suggestion and for sharing your script! We've noted it down and forwarded it to our R&D team.