<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Hi,</div><div><br></div><div><span id="zwchr" data-marker="__DIVIDER__">----- On Oct 20, 2017, at 5:10 PM, Michael L Martin <mmartin4242@gmail.com> wrote:<br></span></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><p>Raw socket options looks like it should be the answer, but I'm
not getting good results:</p><p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63" target="_blank">worker@10.138.69.63</a>)28> {:ok, s} =
:gen_tcp.connect('localhost', 80, [{:raw, 6, 15,
<<1>>}, {:ip, {10, 138, 69, 63}}])</p><p>{:ok, #Port<0.12110>}</p><p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63" target="_blank">worker@10.138.69.63</a>)29> :inet.getopts(s, [{:raw, 6, 15,
32}])</p><p>{:ok, []} <== option not set?<br></p><p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63" target="_blank">worker@10.138.69.63</a>)29> {:ok, s} =
:gen_tcp.connect('localhost', 80, [{:raw, 6, 15,
<<1>>}, {:ip, {10, 138, 69, 64}}]) </p><p>** (MatchError) no match of right hand side value: {:error,
:eaddrnotavail}</p></blockquote><div><br></div><div>IP_FREEBIND on connect doesn't make sense, it's only really useful on listen sockets.</div><div><br data-mce-bogus="1"></div><div> The option lets you bind to an IP address that does not yet exist on the host. That is ok for listen, but when you attempt to build an outgoing connection from that IP, then it has to be configured.</div><div><br data-mce-bogus="1"></div><blockquote style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><p>It appears that the IP_FREEBIND option is simply not set. If I
use IP_TRANSPARENT instead:</p><p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63" target="_blank">worker@10.138.69.63</a>)35> {:ok, s} =
:gen_tcp.connect('localhost', 80, [{:raw, 6, 19,
<<1>>}, {:ip, {10, 138, 69, 63}}])</p><p>{:ok, #Port<0.12113>}</p><p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63" target="_blank">worker@10.138.69.63</a>)34> :inet.getopts(s, [{:raw, 6, 19,
32}])</p><p>{:ok, [{:raw, 6, 19, <<0, 0, 0, 0>>}]}</p></blockquote><div><br></div><div>IP_TRANSPARENT needs special iptables rules to work correctly and is for a very specific use case. I don't think it would be very useful for an Erlang application to use that.</div><blockquote style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><p>In this case, the raw option 19 (IP_TRANSPARENT) is set, but to
false rather than true. I believe this is because the beam file
needs root or CAP_NET_ADMIN.</p></blockquote><div>You need root and a specific iptables setup for it to work.</div><div><br data-mce-bogus="1"></div><blockquote style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><p>Any thoughts?</p></blockquote><div><br></div><div>What are you attempting to achieve anyway?</div><div><br data-mce-bogus="1"></div><div>Regards</div><div>Andreas</div><blockquote style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><p><br></p><p><br></p><br><div class="moz-cite-prefix">On 2017-10-16 01:18 PM, Guilherme
Andrade wrote:<br></div><blockquote cite="mid:CAA5f+NXdxxHJWLWkeQWE3kSzWGyMUyvM_SkZFrHcB_2DGyfhgA@mail.gmail.com"><div dir="ltr">I believe you can use raw socket options[1] for
that, but it won't be portable.<br><br>
[1]: <a href="http://erlang.org/doc/man/inet.html#setopts-2" target="_blank">http://erlang.org/doc/man/inet.html#setopts-2</a>
- {raw, Protocol, OptionNum, ValueBin}<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 16 October 2017 at 15:09, Michael L
Martin <span dir="ltr"><<a href="mailto:mmartin4242@gmail.com" target="_blank">mmartin4242@gmail.com</a>></span>
wrote:<br><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;">Hi all,<br><br>
Is there a way to specify the FREEBIND option when opening a
socket? I don't see any reference to it in the
documentation.<br><br><br>
Thanks,<br><br>
_______________________________________________<br>
erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br><br clear="all"><br>
-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Guilherme<br></div></div></div></div></div></div></div></blockquote><br><br>_______________________________________________<br>erlang-questions mailing list<br>erlang-questions@erlang.org<br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div></div></body></html>