Is it possible to set up OpenBSD such, that it will have IP1 internally (in hosts, in hostname.en0, sockets binds to IP1), but convert it to IP2 when packet goes to ethernet. Also, packets for the IP2 should be received and delivered to services which were bind to IP1.
I think, this is possible in Linux, with iptables
firewall (something like by DNAT/SNAT), but now I want to do this on OpenBSD.
I can setup routing of real LAN in any way.
This should be more or less doable with an alias on the interface and minor PF/NAT magic. Have you looked at all into the PF guide?
This can be very easily done with
pf(4)
and itsnat
,binat
andrdr
rules.It sounds like you specifically want to look into the
binat
rules; the way all these rules are written has changed a couple of releases back (fromnat ... -> ...
, topass ... nat-to ...
), but with OpenBSD 5.2 it should be as follows (example taken directly from http://www.openbsd.org/faq/pf/nat.html#binat):See more info about NAT and traffic redirection in OpenBSD here:
http://www.openbsd.org/faq/pf/nat.html
http://www.openbsd.org/faq/pf/rdr.html
You can modify kernel to substitute IP1 with IP2 for outgoing traffic and vice versa.
What protocol you have in mind ?