Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from Nov 18 '11 at 11:05

This question came from our site for professional and enthusiast programmers.

Why do you need this? – yfeldblum Jul 29 '11 at 13:00
This is the task. If I will done this, I will able to move physical server into virtual and keep its IP unchanged. – osgx Jul 29 '11 at 13:41

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?

share|improve this answer

This can be very easily done with pf(4) and its nat, binat and rdr 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 (from nat ... -> ..., to pass ... nat-to ...), but with OpenBSD 5.2 it should be as follows (example taken directly from

web_serv_int = ""
web_serv_ext = ""

pass on tl0 from $web_serv_int to any binat-to $web_serv_ext`

See more info about NAT and traffic redirection in OpenBSD here:

share|improve this answer

You can modify kernel to substitute IP1 with IP2 for outgoing traffic and vice versa.

What protocol you have in mind ?

share|improve this answer
tcp/udp over ip – osgx Nov 14 '11 at 22:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.