From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <9ab217670904150532l6e9805dcvc339b03c7892aba9@mail.gmail.com> References: <9ab217670904150532l6e9805dcvc339b03c7892aba9@mail.gmail.com> Date: Wed, 15 Apr 2009 15:44:14 +0200 Message-ID: From: Patrick Kristiansen To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=000e0cd247d4a799930467982487 Subject: Re: [9fans] NAT implementation Topicbox-Message-UUID: db1cb1ec-ead4-11e9-9d60-3106f5b1d025 --000e0cd247d4a799930467982487 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/4/15 Devon H. O'Dell > > > I think #2 would be an easily testable and maybe more `correct' way to > do this in Plan 9. I think doing an implementation directly in the IP > path is easier, overall, but that's where my experience lies anyway. > Thanks, I'll try that. > > > > Do you have any advices on how to capture packets and how to send them > out > > again after replacing src/dst addr and port? > > It's not quite that simple. At the simplest, when the packet goes out, > you have to keep a tab of the destination host / port and source host > / port. When a packet comes in, you look up the source host / port in > the hash table (hashed by dest host / port). You rewrite the packet. > You have to regenerate the packet checksum after rewriting it. You > send it back out. I know it's not that simple. But for the rewriting and keeping state stuff, I can look at the existing implementations of nat, i.e. natd for freebsd. The thing I need now is the stuff for capturing and sending packets using pkt interfaces. > > > Are there any ways of testing NAT in a virtual machine? Right now I'm > using > > vmware and it would be nice to be able to test it without setting up a > real > > machine with two Ethernet interfaces. > > Sure, configure a couple VMs with hostonly networking and set up their > IP addresses accordingly. > Nice, thanks. > > > -Patrick Kristiansen > > --dho > > --000e0cd247d4a799930467982487 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2009/4/15 Devon H. O'Dell <devon.odell@gmail.com= >


I think #2 would be an easily testable and maybe more `correct' w= ay to
do this in Plan 9. I think doing an implementation directly in the IP
path is easier, overall, but that's where my experience lies anyway.
Thanks, I'll try that.=A0


> Do you have any advices on how to capture packets and how to send them= out
> again after replacing src/dst addr and port?

It's not quite that simple. At the simplest, when the packet goes= out,
you have to keep a tab of the destination host / port and source host
/ port. When a packet comes in, you look up the source host / port in
the hash table (hashed by dest host / port). You rewrite the packet.
You have to regenerate the packet checksum after rewriting it. You
send it back out.
=A0
I know it's not that s= imple. But for the rewriting and keeping state stuff, I can look at the exi= sting implementations of nat, i.e. natd for freebsd.
The thing I = need now is the stuff for capturing and sending packets using pkt interface= s.

> Are there any ways of testing NAT in a virtual machine? Right now I= 9;m using
> vmware and it would be nice to be able to test it without setting up a= real
> machine with two Ethernet interfaces.

Sure, configure a couple VMs with hostonly networking and set up thei= r
IP addresses accordingly.
Nice, thanks.=A0

> -Patrick Kristiansen

--dho


--000e0cd247d4a799930467982487--