I can't help thinking that some combination of pnatd and socat could help run the whole thing on the device.