Hello, I'll preface by saying I'm not a networking guru (actually quite dumb when it comes to networking) but here I am because I'm tasked with figuring out what's going on.
This is what I think we're running with (copied from the overview page on the router)
I've created a dhcp file to upload and then clone to a whole bunch of GL-MT1300s but I've ran into an issue. In the dhcp file I use a hyphen "-" for readability of the hostname like so: P-WIFI-xxx-xxx and when I push the file to the router I noticed that Network > dhcp disappeared. Ok, I look around and check the file using uci show dhcp >/dev/null and get this error uci: Parse error (invalid character in name field) at line 32, byte 28 that happens to line up with the config host part of my dhcp entry, but I don't know why this is the case.
Everything I read and research says that "-" is a valid character to use for hostname. Conversely in the past these entries were separated by an _ which in those same readings and research should not be used in hostname. Yet confusingly when I revert the config host entry in my dhcp file to use _ instead of "-" this does not throw an error. With the parse error now moving to the next first instance of a "-" in a config host entry when I check again.
At a total loss for what to do or why this is happening. I'd like to use "-" as it is an accepted character that can be used in hostnames, but as it stands I seem to only be able to use "_" or I suppose anything else that would make everything less readable. These entries are sometimes read by people without much knowledge besides what they might need to know to try and troubleshoot a simple issue so readability is of high importance. I would also like to keep everything named according to accepted standards.
Would you mind helping me understand why this isn't necessary? I was simply going off what we had before which was not built by me but by someone who is no longer with the company, and the issue has somehow fallen into my lap. Just trying to learn
uci add dhcp host
uci set dhcp.@host[-1].name='P-LAN-194-11'
uci set dhcp.@host[-1].dns='1'
uci set dhcp.@host[-1].mac='00:00:00:00:00:00'
uci set dhcp.@host[-1].ip='192.168.8.78'
uci set dhcp.@host[-1].leasetime='365d'
uci commit dhcp
We are not talking about a hostname here (the "name" field), but about an uci config section name on line 39...
Hyphen '-' is not valid for a uci section name. (Not really documented anywhere except in the uci sources, I think)
Underscore '_' is allowed.
67 * validate strings for names and types, reject special characters
68 * for names, only alphanum and _ is allowed (shell compatibility)
69 * for types, we allow more characters
Underscores in hostnames aren't RFC compliant (and thus disallowed) period. Some Linux systems begrudgingly allow them, Windows and RFC-compliant DNS servers absolutely do not.
^^^ Corrected the above - dashes ARE allowed, underscores are not, so my observation was wrong and also unhelpful once corrected. My bad!