Addhost fail in WebUI when hostname contains Underscore

Hi Comunity!

When i add a Host in WebUI (example1.foo.com) it works like a charm.

But when i add a host (example_2.foo.com ) i get Invalid hostname or IP.
If i paste that exact hostname in the commandline tool (addhost.php example_2.foo.com public
the device is added indeed!

Anyone else had this problem?

Try force adding it from the WebUI.

That dont work.

I rename the Host in the DNS to something without Underscore and than it works!
But our namingconvention rely on that so i just have to add em up from Cli.
Thats no problem. But curious why the charset dont work in the same manner as in the Cli?

Please try this patch:

https://p.libren.ms/view/59ede51c

1 Like

Thanks for the Support!
Where do i use the Code?
in a new file ?

Underscore is not valid in hostnames.

Well… The RFC for the public part is one thing but this is not an issue in my bind or in the Domain forest at work and Observium has managed to swallow underscore hosts in over 4 years.

Yeah, LibreNMS can handle it no problem.

Perhaps we should ignore this as part of the force option…

Btw, if you apply laf’s patch and add them. Then you can remove the patch and move along.

Additionally, the command line addhost.php does not have the same checks.

Thanks! Yes that is no problem.
Add host.php is the way to go anyway in like 95% of the times!

It is for subdomains which is where we are tripping up.

cd /opt/librenms
wget https://p.libren.ms/view/raw/59ede51c
git apply 59ede51c

That Patch made the trick!
Thank you so much!