Skip to content

fix(vrouter): preserve configured router hostnames - #347

Merged
cmulk merged 1 commit into
sandialabs:mainfrom
GhostofGoes:fix-issue-335-router-hostnames
Sep 29, 2026
Merged

cmulk merged 1 commit into
sandialabs:mainfrom
GhostofGoes:fix-issue-335-router-hostnames

Conversation

@GhostofGoes

@GhostofGoes GhostofGoes commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

tl;dr: remove special handling for router hostnames, set them exactly as defined in topology

Previously Node.RouterName() lowercased router hostnames and replaced . and _ with -. That made the guest hostname differ from the minimega VM name, so exact-match lookups such as cc filter hostname= missed routers. This special handling is no longer necessary with the hostname validation added in #268

Background

Why the rewrite existed, and why it's safe to remove:

  • RouterName() was added with the original Vyatta app in f7c9d35 (2020). No commit says why. Its only caller is system host-name in vyatta.tmpl. Minirouter never used it, and the startup app skips routers.
  • Vyatta and every VyOS release validate host-name against [A-Za-z0-9][-.A-Za-z0-9]*[A-Za-z0-9] (max 63) and never lowercase it. Uppercase letters and dots are accepted. Only _ is rejected.
  • The topology schema has rejected _ and . in hostnames since 65f8e83, so the ./_ rewrite only mattered for configs that skipped validation.
  • Firewall nodes are rendered from the same template, and RouterName() never rewrote their hostnames.

Changes

  • Remove RouterName() from the v0 and v1 Node types. vyatta.tmpl now uses $node.General.Hostname, like the Linux and Windows startup templates.
  • Add a template test that renders both the VyOS script and the Vyatta config.boot with a mixed-case hostname.
  • CHANGELOG entry.

Related Issues/PRs

Type of Change

  • Bugfix (fix)
  • Feature (feat)
  • Documentation (docs)
  • Refactor (refactor)
  • Chore (CI, build, dependencies, etc.) (chore)
  • Other (please describe):

Checklist

  • This PR conforms to the process detailed in the Contributing Guide.
  • I have included no proprietary/sensitive information in my code or the PR.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • I have tested my code (describe below).

Testing

Tested with an experiment with a VyOS router, tweaking the hostname a few times: router, ROUTER1, ROUTER-123.

Additional Notes

A config created with --skip-validation, or stored before 65f8e83, that has _ in a router hostname will now have VyOS reject the host-name line instead of getting - in its place. Renaming the node fixes it.

🤖 Generated with Claude Code

@nblair2

nblair2 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

The question - why are those changes made (vyos, vyatta, minirouter requirements)? If these are requirements they should be added to the schema, validated at configure time.

The vrouter app wrote router hostnames into VyOS and Vyatta configs
through Node.RouterName(), which lowercased the name and replaced "."
and "_" with "-". The guest hostname then differed from the minimega VM
name, so exact-match lookups such as `cc filter hostname=` missed
routers. Firewall nodes, rendered from the same template, were never
rewritten.

Vyatta and every VyOS release accept uppercase letters and dots in
`system host-name` and never lowercase it; only underscores are
rejected. The topology schema has rejected "_" and "." in node
hostnames since 65f8e83. Remove RouterName() and render the hostname
as written, as the Linux and Windows startup scripts already do.

Fixes sandialabs#335

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@GhostofGoes

GhostofGoes commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@nblair2 RouterName() came in with the original Vyatta app in f7c9d35 (April 2020). No commit explains it, and it only ever fed system host-name in vyatta.tmpl. Minirouter never used it, and the startup app skips routers.

Vyatta and every VyOS release validate host-name against [A-Za-z0-9][-.A-Za-z0-9]*[A-Za-z0-9] (max 63) and never lowercase it. Lowercasing was never a requirement. Underscore is the only rejected character, and the schema pattern from 65f8e83 already rejects _ and . when a config is created. Firewall nodes use the same template and were never rewritten either. I removed RouterName() and render the hostname as written.

That regex also needs at least 2 characters, and Windows DNS host names have the same minimum, so #429 raises the schema's hostname minimum from 1 to 2 (docs: sandialabs/sceptre-phenix-docs#70). sandialabs/sceptre-phenix-apps#148 replaces the apps test fixture that modeled the old rewrite.

One caveat: a config created with --skip-validation that has _ in a router hostname will now have VyOS reject the host-name line instead of getting - in its place.

@GhostofGoes
GhostofGoes marked this pull request as ready for review September 23, 2026 16:40
@cmulk

cmulk commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

makes sense to me, just need to fix the changelog conflict

@GhostofGoes

Copy link
Copy Markdown
Contributor Author

@cmulk resolved

@cmulk
cmulk merged commit ff1d27e into sandialabs:main Sep 29, 2026
6 checks passed
@GhostofGoes
GhostofGoes deleted the fix-issue-335-router-hostnames branch September 29, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Router hostnames converted to lower

3 participants