Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify /etc/hosts file handling across CL,FRR and Linux VMs and containers #1317

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

ipspace
Copy link
Owner

@ipspace ipspace commented Sep 14, 2024

The hosts file handling is done exclusively in the 'linux/hosts.j2' template with the contents being generated in the 'linux/hosts-common.j2' template.

These templates are used in CL, FRR, and Linux initial configuration templates as well as (using symlinks) in the hosts.j2 templates used to generate clab_files that are mapped into the container /etc/hosts files.

The content-generation template has been rewritten from scratch (the previous one generated invalid file format) and can be controlled with the 'netlab_intf_hosts' variable to generate hostnames that include interface names.

@ipspace ipspace requested a review from ssasso September 14, 2024 09:36
…ners

The hosts file handling is done exclusively in the 'linux/hosts.j2' template
with the contents being generated in the 'linux/hosts-common.j2' template.

These templates are used in CL, FRR, and Linux initial configuration templates
as well as (using symlinks) in the hosts.j2 templates used to generate clab_files
that are mapped into the container /etc/hosts files.

The content-generation template has been rewritten from scratch (the previous
one generated invalid file format) and can be controlled with the 'netlab_intf_hosts'
variable to generate hostnames that include interface names.
…e names

If we define multiple IP address for a hostname in /etc/hosts, Linux picks
a random IP address (not necessarily the first one) when doing ping or
traceroute. To ensure the CLI commands always use the loopback IP address,
we have to include interface names in IP addresses.

Also, for hosts, the hostname has to be before the interface/hostname to
get the correct name during the reverse IP lookup.
@ipspace ipspace merged commit 98affa5 into dev Sep 23, 2024
10 checks passed
@ipspace ipspace deleted the etc_hosts branch September 23, 2024 12:46
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.

2 participants