Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jul 2014 20:47:54 +0300
From:      Sami Halabi <sodynet1@gmail.com>
To:        Julian Elischer <julian@freebsd.org>
Cc:        freebsd-net@freebsd.org, Niu Zhixiong <kaiaixi@gmail.com>
Subject:   Re: A question on modifying packet.
Message-ID:  <CAEW%2BoganLM=as%2Bb2GOsKbqbsjw95uMnfVKVj09ZdFndvO8V21Q@mail.gmail.com>
In-Reply-To: <53BD7317.9030008@freebsd.org>
References:  <CAOENNMA-%2B6P2tT3JTusH3Q8Qz4O7XnAc0ZEjVRqxU3W342sp%2Bg@mail.gmail.com> <53BD7317.9030008@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAEW%2BoganLM=as%2Bb2GOsKbqbsjw95uMnfVKVj09ZdFndvO8V21Q>