I would like to build a network environment where I have two Linux PCs (I will call them LPC1 and LPC2) connected to a switch, and I would like to encrypt the traffic between the two with OpenVPN. Do you see any difficulties to setup this environment?

Let's go further, let's say I have two other NICs on these PCs and I want them to act as a router to encrypt the traffic between other two PCs (I will call them PC1 and PC2) connected with the Linux boxes in a way like this:


Do you think that is possible this kind of configuration?


There shouldn't be any problem with that, if it's configured correctly. It should work in both tun (IP routed) and tap (Ethernet bridged) mode (depending on what you need; tun would be preferred, as always). You will have to make sure the routing is correct so that all traffic except the encrypted tunnel goes over the tunnel.

That's going to be the hard part. I'd suggest putting OpenVPN + the switch-side NIC in a network namespace. Then move the tun/tap interface it creates back to the main network namespace, so that you can route traffic over it. This gets more complicated if you need to communicate with other hosts on the switch. Another approach is policy routing (you could select the un-encrypted route only for OpenVPN's source port/IP, otherwise the encrypted route). Policy routing also makes the need to access other hosts on the switch case easier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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