I've got a VCS running on debian as prod server, and due to some hypervisor issues it had to be rebooted/migrated/updated several times in the past week.
Because i'm running my app using docker containers, i can't just pass
localhost for it to connect to my local postgres, so i'm using the
ens2 ip instead.
ens2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.12.174.3 netmask 255.255.255.254 broadcast 10.12.174.3 inet6 fe80::dc1c:14ff:fe51:5002 prefixlen 64 scopeid 0x20<link> inet6 2001:bc8:4740:205::1 prefixlen 127 scopeid 0x0<global> ether de:1c:14:51:50:02 txqueuelen 1000 (Ethernet) RX packets 37139 bytes 4801851 (4.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 39791 bytes 35291408 (33.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
But with every reboot that ip changes, and i have to manually go and change it in env vars so my app can reach the db again, which i'm sure you'll agree is not very practical.
So here is my question: is there a way to automatically assign an alias, pretty much like
localhost, to this specific interface?
I guess i could still try and parse the
ifconfig output but i'd rather ask first for an actual solution 👼
Thanks for your time guys 👌