All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Haxby <john.haxby@oracle.com>
To: Clemens Eisserer <linuxhippy@gmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: API to find out wether a IP address is local?
Date: Tue, 14 Jun 2011 10:11:04 +0100	[thread overview]
Message-ID: <4DF725A8.7040205@oracle.com> (raw)
In-Reply-To: <BANLkTi=fu+bMtOs_xWfaW0rwwDhk4TrSdA@mail.gmail.com>

On 14/06/11 08:31, Clemens Eisserer wrote:
> I know this question is not really netfilter related, sorry. But I
> didn't know where to ask it instead.
>
> Does Linux have an API to find out wether an IP address is local?

netdevice(7) tells you how to extract all the IPv4 addresses from the
network devices; /proc/net/if_inet6 lists all the local IPv6 addresses.

This is not necessarily useful though: redirection happens in all kinds
of ways and all kinds of places and while getpeeraddr(2) might tell you
that you're connected to one of google.com's addresses, that could be
far from the truth.  (Of course, the inverse is true, just because you
thought you were connecting to a local address doesn't mean that some
wild and woolly iptables configuration didn't send your packets winging
half way around the globe.)

jch

  reply	other threads:[~2011-06-14  9:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-14  7:31 API to find out wether a IP address is local? Clemens Eisserer
2011-06-14  9:11 ` John Haxby [this message]
2011-06-14  9:48   ` Jan Engelhardt

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=4DF725A8.7040205@oracle.com \
    --to=john.haxby@oracle.com \
    --cc=linuxhippy@gmail.com \
    --cc=netfilter@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.