In my little home lab I run a single Nomad setup which has two host networks defined as the client configuration, as follows:
bind_addr = "{%raw%}{{ GetInterfaceIP \"tailscale0\" }}{%endraw%}"
... other stuff ...
client {
host_network "public" {
interface = "eth0"
}
host_network "private" {
interface = "tailscale0"
}
}
The idea being that I can by default to exposing things to my personal tailnet, and opt-in to exposing something to the public internet as needed (really only my Traefik setup is exposed to the public internet).
But I’ve noticed through downtime detection for a host I run that sometimes when I update a job (like Traefik) I end up getting an IPv6 address for the service block I define instead of the public IPv4 address (note: the IPv6 address assigned is the public interfaces IPv6 address). I’m using Traefik’s Nomad service discovery and registration which has been very solid up until recently for some reason.
So a few question:
- If a
host_networkdefinition only takes an interface name, how does it pick the IP address to use? Can I limit the selection space to IPv4 by specifying a cidr like0.0.0.0/0 - Is there a way to make this work with IPv4 or IPv6? I don’t particularly care which variety of IPs we use as long as they are routable and do the right thing so I’m personally very curious on how I’d make this work for IPv6.