In order to change the gateway in an Unifi device via CLI, you should first look at the current routes.
route -eKernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.20.0 * 255.255.255.0 U 0 0 0 eth0Next, we should delete the default route.
route del defaultFinally, we should register the new default route as the gateway. In my case the gateway is at 192.168.20.1.
route add default gw 192.168.20.1 eth0If we check again the curent routes, here is the result:
route -eKernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default 192.168.20.1 0.0.0.0 UG 0 0 0 eth0
192.168.20.0 * 255.255.255.0 U 0 0 0 eth0