Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-22-2015, 12:39 PM   #1
Registered: Jan 2003
Location: EU (UK)
Distribution: Ubuntu 14.x, Raspbian, Kali
Posts: 226

Rep: Reputation: 30
Bridge VPN to Ethernet (tun0 to eth1)

Hi everyone.

I'm afraid that this problem is defeating me and I would be most grateful for any pointers.

I have two NIC's (eth0 and eth1) on my machine.

eth0 is connected to my router and provides internet access with an IP address from my broadband provider.

I am running OpenVPN that establishes a tunnel (tun0) that has a different IP address that is overseas.

What I would like to do is to bridge tun0 and eth1 so that I can connect another device to the tunnelled traffic.

I suspect that the answer lies in iptables but having visited lots of websites, it all seems more than a little unclear to me.

I have tried using bridge-utils however that only seems to work between eth0 and eth1, it does not work with tun0. If I create br0 it avoids the tunnel and passes traffic direct from my normal IP address, not the vpn IP address.

Can anybody point me in the right direction?

Old 02-22-2015, 02:39 PM   #2
Ser Olmy
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,345

Rep: Reputation: Disabled
tun0 is a layer 3 tunnel interface. It doesn't do layer 2 (Ethernet or whatever) at all, which means it can't be bridged.

What you can do, is route traffic through the PC with the tunnel interface. Other devices on your network would send packets to that PC, which would then forward them through the tunnel.

For that to work, you must either:
  • have the PC with the VPN tunnel serve as a gateway for every other device needing to reach the remote network (or the entire network, for that matter), OR
  • create a route entry for the remote network on your current gateway router, pointing to the PC with the VPN tunnel, OR
  • manually create routes any device needing access to the remote network.
That will cover traffic flowing from your network to the remote network, but what about return traffic? You can't expect the router(s) at the remote end to know about your internal network, so you'd also have to configure NAT on the PC with the tunnel interface.

The following iptables command will "hide" (NAT) all outgoing traffic behind the address of the tunnel interface:
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
1 members found this post helpful.


vpn openvpn bridge

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How do you bridge the eth0 (ethernet) and eth1 (WiFi_Ap)? TeaYoung Linux - Software 1 10-25-2014 05:51 AM
How do I bridge the eth0 (ethernet) and eth1 (WiFi_Ap)? TeaYoung Linux - Networking 2 10-12-2014 07:01 PM
ethernet bridge (wlan0 eth1) - canīt ping magicien Linux - Wireless Networking 0 07-05-2004 03:59 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration