Skip to content

Instantly share code, notes, and snippets.

@plembo
Last active November 11, 2024 01:22
Show Gist options
  • Save plembo/6bb4491ebbfbce049c7efce0634d57f0 to your computer and use it in GitHub Desktop.
Save plembo/6bb4491ebbfbce049c7efce0634d57f0 to your computer and use it in GitHub Desktop.
Adding and removing static host mappings on EdgeRouter

Adding and removing static host mappings on EdgeRouter

Tested on a Ubiquiti EdgeRouter 4 with dnsmasq enabled for DHCP (and DNS) serving.

These operations can also be carried out in the EdgeRouter web gui with the "DNS host names" Wizard (click the "Wizards" tab and then select "DNS host names" to access).

To see all currently statically mapped hosts:

$ cat /etc/hosts

or, using the actual CLI:

$ configure
# show system static-host-mapping
# exit
$

To add a static host mapping and an alias:

$ configure
# set system static-host-mapping host-name test.example.com inet 10.0.1.24
# set system static-host-mapping host-name test.example.com alias test
# commit
# save
# exit
$

To add a couple of more aliases:

$ configure
# set system static-host-mapping host-name test.example.com alias test2.casalembo.com
# set system static-host-mapping host-name test.example.com alias test3.casalembo.com
# commit
# save
# exit
$

To remove static mapping and all aliases:

$ configure
# delete system static-host-mapping host-name test.example.com
# commit
# save
# exit
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment