Skip to content

routing with Venus OS

jhofstee edited this page Sep 6, 2026 · 8 revisions

In supported firmware the access point on GX devices is intended to connect to device itself, not to act as a router. That doesn't mean it can't route though, but it is simply not officially supported. So here we go, at your own risk...

To set it up once

Make the rootfs writable and resize it /opt/victronenergy/swupdate-scripts/resize2fs.sh

Enable ip forwarding (replace wifi0 with the interface you want to forward to):

sysctl net.ipv4.ip_forward=1
iptables -A FORWARD -i ap0 -o wifi0 -j ACCEPT
iptables -A FORWARD -i wlan0 -o ap0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -o wifi0 -j MASQUERADE

Enable DNS request on the access point

nano /etc/dnsmasq.ap.conf
change the no-resolv line to #no-resolv
Save and then run: /etc/init.d/dnsmasq.ap restart

To set it up automatically

This script can be run multiple times and can e.g. be run from rc.local.

#!/bin/sh

FORWARD_IFACE="wifi0"
DNSMASQ_CONF="/etc/dnsmasq.ap.conf"

/opt/victronenergy/swupdate-scripts/resize2fs.sh

sysctl -w net.ipv4.ip_forward=1

if ! iptables -C FORWARD -i ap0 -o "$FORWARD_IFACE" -j ACCEPT 2>/dev/null; then
    iptables -A FORWARD -i ap0 -o "$FORWARD_IFACE" -j ACCEPT
fi

if ! iptables -C FORWARD -i "$FORWARD_IFACE" -o ap0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 2>/dev/null; then
    iptables -A FORWARD -i "$FORWARD_IFACE" -o ap0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
fi

if ! iptables -t nat -C POSTROUTING -o "$FORWARD_IFACE" -j MASQUERADE 2>/dev/null; then
    iptables -t nat -A POSTROUTING -o "$FORWARD_IFACE" -j MASQUERADE
fi

if grep -q '^no-resolv[[:space:]]*$' "$DNSMASQ_CONF"; then
    sed -i 's/^no-resolv[[:space:]]*$/#no-resolv/' "$DNSMASQ_CONF"
    /etc/init.d/dnsmasq.ap restart
fi

Clone this wiki locally