From owner-freebsd-net@FreeBSD.ORG Wed Jul 9 17:47:55 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1BA5D3A3; Wed, 9 Jul 2014 17:47:55 +0000 (UTC) Received: from mail-pa0-x231.google.com (mail-pa0-x231.google.com [IPv6:2607:f8b0:400e:c03::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E0430277A; Wed, 9 Jul 2014 17:47:54 +0000 (UTC) Received: by mail-pa0-f49.google.com with SMTP id lj1so9453922pab.8 for ; Wed, 09 Jul 2014 10:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Nb0bvoH02a03fvc8PuhSftLkyFvoHxJG92lyT+Nhesg=; b=k/Hbw3CpuzYBTtQKg9j5NBmKr7ui4UEfrHXNpHZ8g6bW8VlCnX0zSypK9gApwqjtVH iUZQVvjKrRgAteBD+MK3rmmX41WuCx9B0qBy/BwJwzwq+rZqafQ1qZD6oP68vsDr6ssl +KloGHVT3UNBLYN4esLpP4B+AVqpwOqYHQOEgqJHY3uDgi2ibgK+wLofDvEqzy4pD27k YAc4ZSHm+x1L1qF46I6wUc/iUqOSNLO3e1MnqMBpXpGH3efsu4GYGa2/EUIdZUfhz3up EGIxemAT+gZ350fOrk9xWlKRsW9SUcgIjpYcKFrTWjYAQHeCkjE18X+8UfX0Qvtf2/U+ ZiEQ== MIME-Version: 1.0 X-Received: by 10.68.252.73 with SMTP id zq9mr940533pbc.146.1404928074443; Wed, 09 Jul 2014 10:47:54 -0700 (PDT) Received: by 10.70.74.168 with HTTP; Wed, 9 Jul 2014 10:47:54 -0700 (PDT) Received: by 10.70.74.168 with HTTP; Wed, 9 Jul 2014 10:47:54 -0700 (PDT) In-Reply-To: <53BD7317.9030008@freebsd.org> References: <53BD7317.9030008@freebsd.org> Date: Wed, 9 Jul 2014 20:47:54 +0300 Message-ID: Subject: Re: A question on modifying packet. From: Sami Halabi To: Julian Elischer Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18 Cc: freebsd-net@freebsd.org, Niu Zhixiong X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jul 2014 17:47:55 -0000 use netgraph. In theory it should work.. in practice It worked for me once, but couldn't repeat the success. See ng_patch. Here is the code i tried: kldload ng_patch kldload ng_ipfw /usr/sbin/ngctl -f- << SEQ mkpeer ipfw: patch 300 in name ipfw:300 src_dst_chg msg src_dst_chg: setconfig { count=3D2 csum_flags=3D1 ops=3D[ \ { mode=3D1 value=3D0xc0a8e609 length=3D4 offset=3D= 12 } \ { mode=3D1 value=3D0xc0a8e680 length=3D4 offset=3D= 16 } ] } SEQ /sbin/ipfw add 600 netgraph 300 log ip from any to 239.0.0.19 dst-port 1234 in via vlan999 Sami On 7/9/14, 1:01 PM, Niu Zhixiong wrote: > Hi, all > I have only one NIC. I want to capture packets from one certain ip addres= s > and change the both src and dst addresses and forward to other destinatio= n > via the same NIC. It is possible? Is there any library to help me do this= ? > there is no library, but look at how natd does this using divert sockets. > > Regards, > Niu Zhixiong > =EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D= =EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D > kaiaixi@gmail.com > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" > > > _______________________________________________ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"