Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com 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

3 Answers 3

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 http://www.openbsd.org/faq/pf/nat.html#binat):

web_serv_int = "192.168.1.100"
web_serv_ext = "24.5.0.6"

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:

http://www.openbsd.org/faq/pf/nat.html
http://www.openbsd.org/faq/pf/rdr.html

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

 
discard

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.