1

I'm trying to setup openvpn in bridge mode so I can link a few networks together across the country. I have got openvpn setup and that works fine, its when I try and turn it into a bridged network is where things go the wrong way.

I am following this tutorial here.

When I try and run bridge-start I get a confirmation that the tap device was opened, but I also get disconnected from the ssh session and have to reboot the server to connect again.

Sat May 27 02:49:35 2017 TUN/TAP device tap0 opened
Sat May 27 02:49:35 2017 Persist state set to: ON

Should I be bridging to eth0 or am I just doing something wrong?

This is my bridge-start script

#!/bin/bash

#################################
# Set up Ethernet bridge on Linux
# Requires: bridge-utils
#################################

# Define Bridge Interface
br="br0"

# Define list of TAP interfaces to be bridged,
# for example tap="tap0 tap1 tap2".
tap="tap0"

# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth="eth0"
eth_ip="192.168.8.4"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.8.255"

for t in $tap; do
    openvpn --mktun --dev $t
done

brctl addbr $br
brctl addif $br $eth

for t in $tap; do
    brctl addif $br $t
done

for t in $tap; do
    ifconfig $t 0.0.0.0 promisc up
done

ifconfig $eth 0.0.0.0 promisc up

ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast

And my ifconfig

eth0      Link encap:Ethernet  HWaddr 00:16:3c:5d:7a:a5
          inet addr:111.111.111.111  Bcast:111.111.111.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:186590 errors:0 dropped:348 overruns:0 frame:0
          TX packets:136 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11311181 (10.7 MiB)  TX bytes:20623 (20.1 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tap0      Link encap:Ethernet  HWaddr 7e:9f:bc:8a:06:f7
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Edit: I'm logging in via vnc to make all changes.

This is what my /etc/network/interfaces looks like currently, I copied all of the address/gateway/netmask from eth0 before I made changes. I cannot ssh into the server, do I have my settings wrong?

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address 111.191.104.233
        gateway 111.191.104.1
        netmask 255.255.255.0
        bridge_ports eth0
        bridge_fd 0
        bridge_maxwait 0

interfaces before any modification

 auto lo
  iface lo inet loopback

 auto eth0
  iface eth0 inet static
   address 111.191.104.233
   gateway 111.191.104.1
   netmask 255.255.255.0
   dns-nameservers 8.8.8.8 8.8.4.4
2

You haven't changed the eth_* variables in your bridge-start script to match your actual scenario. As a result when you run your script the IP address gets changed from 111.111.111.111 to 192.168.8.4 and you lose connectivity.

Even when you've fixed that you'll probably need to recreate your routing table (default route, in particular).

If possible, get your bridge set up and working (br0 and eth0) before you go any further with openvpn. Ideally you'd get the bridge running at boot time, and then you can add in the tap0 interface as you start testing openvpn.

Successfully changing a network configuration remotely is not easy. If you have any way to get a KVM attached while you get this working I would recommend you jump at the chance.


A comment appears to ask for a tutorial. Rather than pointing off-site, here is how I have a bridge set up on one of my systems. It does not use NetworkManager, but rather this is the configuration in /etc/network/interfaces. If you get this wrong you will not be able to log in, so I would suggest you use a KVM, or that you try it on a local machine to confirm the process works.

allow-hotplug eth0
iface eth0 inet manual

auto br0
iface br0 inet static              ← ASSUMES STATIC IP ADDR
        address 111.111.111.111
        netmask 255.255.255.0
        gateway 111.111.111.254    ← FIX ME BEFORE TRYING THIS
        bridge_ports eth0
        bridge_fd 0
        bridge_maxwait 0
  • Is there a tutorial anywhere for how to do that. I'm not sure where I would start? – 12shadow12 May 27 '17 at 22:23
  • Added a question to the bottom of OP. – 12shadow12 May 28 '17 at 0:38
  • @12shadow12 did your interfaces file have reference to eth0 before you changed it? Is your IP address obtained from DHCP or is it static? Have you a firewall configured - if so temporarily please turn it off. – roaima May 28 '17 at 8:48
  • Yes it did and my ip is static, I added some more info to OP – 12shadow12 May 28 '17 at 10:29

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.