Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Nov 2002 14:55:19 -0500 (EST)
From:      Robert Watson <rwatson@freebsd.org>
To:        soheil soheil <soheil_hh@hotmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: Q. about sockets
Message-ID:  <Pine.NEB.3.96L.1021120145144.44513O-100000@fledge.watson.org>
In-Reply-To: <F71uLn5U9T3TGJ2TUSz0001cdc2@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Wed, 20 Nov 2002, soheil soheil wrote:

> Can i use raw socket for get all of the TCP/IP packet travels through my
> PC like this ? 
> 
> in -------->MyGW                  MyGW------> out
>              |                     |
>               -----> MySocket -----

Generally, no -- there are a number of approaches you can take addressing
the problem you're talking about, but it depends a lot on what you need
the solution to do.  If you definitely want a userland solution, one place
to start looking is at DIVERT sockets.  This is used by the userland nat
daemon (natd(8)) to intercept packets along a route or going in/out an
interface.  Take a look at divert(4) for more general information on the
divert notion.  I've used IPDIVERT in a number of situations to write
filtering applications at the IP level.  I've also used BPF to write
userland applications to perform filtering at the link layer by writing a
simple bridging application.  Depending on what you're trying to
accomplish, you might also be interested in the ipfw "fwd" command, which
allows you to intercept TCP connections, which you can then hook up to a
new TCP connection created by a proxy application.  ipfw(8) contains some
information about connection "fwd"s.

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert@fledge.watson.org      Network Associates Laboratories



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1021120145144.44513O-100000>