You have to name your nodes and use the same cookie on both nodes.
In machine 1:
iex --name node1@machine1.com --cookie a_cookie_string
In machine 2:
iex --name node2@machine2.com --cookie a_cookie_string
Now the two machines can communicate. To test it, you can do something like this, on machine1:
iex(node1@machine1.com)1> Node.connect :"node2@machine2.com"
true
iex(node1@machine1.com)2> print_node_name = fn -> IO.puts Node.self end
#Function<erl_eval.20.80484245>
iex(node1@machine1.com)3> Node.spawn(:"node2@machine2.com", print_node_name)
node2@machine2.com
#PID<7789.49.0>
Domain names machine1.com
and machine2.com
can be changed with the ip addresses of the machines as well.