netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martijn van Oosterhout <kleptog@svana.org>
To: Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
Cc: netdev@oss.sgi.com, linux-net@vger.kernel.org, davem@redhat.com,
	yoshfuji@linux-ipv6.org, pekkas@netcore.fi, jmorris@redhat.com,
	linux-kernel@vger.kernel.org
Subject: Re: UDP sockets bound to ANY send answers with wrong src ip address
Date: Wed, 9 Jun 2004 22:20:30 +1000	[thread overview]
Message-ID: <20040609122030.GA14854@svana.org> (raw)
In-Reply-To: <200406091425.39324.vda@port.imtp.ilyichevsk.odessa.ua>

[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]

On Wed, Jun 09, 2004 at 02:25:39PM +0300, Denis Vlasenko wrote:
> I observe that UDP sockets listening on ANY
> send response packets with ip addr derived from
> ip address of interface which is used to send 'em
> instead of using dst ip address of client's packet.
> 
> I was bitten by this with DNS and NTP.

This is the responsibility of the program. Unless the UDP packet is
bound to a particular address, or the program specifies an IP, the
kernel will pick one. For this reason both the BIND and NTP daemons
open a socket for each interface so they can control this. netstat on
my machine shows:

udp        0      0 192.168.1.225:123       0.0.0.0:*                           
udp        0      0 127.0.0.1:123           0.0.0.0:*                           
udp        0      0 0.0.0.0:123             0.0.0.0:*                        

for the NTP server. The DNS has similar machanism. Remember, UDP
doesn't involve connections, so there is no concept of "replying" to a
packet, the program has to manage that itself.

In your example, if you tell netcat which address to bind to, it will
work.

Hope this helps,
-- 
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

  parent reply	other threads:[~2004-06-09 12:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-09 11:25 UDP sockets bound to ANY send answers with wrong src ip address Denis Vlasenko
2004-06-09 12:18 ` Julian Anastasov
2004-06-09 12:45   ` Denis Vlasenko
2004-06-09 12:20 ` Martijn van Oosterhout [this message]
2004-06-09 12:24 ` YOSHIFUJI Hideaki / 吉藤英明
2004-06-11  9:30   ` Denis Vlasenko
2004-06-11 10:34     ` Herbert Xu
2004-06-11 12:27       ` Denis Vlasenko
2004-06-11 13:53         ` Julian Anastasov
2004-06-12 22:08           ` Denis Vlasenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040609122030.GA14854@svana.org \
    --to=kleptog@svana.org \
    --cc=davem@redhat.com \
    --cc=jmorris@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=pekkas@netcore.fi \
    --cc=vda@port.imtp.ilyichevsk.odessa.ua \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).