From owner-freebsd-ipfw@freebsd.org Tue Oct 18 16:04:05 2016 Return-Path: Delivered-To: freebsd-ipfw@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC088C16481 for ; Tue, 18 Oct 2016 16:04:05 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 483BC300 for ; Tue, 18 Oct 2016 16:04:04 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id u9IG3wpE004499; Wed, 19 Oct 2016 03:03:59 +1100 (EST) (envelope-from smithi@nimnet.asn.au) Date: Wed, 19 Oct 2016 03:03:58 +1100 (EST) From: Ian Smith To: Shawn Bakhtiar cc: Samira Nazari , "freebsd-ipfw@freebsd.org" Subject: Re: change packets with IPFW divert In-Reply-To: Message-ID: <20161019023739.D6806@sola.nimnet.asn.au> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2016 16:04:05 -0000 On Tue, 18 Oct 2016 14:21:50 +0000, Shawn Bakhtiar wrote: > On Oct 18, 2016, at 6:49 AM, Samira Nazari > wrote: > > Hello every one, > > When we diverte packets to the specified port with "IPFW divert" , > > we can change it and re-sent to the kernel? > Not sure what you mean by change it but: > > "Divert sockets are similar to raw IP sockets, except that they can > be bound to a specific divert port via the bind(2) system call. The > IP address in the bind is ignored; only the port number is > significant. A divert socket bound to a divert port will receive all > packets diverted to that port by some (here unspecified) kernel > mechanism(s). Packets may also be written to a divert port, in which > case they re-enter kernel IP packet processing." > > -- SRC: https://www.freebsd.org/cgi/man.cgi?query=divert&sektion=4&apropos=0&manpath=FreeBSD+10.3-RELEASE+and+Ports Apart from divert(4), most likely the best example is the natd(8) code, which modifies packet source or destination addresses and (maybe) ports. Ignoring the NAT processing - or not, as appropriate - the way natd uses divert sockets both to receive packets from ipfw and later (perhaps) to reinject them for further processing should show clearly how it's done. cheers, Ian