Skip to content

Instantly share code, notes, and snippets.

@arkku
Last active January 9, 2026 23:40
Show Gist options
  • Select an option

  • Save arkku/5df0e7adf835217c3df0fbe13550ee8d to your computer and use it in GitHub Desktop.

Select an option

Save arkku/5df0e7adf835217c3df0fbe13550ee8d to your computer and use it in GitHub Desktop.
Edit subnet in UniFi without a gateway
# mongodump --port 27117 --db ace --out "/srv/mongodb-backup-$(date +%Y%m%d)"
# mongo --port 27117
use ace
# Find network by name
db.networkconf.find({name: "Default"})
# Some of these settings can't be set in the UI without a UniFi gateway,
# but manually setting the `"purpose": "corporate"` makes the subnet
# visible (for reference).
db.networkconf.update(
{name: "NetworkName"},
{$set: {
"purpose": "corporate",
"ip_subnet": "192.168.X.1/24",
"dhcpd_enabled": false,
"dhcp_relay_enabled": false,
"dhcpguard_enabled": true,
"dhcpd_ip_1": "192.168.X.1",
"dhcpd_ip_2": "192.168.X.2",
"dhcpd_ip_3": "192.168.X.3",
"dhcpd_start": "192.168.X.128",
"dhcpd_stop": "192.168.X.199",
"dhcpd_leasetime": "3601",
"networkgroup": "LAN",
"setting_preference": "manual"
}}
)
# Does nothing, but also doesn't harm if `"ipv6_interface_type": "none"`.
# Meanwhile if you set `"ipv6_interface_type": "pd", you can't save the
# the settings anymore.
db.networkconf.update({name: "Default"}, {$set: { "ipv6_pd_prefixid": "1" }})
# Some other settings that probably do nothing without a gateway
db.networkconf.update(
{name: "Default"},
{$set: {
"is_nat": true,
"internet_access_enabled": true,
"ipv6_enabled": true,
"auto_scale_enabled": false,
"ipv6_pd_auto_prefixid_enabled": false
}}
)
@arkku
Copy link
Author

arkku commented Jan 9, 2026

My UniFi controller somehow didn't let me edit the DHCP guard settings on some subnets, so I went to edit them directly in the database. While doing that (and looking at the Default network for reference) I noticed that I can make the subnet range visible in the UI by setting the purpose to corporate. It doesn't seem to have any ill effects, since I don't have and won't have a UniFi gateway, but it's nice to have the reference visible. And now I can use the DHCP manager to edit the DHCP guard settings, and there it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment