<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Thanks for the quick response. As for what I'm attempting to
achieve, well, I'm not really sure.</p>
<p>I have a customer that is adamant that we use IP_FREEBIND, so
I've been poking around in :gen_tcp and :inet trying to see how to
do that.</p>
<p>Here's what happens when I try to open a listen socket:</p>
<p>iex(5)> {:ok, s} = :gen_tcp.listen(8000, [{:raw, 6, 15,
<<1 :: size(32)>>}, {:ip, {10, 138, 69, 63}}])<br>
{:ok, #Port<0.1305>}<br>
iex(6)> :inet.getopts(s, [{:raw, 6, 15,
4}]) <br>
{:ok, []}<br>
iex(7)> :gen_tcp.close(s)<br>
:ok<br>
iex(8)> {:ok, s} = :gen_tcp.listen(8000, [{:raw, 6, 15,
<<1 :: size(32)>>}, {:ip, {10, 138, 69, 64}}])<br>
** (MatchError) no match of right hand side value: {:error,
:eaddrnotavail}<br>
<br>
iex(8)></p>
<p>So it looks like it's not working for listen sockets, either.
Could very well be that I simply don't know what the heck I'm
doing...</p>
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 2017-10-20 12:04 PM, Andreas Schultz
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:542205910.3060266.1508515448634.JavaMail.zimbra@tpip.net">
<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
<a class="moz-txt-link-rfc2396E" href="mailto:mmartin4242@gmail.com"><mmartin4242@gmail.com></a> 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"
moz-do-not-send="true">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"
moz-do-not-send="true">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"
moz-do-not-send="true">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"
moz-do-not-send="true">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"
moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">erlang-questions@erlang.org</a><br>
<a
href="http://erlang.org/mailman/listinfo/erlang-questions"
rel="noreferrer" target="_blank"
moz-do-not-send="true">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>
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote>
</div>
</div>
</blockquote>
<br>
</body>
</html>