old-www/LDP/LG/issue68/tag/1.html

343 lines
13 KiB
HTML

<!--startcut ======================================================= -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<META NAME="generator" CONTENT="lgazmail v1.3E.w">
<TITLE>The Answer Gang 68: Dial-on-demand users should know:</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"
LINK="#3366FF" VLINK="#A000A0">
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<P> <hr>
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
<p align="center">
<table width="100%" border="0"><tr>
<td align="right" valign="center"
><IMG ALT="" SRC="../../gx/navbar/left.jpg"
WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="middle" border="0"
><A HREF="../"
><IMG SRC="../../gx/navbar/toc.jpg" align="middle"
ALT="[ Table Of Contents ]" border="0"></A
><A HREF="../lg_answer68.html"
><IMG SRC="../../gx/dennis/answertoc.jpg" align="middle"
ALT="[ Answer Guy Current Index ]" border="0"></A></td>
<td align="center" valign="center"><A HREF="../lg_answer68.html#greeting"><img align="middle"
src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A> &nbsp;
<A HREF="bios.html">bios</A> &nbsp;
<A HREF="1.html">1</A> &nbsp;
<A HREF="2.html">2</A> &nbsp;
<A HREF="3.html">3</A> &nbsp;
<A HREF="4.html">4</A> &nbsp;
<A HREF="5.html">5</A> &nbsp;
<A HREF="6.html">6</A> &nbsp;
<A HREF="7.html">7</A> &nbsp;
<A HREF="8.html">8</A> &nbsp;
<A HREF="9.html">9</A> &nbsp;
<A HREF="10.html">10</A> &nbsp;
<A HREF="11.html">11</A> &nbsp;
<A HREF="12.html">12</A>
</td>
<td align="left" valign="center"><A HREF="../../tag/kb.html"
><IMG SRC="../../gx/dennis/answerpast.jpg" align="middle"
ALT="[ Index of Past Answers ]" border="0"></A
><IMG ALT="" SRC="../../gx/navbar/right.jpg" align="middle"
WIDTH="14" HEIGHT="45" BORDER="0"></td></tr></table>
</p>
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<center>
<H1><A NAME="answer">
<img src="../../gx/dennis/qbubble.gif" alt="(?)"
border="0" align="middle">
<font color="#B03060">The Answer Gang</font>
<img src="../../gx/dennis/bbubble.gif" alt="(!)"
border="0" align="middle">
</A></H1>
<BR>
<H4>By Jim Dennis, Ben Okopnik, Dan Wilder, Breen, Chris, and the Gang,
the Editors of Linux Gazette...
and You!
<br>Send questions (or interesting answers) to
<a href="mailto:linux-questions-only@ssc.com">linux-questions-only@ssc.com</a>
</H4>
<p><em><font color="#990000">There is no guarantee that your questions
here will <b>ever</b> be answered. Readers at confidential sites
must provide permission to publish. However, you can be published
anonymously - just let us know!
</font></em></p>
</center>
<p><hr><p>
<!-- endcut ======================================================= -->
<!-- begin 1 -->
<H3 align="left"><img src="../../gx/dennis/bbubble.gif"
height="50" width="60" alt="(!) " border="0"
>Dial-on-demand users should know:</H3>
<p><strong>From Richard Greaney
</strong></p>
<p align="right"><strong>More Answers by Mike Orr, Jim Dennis,
Willy Tareau, David Forrest, Juanjo and Erik Corry
<br></strong></p>
<!-- sig -->
<P><STRONG>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
If you are on a dial-up connection and are tired of not getting reliable
starts to your connection (often having to click "refresh" after
starting a browser to prevent it from timing out) you may benefit from
this piece of advice.
</STRONG></P>
<P><STRONG>
There are two ways Linux looks up a host before connecting. One uses the
traditional <TT> gethostbyname()</TT> function (which uses DNS and hence UDP)
while the other uses a straight lookup on the IP address. Either way, if
you use a demand dial setup, these will run into problems. If you type
ifconfig before you get connected, you will notice your ppp0 adapter has
the address 10.64.64.64. Once you are connected, it becomes a little
more beleivable. However, those first lookup SYN packets are sent from
10.64.64.64, but since the ppp interface has changed it's IP address,
the packets will not reach it. Refreshing the connection attempt will
work, but it's less than elegant.
</STRONG></P>
<P><STRONG>
How to fix:
cat <TT>/proc/sys/net/ipv4/ip_dynaddr</TT> should return the value '1'. If this
is not the case, type (as root) echo 1 &gt; <TT>/proc/sys/net/ipv4/ip_dynaddr</TT>
</STRONG></P>
<P><STRONG>
What you are doing is telling your machine that it has a dynamic IP
address. Any packets which are originally sent from 10.64.64.64 will be
redirected to the new IP address as soon as you get connected to your ISP.
</STRONG></P>
<P><STRONG>
Richard Greaney
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Mike]
Thanks for the advice. Why do people need to do this now? When I used
to have a dynamic IP address three years ago, I never needed to do this.
</BLOCKQUOTE>
<P><STRONG><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
That one I can't answer. I've built a few Linux boxes in my time and not
one of them has had anything other than 0 set for the ip_dynaddr field.
Having said that, they were very seldom used to connect to the net. My
present machine (which connects to the net several times a day) was also
set to 0 by default (as is standard) but I decided one day I was going
to iron out why I was having to refresh the connection on startup before
any data came across. I was looking to rewrite some source code but
stumbled across this one instead. I've read that Linux is widely known
for not being great with demand-dial setups. Perhaps this is why? I
thought the people could benefit from knowing this.
</STRONG></P>
<P><STRONG>
The text from the kernel docs explains it pretty clearly.
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [JimD]
The result is a failure of <EM>existing</EM> connections. As new connections
are established over the newly raised link, those work. So the
ip_dynaddr solution is for a problem that many Linux users never knew
they were having.
</BLOCKQUOTE>
<BLOCKQUOTE>
Paul Mackerras (author/maintainer of the Linux pppd) was trying to
explain this whole thing to me one time. I'm afraid I just wasn't
"getting it." (We'd probably already had too much sake by then,
I think we were eating sushi that evening).
</BLOCKQUOTE>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> [Mike]
I did a google search for "ip_dynaddr" and came up with:
</BLOCKQUOTE>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> (Willy Tareau)
<DL>
<DT><A HREF="http://web.gnu.walfield.org/mail-archive/linux-kernel/2000-March/0179.html"
>http://web.gnu.walfield.org/mail-archive/linux-kernel/2000-March/0179.html</A>
<dd>
What exactly does setting ip_dynaddr to 1 or 2 do? it allows to change your
local addresses to the one of an interface which is changing (typically ppp*)
when up.
</DL></blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
(David Forrest)
<DL>
<DT><A HREF="http://web.gnu.walfield.org/mail-archive/linux-kernel/2000-March/0184.html"
>http://web.gnu.walfield.org/mail-archive/linux-kernel/2000-March/0184.html</A>
<dd><code>drf5n@mug:/usr/src/linux$ grep -r ip_dynaddr * </code>
</DL></blockQuote>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
> (Juanjo, with RST-provoking mode by Erik Corry )
<DL>
<DT><A HREF="http://www.linuxhq.com/kernel/v2.0/doc/networking/ip_dynaddr.txt.html"
>http://www.linuxhq.com/kernel/v2.0/doc/networking/ip_dynaddr.txt.html</A>
<dd>
<strong>IP dynamic address hack-port v0.03-rst</strong>
<br>
This stuff allows diald ONESHOT connections to get established by
dynamically changing packet source address (and socket's if local procs).
It is implemented for TCP diald-box connections(1) and IP_MASQuerading(2).
<br>&nbsp;<br>
If enabled[*] and forwarding interface address has changed:
<br>&nbsp;<br>
<ul>
<LI>Socket (and packet) source address is rewritten ON RETRANSMISSIONS
while in SYN_SENT state (diald-box processes).
<LI>Out-bounded MASQueraded source address changes ON OUTPUT (when
internal host does retransmission) until a packet from outside is
received by the tunnel.
</ol>
<br>
This is specially helpful for auto dialup links (diald), where
the &quot;actual&quot; outgoing address is unknown at the moment the
link is going up. So, the <EM>same</EM>
(local AND masqueraded) connections requests that bring the link up will be
able to get established.
<br>&nbsp;<br>
If you enable the RST-provoking mode, then the source address will be changed,
even if the socket is established. This means we send an incorrect packet out,
which causes the remote host to kill our socket. This is the desired behaviour,
because such a socket is doomed anyway, and the earlier it dies, the better.
This prevents the dial-on-demand connection from being kept up by a dead
connection, and tells the application that the connection was lost.
<br>&nbsp;<br>
[*] At boot, by default no address rewriting is attempted.
<br>&nbsp;<br>
The values for the ip_dynaddr sysctl are:
<br>&nbsp;<br>
<code><font color="#000033"><br> 1: To enable:
<br> 2: To enable verbosity:
<br> 4: To enable RST-provoking:
</font></code>
<br>&nbsp;<br>
Flags can be combined by adding them. Common settings
would be:
<dl>
<dt>
To switch off special handling of dynamic addresses (default)
<dd><CODE>
# echo 0 &gt; /proc/sys/net/ipv4/ip_dynaddr
</CODE>
<dt>
To enable rewriting in quiet mode:
<dd><CODE>
# echo 1 &gt; /proc/sys/net/ipv4/ip_dynaddr
</CODE>
<dt>
To enable rewriting in verbose mode:
<dd><CODE>
# echo 3 &gt; /proc/sys/net/ipv4/ip_dynaddr
</CODE>
<dt>
(for backwards compatibility you can also use)
<dd><CODE>
# echo 2 &gt; /proc/sys/net/ipv4/ip_dynaddr
</CODE>
<dt>
To enable quiet RST-provoking mode:
<dd><CODE>
# echo 5 &gt; /proc/sys/net/ipv4/ip_dynaddr
</CODE>
<dt>
To enable verbose RST-provoking mode:
<dd><CODE># echo 7 &gt; /proc/sys/net/ipv4/ip_dynaddr
</CODE>
</dl>
</DL></blockQuote>
<!-- end 1 -->
<!--startcut ======================================================= -->
<P> <hr> </p>
<!-- *** BEGIN copyright *** -->
<H5 align="center">This page edited and maintained by the Editors
of <I>Linux Gazette</I>
<a href="http://www.linuxgazette.com/copying.html"
>Copyright &copy;</a> 2001
<BR>Published in issue 68 of <I>Linux Gazette</I> July 2001</H5>
<H6 ALIGN="center">HTML script maintained by
<A HREF="mailto:star@starshine.org">Heather Stern</a> of
Starshine Technical Services,
<A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
</H6>
<!-- *** END copyright *** -->
<P> <hr>
<P> <hr>
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
<p align="center">
<table width="100%" border="0"><tr>
<td align="right" valign="center"
><IMG ALT="" SRC="../../gx/navbar/left.jpg"
WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="middle" border="0"
><A HREF="..//"
><IMG SRC="../../gx/navbar/toc.jpg" align="middle"
ALT="[ Table Of Contents ]" border="0"></A
><A HREF="../lg_answer68.html"
><IMG SRC="../../gx/dennis/answertoc.jpg" align="middle"
ALT="[ Answer Guy Current Index ]" border="0"></A></td>
<td align="center" valign="center"><A HREF="../lg_answer68.html#greeting"><img align="middle"
src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A> &nbsp;
<A HREF="bios.html">bios</A> &nbsp;
<A HREF="1.html">1</A> &nbsp;
<A HREF="2.html">2</A> &nbsp;
<A HREF="3.html">3</A> &nbsp;
<A HREF="4.html">4</A> &nbsp;
<A HREF="5.html">5</A> &nbsp;
<A HREF="6.html">6</A> &nbsp;
<A HREF="7.html">7</A> &nbsp;
<A HREF="8.html">8</A> &nbsp;
<A HREF="9.html">9</A> &nbsp;
<A HREF="10.html">10</A> &nbsp;
<A HREF="11.html">11</A> &nbsp;
<A HREF="12.html">12</A>
</td>
<td align="left" valign="center"><A HREF="../../tag/kb.html"
><IMG SRC="../../gx/dennis/answerpast.jpg" align="middle"
ALT="[ Index of Past Answers ]" border="0"></A
><IMG ALT="" SRC="../../gx/navbar/right.jpg" align="middle"
WIDTH="14" HEIGHT="45" BORDER="0"></td></tr></table>
</p>
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
</BODY></HTML>
<!--endcut ========================================================= -->