Inet dist: Where do these parameters belong?

With this script I can start a iex session through a vpn-tunnel to a remote node:

#!/usr/bin/bash
min="9001"
max=${min}

node="joe"
address="192.168.100.209"
cookie="pazuzu"
name=${node}@${address}

tuple=$(echo "{$address}" | tr '.' ',')

ERL_EPMD_ADDRESS=${address}

params="-kernel"
params+=" inet_dist_listen_min ${min}"
params+=" inet_dist_listen_max ${max}"
params+=" inet_dist_use_interface ${tuple}"

iex --erl "${params}" --name ${name} --cookie ${cookie} -S mix

It works (the remote node is configured accordingly) :


 iex(joe@192.168.100.209)2> Node.connect :'averell@192.168.100.130'                             
true                                                                                           

 iex(joe@192.168.100.209)3> Node.list()                                                         
 [:"averell@192.168.100.130"]                                                                   

iex(joe@192.168.100.209)4> Node.spawn_link(:"averell@192.168.100.130", fn -> IO.puts(Node.self\
) end)                                                                                           
averell@192.168.100.130                                                                        
PID<20191.152.0>                                                                              

iex(joe@192.168.100.209)5> Node.disconnect :'averell@192.168.100.130'                          
true                                   

The vpn is made with tinc - it works flawless:


sudo netstat -tulpn  | grep [b]eam
tcp    0   0 192.168.100.209:9001    0.0.0.0:*   LISTEN      24080/beam.smp 

sudo netstat -tulpn  | grep [e]pmd
tcp        0      0 127.0.0.1:4369          0.0.0.0:*               LISTEN      21477/epmd          
tcp        0      0 192.168.100.209:4369    0.0.0.0:*               LISTEN      21477/epmd 

But I couldn’t figure out yet where to put the credentials when I build a release. No success with ERL_FLAGS.

Thanks for any advice in advance.

P.S. for completeness:

karl@somewhere:~$ ifconfig ens6 | head -n 2
ens6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 85.xxx.xx.104  netmask 255.255.255.255  broadcast 0.0.0.0
karl@somewhere:~$ ifconfig erlVPN | head -n 2
erlVPN: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 192.168.100.209  netmask 255.255.255.255  destination 192.168.100.209 

Solution:

ERL_AFLAGS="-kernel inet_dist_use_interface {192,168,100,209} -name joe@somewhere -setcookie secret”

 ./_build/prod/rel/joe/bin/joe start_iex

Much simpler as with some shell script.

In prod-mode/release the cookie is ignored for known reasons and is to be set ”by hand” in one way or another.

Strangely enough IPs in long names only work in dev - in prod/release hostnames are needed plus an entry in /etc/hosts for the remote node.

Regards, Karl