I am trying to configure a few VM's network configuration and consul etc. I am using vagrant and configured the VMs to use a private network. This creates an interface eth1 in addition to the NAT connection to the host on eth0. Consul by default uses the first interface, eth0. Of course that messes everything up because both VMs register with the same IP which is not the one from the private network, but from the host connection.
So far, so good. I can change which IP consul uses, but this got me wondering:
Is there a better heuristic for finding the "main" interface than "use the first one"?
Since this is an attempt at automating network configuration and dns, I would like some kind of general solution, but I am not sure how to do this. Ideally this would be the one where the other consul-agents live. The more heterogenous such a cluster is, the less likely it is that the interface is the same for all cluster nodes.
Basically, I am looking for "do-what-i-mean(X)" for networking. ;-)