LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Please could you post a working configuration for a OPENVPN with bridge ? (https://www.linuxquestions.org/questions/linux-server-73/please-could-you-post-a-working-configuration-for-a-openvpn-with-bridge-753993/)

frenchn00b 09-09-2009 04:48 PM

Please could you post a working configuration for a OPENVPN with bridge ?
 
I would be glad to progress, with a server.conf
and the few extra files or info. you may share.
(without playing with IP tables would be great)
Openvpn is so difficult :(

For the moment I can log into my openvpnc from the client to the server,
but this guy get no single IP address affected in its tap network #3 of xp.


thank you

do we really need to do that ?
Quote:

sudo vi /etc/network/interfaces

After you're done editing it, it it should look approximately like below

## This is the network bridge declaration
auto lo br0 ## start on boot

iface lo inet loopback

iface br0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
bridge_ports eth0

iface eth0 inet manual
up ifconfig $IFACE 0.0.0.0 up
up ip link set $IFACE promisc on
down ip link set $IFACE promisc off
down ifconfig $IFACE down

If you are running linux inside a virtual machine, you may want to add the following parameters to the bridge connection:

bridge_fd 9 ## from the libvirt docs (forward delay time)
bridge_hello 2 ## from the libvirt docs (hello time)
bridge_maxage 12 ## from the libvirt docs (maximum message age)
bridge_stp off ## from the libvirt docs (spanning tree protocol)

to restart networking run

scheidel21 09-10-2009 12:11 PM

First you need to bridge the eth0 interface with the TAP0 interface on the server. I recommend googling for openvpn bridge setup script it will automate that for you, that will likely fix your lack of IP issue if your openvpn server is configured properly.

frenchn00b 09-10-2009 12:17 PM

Quote:

Originally Posted by scheidel21 (Post 3677565)
__________________
Why get rid of old equipment when you can breath new life into it? That old PowerPC 601, or the old 486DX or Pentium machine no longer just door stops now they're routers, servers, fully operational word processors, and cluster computing powerhouses.

http://www.linuxquestions.org/questi...389/page5.html

thank you !

--
btw I googled PowerPC 601 emulator linux,
and not found :(
those were cool those old macintosh!

frenchn00b 09-10-2009 10:20 PM

Quote:

Originally Posted by scheidel21 (Post 3677565)
First you need to bridge the eth0 interface with the TAP0 interface on the server. I recommend googling for openvpn bridge setup script it will automate that for you, that will likely fix your lack of IP issue if your openvpn server is configured properly.

I am working on an installer:

it is geting on the right direction, but still not perfect ...

Code:

#!/bin/sh

clear

echo "  "
echo " --------------------------  "
echo " INSTALLER OF OPENVPN FOR NEWBIES, FRENCHN00B  "
echo " --------------------------  "
echo "  "
echo " Ready to break your machine  YES/YES? ctrl+c to exit "
read yesyes

apt-get install openvpn bridge-utils mc

ifconfig

echo "  "

echo "Your machine with vpn, IP"
read IPSERVER

echo "Your router with vpn, IP"
read IPROUTER

echo "----------------------------------------"
cp /etc/network/interfaces "/etc/network/interfaces-$(date)"
cp /etc/network/interfaces "/etc/network/interfaces_bak"

#



echo "## This is the network bridge declaration" >  /tmp/interface.tmp
echo "auto lo br0  ## start on boot" >>  /tmp/interface.tmp
echo " " >>  /tmp/interface.tmp
echo "iface lo inet loopback " >>  /tmp/interface.tmp
echo " " >>  /tmp/interface.tmp
echo "iface br0 inet static " >>  /tmp/interface.tmp
echo "  address $IPSERVER " >>  /tmp/interface.tmp
echo "  netmask 255.255.255.0" >>  /tmp/interface.tmp
echo "  gateway $IPROUTER" >>  /tmp/interface.tmp
echo "  bridge_ports eth0" >>  /tmp/interface.tmp
echo "  " >>  /tmp/interface.tmp
echo "iface eth0 inet manual" >>  /tmp/interface.tmp


echo '  up ifconfig $IFACE 0.0.0.0 up'  >> /tmp/interface.tmp
echo '  up ip link set $IFACE promisc on'  >> /tmp/interface.tmp
echo '  down ip link set $IFACE promisc off'  >> /tmp/interface.tmp
echo '  down ifconfig $IFACE down '  >> /tmp/interface.tmp
 
mc -e /tmp/interface.tmp
cp /tmp/interface.tmp /etc/network/interfaces
echo "----------------------------------------"
 
  /etc/init.d/networking restart
   
 echo "#!/bin/sh"  > /etc/openvpn/up.sh
 echo 'BR=$1' >> /etc/openvpn/up.sh
 echo 'DEV=$2'  >> /etc/openvpn/up.sh
 echo 'MTU=$3'  >> /etc/openvpn/up.sh
 echo '/sbin/ifconfig $DEV mtu $MTU promisc up'  >> /etc/openvpn/up.sh
 echo '/usr/sbin/brctl addif $BR $DEV' >> /etc/openvpn/up.sh
 mc -e /etc/openvpn/up.sh
 
 
 echo "  #!/bin/sh" >  /etc/openvpn/down.sh
 echo ' BR=$1'  >>  /etc/openvpn/down.sh
 echo '  DEV=$2'  >>  /etc/openvpn/down.sh
 echo ' /usr/sbin/brctl delif $BR $DEV'  >>  /etc/openvpn/down.sh
 echo ' /sbin/ifconfig $DEV down'  >>  /etc/openvpn/down.sh
 mc -e /etc/openvpn/down.sh
 
  chmod +x /etc/openvpn/up.sh /etc/openvpn/down.sh
 
  #/etc/openvpn/server.conf
 
cp /etc/openvpn/server.conf "/etc/openvpn/server.conf-$(date)"
cp /etc/openvpn/server.conf  /etc/openvpn/server.conf_bak
 echo 'mode server' > /etc/openvpn/server.conf
 echo 'tls-server ' >> /etc/openvpn/server.conf
 echo '  ' >> /etc/openvpn/server.conf
 echo 'local <your ip address> ## ip/hostname of server ' >> /etc/openvpn/server.conf
 echo 'port 1194 ## default openvpn port ' >> /etc/openvpn/server.conf
 echo 'proto udp ' >> /etc/openvpn/server.conf
 echo '  ' >> /etc/openvpn/server.conf
 echo '#bridging directive ' >> /etc/openvpn/server.conf
 echo 'dev tap0 ## If you need multiple tap devices, add them here ' >> /etc/openvpn/server.conf
 echo '#up "/etc/openvpn/up.sh br0" ' >> /etc/openvpn/server.conf
 echo '#down "/etc/openvpn/down.sh br0" ' >> /etc/openvpn/server.conf
 echo '  ' >> /etc/openvpn/server.conf
 echo ' persist-key ' >> /etc/openvpn/server.conf
 echo ' persist-tun ' >> /etc/openvpn/server.conf
 echo '  ' >> /etc/openvpn/server.conf
 echo ' #certificates and encryption ' >> /etc/openvpn/server.conf
 echo ' ca ca.crt ' >> /etc/openvpn/server.conf
 echo ' cert server.crt ' >> /etc/openvpn/server.conf
 echo ' key server.key  # This file should be kept secret ' >> /etc/openvpn/server.conf
 echo ' dh dh1024.pem ' >> /etc/openvpn/server.conf
 echo ' tls-auth ta.key 0 # This file is secret ' >> /etc/openvpn/server.conf
 echo '  ' >> /etc/openvpn/server.conf
 echo ' cipher BF-CBC        # Blowfish (default) ' >> /etc/openvpn/server.conf
 echo ' comp-lzo ' >> /etc/openvpn/server.conf
 echo '  ' >> /etc/openvpn/server.conf
 echo ' #DHCP Information ' >> /etc/openvpn/server.conf
 echo ' ifconfig-pool-persist ipp.txt ' >> /etc/openvpn/server.conf
 echo " server-bridge $IPSERVER 255.255.255.0 $IPSERVER+100 192.168.1.110"  >> /etc/openvpn/server.conf
# echo ' push "dhcp-option DNS your.dns.ip.here"' >> /etc/openvpn/server.conf
# echo ' push "dhcp-option DOMAIN yourdomain.com"' >> /etc/openvpn/server.conf
 echo ' max-clients 10 ## set this to the max number of clients that should be connected at a time' >> /etc/openvpn/server.conf
 echo ' ' >> /etc/openvpn/server.conf
 echo ' #log and security' >> /etc/openvpn/server.conf
 echo ' user nobody' >> /etc/openvpn/server.conf
 echo ' group nogroup' >> /etc/openvpn/server.conf
 echo ' keepalive 10 120' >> /etc/openvpn/server.conf
 echo ' status openvpn-status.log' >> /etc/openvpn/server.conf
 echo ' verb 3' >> /etc/openvpn/server.conf
 mc -e /etc/openvpn/server.conf
 echo "restart it"
 echo "  "
echo " Ready to break your machine  YES/YES? ctrl+c to exit "
 read restart
 /etc/init.d/openvpn restart


frenchn00b 09-10-2009 11:39 PM

or I use this

Quote:

enVPN is installed by

sudo apt-get install openvpn bridge-utils

Setting up the Bridge

Now you need to edit /etc/network/interfaces

Commonly, you have a linux server behind a NAT firewall, and you want to provide access to a small network. Your /etc/network/interfaces probably looks something like

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo eth0
iface lo inet loopback

# The primary network interface
## This device provides internet access.
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1

We're going to edit this and add a bridge interface. Go ahead and

sudo vi /etc/network/interfaces

After you're done editing it, it it should look approximately like below

## This is the network bridge declaration
auto lo br0 ## start on boot

iface lo inet loopback

iface br0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
bridge_ports eth0

iface eth0 inet manual
up ifconfig $IFACE 0.0.0.0 up
up ip link set $IFACE promisc on
down ip link set $IFACE promisc off
down ifconfig $IFACE down

If you are running linux inside a virtual machine, you may want to add the following parameters to the bridge connection:

bridge_fd 9 ## from the libvirt docs (forward delay time)
bridge_hello 2 ## from the libvirt docs (hello time)
bridge_maxage 12 ## from the libvirt docs (maximum message age)
bridge_stp off ## from the libvirt docs (spanning tree protocol)

to restart networking run

sudo /etc/init.d/networking restart

The bridging decelerations here come from the libvirt documentation. I really only understand the bridge_ports directive and the bridge_stp directive. Therefore if you know more than me help me out.

Generating Certificates

Next, we need to generate certificates for the server. In order to do this I will setup my own Certificate Authority using the provided easy-rsa scripts in the /usr/share/doc/openvpn/examples/easy-rsa/ directory. Another alternative is using the graphical program tinyca to create your CA.

Step 1:

* Copy files to the /etc/openvpn/easy-rsa/ directory

sudo mkdir /etc/openvpn/easy-rsa/
sudo cp -R /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/

Step 2:

* Edit /etc/openvpn/easy-rsa/vars

sudo vi /etc/openvpn/easy-rsa/vars

Change these lines at the bottom so that they reflect your new CA.

export KEY_COUNTRY="US"
export KEY_PROVINCE="CA"
export KEY_CITY="SanFrancisco"
export KEY_ORG="Fort-Funston"
export KEY_EMAIL="me@myhost.mydomain"

Step 3:

* Setup the CA and create your first server certificate

cd /etc/openvpn/easy-rsa/ ## move to the easy-rsa directory
sudo chown -R root:admin . ## make this directory writable by the system administrators
sudo chmod g+w . ## make this directory writable by the system administrators
source ./vars ## execute your new vars file
./clean-all ## Setup the easy-rsa directory (Deletes all keys)
./build-dh ## takes a while consider backgrounding
./pkitool --initca ## creates ca cert and key
./pkitool --server server ## creates a server cert and key
cd keys
openvpn --genkey --secret ta.key ## Build a TLS key
sudo cp server.crt server.key ca.crt dh1024.pem ta.key ../../

Your Certificate Authority is now setup and the needed keys are in /etc/openvpn/

Configuring the Server

By default all servers specified in *.conf files in the /etc/openvpn/ directory are started on boot. Therefore, all we have to do is creating a new file named server.conf in the /etc/openvpn/ directory.

First, we're going to create a couple of new scripts to be used by the openvpn server.

sudo vi /etc/openvpn/up.sh

This script should contain the following

#!/bin/sh

BR=$1
DEV=$2
MTU=$3
/sbin/ifconfig $DEV mtu $MTU promisc up
/usr/sbin/brctl addif $BR $DEV

Now, we'll create a "down" script.

sudo vi /etc/openvpn/down.sh

It should contain the following.

#!/bin/sh

BR=$1
DEV=$2

/usr/sbin/brctl delif $BR $DEV
/sbin/ifconfig $DEV down

Now, make both scripts executable.

sudo chmod +x /etc/openvpn/up.sh /etc/openvpn/down.sh

And now on to configuring openvpn itself.

sudo vi /etc/openvpn/server.conf

mode server
tls-server

local <your ip address> ## ip/hostname of server
port 1194 ## default openvpn port
proto udp



#bridging directive
dev tap0 ## If you need multiple tap devices, add them here
up "/etc/openvpn/up.sh br0"
down "/etc/openvpn/down.sh br0"

persist-key
persist-tun

#certificates and encryption
ca ca.crt
cert server.crt
key server.key # This file should be kept secret
dh dh1024.pem
tls-auth ta.key 0 # This file is secret

cipher BF-CBC # Blowfish (default)
comp-lzo

#DHCP Information
ifconfig-pool-persist ipp.txt
server-bridge 192.168.1.10 255.255.255.0 192.168.1.100 192.168.1.110
push "dhcp-option DNS your.dns.ip.here"
push "dhcp-option DOMAIN yourdomain.com"
max-clients 10 ## set this to the max number of clients that should be connected at a time

#log and security
user nobody
group nogroup
keepalive 10 120
status openvpn-status.log
verb 3

Don't forget to either reboot or run the command below. This will restart openvpn and load the new config.

sudo /etc/init.d/openvpn restart


or this ???

Quote:

put OpenVPN in its place: as a secure tunnel manager.

The important paradigm shift here is that you aren’t required to do anything from withing OpenVPN to configure the interface. You can just bring up the tunnel and your TUN/TAP device will be alive but unconfigured. At that point you could do something like this:

ip link set tap0 up
ip addr add 172.17.0.1/24 dev tap0

You could do this manually, or in an up script, or whatever. Or you could let your distro do it. Ah, so we can have a tap0 stanza in /etc/network/interfaces (Debian-based distros) that will configure tap0 when we ask it to. Let’s look at a client example:

# in /etc/network/interfaces
iface tap0 inet dhcp
hostname falcon
# dhclient doesn't pay attention to this, so if you use dhclient (you
# probably do) see /etc/dhcp3/dhclient.conf
client falcon

# in the openvpn config
dev tap0
route-delay 10
cd /etc/openvpn
up "up.sh"
down-pre
down "down.sh"


# up.sh
#! /bin/bash
ifdown tap0 2>/dev/null
ifup tap0 &

# down.sh
ifdown tap0

There’s some subtlety here, let’s talk about it. Note that we’re specifying both the DHCP client id and the DHCP hostname—more on that later. We use an external script because of the way OpenVPN’s up option works, so that we can background the ifup call. This is important because the tunnel isn’t fully up at this point, so your DHCP client won’t succeed unless we background it (I tried up-delay to no avail). I have the ifdown bit in there as a safety measure—if for whatever reason Debian thinks the interface is already up it won’t start the DHCP client and that would be bad. But hopefully this doesn’t happen much thanks to the down option. Finally, the route-delay option gives the DHCP negotiation a chance to finish before any routes are applied (and in my setup there is one important route that I push to clients).

On the server side, we need to set up the DHCP server. ISC DHCP (dhcp3-server on Debian) isn’t very intelligent about interfaces that materialize out of nowhere, so we’ll need to set up a persistent TAP device.

# in /etc/network/interfaces
auto tap0
iface tap0 inet static
address 172.17.0.1
netmask 255.255.255.0
pre-up openvpn --dev tap0 --mktun

# in openvpn config
dev tap0

Now tap0 will be brought up automatically at boot, and will stay up even if you restart OpenVPN (you can bring it up now with ifup tap0). Notice that no ifconfig option is needed in the OpenVPN config. Now you can configure your DHCP server for the subnet:
what is better br0 or tap0 in interfaces?

frenchn00b 09-10-2009 11:48 PM

I get the error

TLS Error: cannot locate HMAC" error

and forget tap0
it is too complicated to install

frenchn00b 09-10-2009 11:56 PM

eroro now
Code:

. I am getting this error on my openvpn server : read UDPv4 [EHOSTUNREACH]: No route to host (code=113

frenchn00b 09-10-2009 11:59 PM

pfffffffff
http://www.dd-wrt.com/phpBB2/viewtop...c7ac459d44b83b


I give up with openvpn

frenchn00b 09-11-2009 12:15 AM

I get this address 169.254.131.32 via openvpn but i am not on my network

:( Is there good how to to be bridged?

scheidel21 09-11-2009 07:51 AM

There are plenty of decent HOWTOs this one here is from SUSE but also has notes for Debian, not the the bridge script, and also note that the interfaces file has only the physical interfaces noted in this case eth0

http://en.opensuse.org/Yet_another_O...de_setup_howto

THis is some info on bridged VPN setup

http://www.openvpn.net/index.php/ope...-bridging.html

I used this HOWTO myself

http://vickeryj.freeshell.org/notes/open_vpn_howto.htm

Note I did not edit the openVPN init.d script but I did copy a bridge script edit it, and then added it to init.d and had it start automatically at boot so I didn't have to manually run a bridge start script every time.

There are also countless other HOWTO's that are good, but for a final note let me post some of my configs, they are both bridged, in one case the LAN DHCP server hands out address in the other the openVPN server hands out IP addresses. I think your issue at this juncture may be that your end computer is not getting an IP adddress either from DHCP or openVPN. Or perhaps your config is just wrong. BOth if these server configs work, and so does the client config.

Server config 1 LAN DHCP server giving out addresses
Code:

# Which local IP address should OpenVPN
# listen on? (optional)
local 192.168.100.11

# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one.  You will need to
# open up this port on your firewall.
port 1194
#port 4092
# TCP or UDP server?
;proto tcp
proto udp

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
dev tap0
;dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one.  On XP SP2 or higher,
# you may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap

# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key).  Each client
# and the server must have their own cert and
# key file.  The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys.  Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
ca /etc/openvpn/keys/hesco/ca.crt
cert /etc/openvpn/keys/hesco/hesco-server.crt
key /etc/openvpn/keys/hesco/hesco-server.key  # This file should be kept secret

# Diffie hellman parameters.
# Generate your own with:
#  openssl dhparam -out dh1024.pem 1024
# Substitute 2048 for 1024 if you are using
# 2048 bit keys.
dh /etc/openvpn/keys/hesco/dh2048.pem

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
;server 10.8.0.0 255.255.255.0

# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
#ifconfig-pool-persist ipp.txt

# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface.  Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0.  Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients.  Leave this line commented
# out unless you are ethernet bridging.
;server-bridge 192.168.100.12 255.255.255.0 10.8.0.50 10.8.0.100

# Configure server mode for ethernet bridging
# using a DHCP-proxy, where clients talk
# to the OpenVPN server-side DHCP server
# to receive their IP address allocation
# and DNS server addresses.  You must first use
# your OS's bridging capability to bridge the TAP
# interface with the ethernet NIC interface.
# Note: this mode only works on clients (such as
# Windows), where the client-side TAP adapter is
# bound to a DHCP client.
server-bridge

# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
push "route 192.168.168.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"

# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
#  iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN.  This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#  ifconfig-push 10.9.0.1 10.9.0.2

# Suppose that you want to enable different
# firewall access policies for different groups
# of clients.  There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
#    group, and firewall the TUN/TAP interface
#    for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
#    modify the firewall in response to access
#    from different clients.  See man
#    page for more info on learn-address script.
;learn-address ./script

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly).
;push "redirect-gateway def1 bypass-dhcp"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.  CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
;push "dhcp-option DNS 208.67.222.222"
;push "dhcp-option DNS 208.67.220.220"

# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
client-to-client

# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names.  This is recommended
# only for testing purposes.  For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120

# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
#  openvpn --genkey --secret ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
;tls-auth ta.key 0 # This file is secret

# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
;cipher BF-CBC        # Blowfish (default)
cipher AES-128-CBC  # AES
;cipher DES-EDE3-CBC  # Triple-DES

# Enable compression on the VPN link.
# If you enable it here, you must also
# enable it in the client config file.
comp-lzo

# The maximum number of concurrently connected
# clients we want to allow.
;max-clients 100

# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this out on
# non-Windows systems.
user nobody
group nogroup

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status openvpn-status.log

# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it.  Use one
# or the other (but not both).
;log        openvpn.log
;log-append  openvpn.log

# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3

# Silence repeating messages.  At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20

This one has different encryption, runs on a diffeent port and has the openVPN server handing out IP addresses, this one works too.
Code:

# Which local IP address should OpenVPN
# listen on? (optional)
local 192.168.1.3

# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one.  You will need to
# open up this port on your firewall.
#port 1194
port 4091

# TCP or UDP server?
proto tcp
;proto udp

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
dev tap0
;dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one.  On XP SP2 or higher,
# you may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap

# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key).  Each client
# and the server must have their own cert and
# key file.  The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys.  Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
ca /etc/openvpn/keys/enip-vpn/ca.crt
cert /etc/openvpn/keys/enip-vpn/enip-vpn-server.crt
key /etc/openvpn/keys/enip-vpn/enip-vpn-server.key  # This file should be kept secret

# Diffie hellman parameters.
# Generate your own with:
#  openssl dhparam -out dh1024.pem 1024
# Substitute 2048 for 1024 if you are using
# 2048 bit keys.
dh /etc/openvpn/keys/enip-vpn/dh2048.pem

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
#server 10.8.0.0 255.255.255.0

# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist ipp.txt

# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface.  Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0.  Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients.  Leave this line commented
# out unless you are ethernet bridging.
server-bridge 192.168.1.3 255.255.255.0 192.168.1.243 192.168.1.247

# Configure server mode for ethernet bridging
# using a DHCP-proxy, where clients talk
# to the OpenVPN server-side DHCP server
# to receive their IP address allocation
# and DNS server addresses.  You must first use
# your OS's bridging capability to bridge the TAP
# interface with the ethernet NIC interface.
# Note: this mode only works on clients (such as
# Windows), where the client-side TAP adapter is
# bound to a DHCP client.
;server-bridge

# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"

# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
#  iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN.  This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#  ifconfig-push 10.9.0.1 10.9.0.2

# Suppose that you want to enable different
# firewall access policies for different groups
# of clients.  There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
#    group, and firewall the TUN/TAP interface
#    for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
#    modify the firewall in response to access
#    from different clients.  See man
#    page for more info on learn-address script.
;learn-address ./script

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly).
;push "redirect-gateway def1 bypass-dhcp"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.  CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
;push "dhcp-option DNS 192.168.1.10"
;push "dhcp-option DNS 208.67.220.220"

# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
client-to-client

# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names.  This is recommended
# only for testing purposes.  For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120

# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
#  openvpn --genkey --secret ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
;tls-auth ta.key 0 # This file is secret

# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
;cipher BF-CBC        # Blowfish (default)
cipher AES-256-CBC  # AES
;cipher DES-EDE3-CBC  # Triple-DES

# Enable compression on the VPN link.
# If you enable it here, you must also
# enable it in the client config file.
comp-lzo

# The maximum number of concurrently connected
# clients we want to allow.
max-clients 2

# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this out on
# non-Windows systems.
user nobody
group nogroup

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status openvpn-status.log

# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it.  Use one
# or the other (but not both).
;log        openvpn.log
;log-append  openvpn.log

# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3

# Silence repeating messages.  At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20

This is a client config file I know works on windows machines, I have xed out the Public IP and note you would have to change the key and cert values to match your appropriate key and cert.

Code:

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
dev tap
;dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
dev-node HESCOVPN

# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote x.x.x.x 1194
;remote my-server-2 1194

# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nogroup

# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
ca cah.crt
cert alexs.crt
key alexs.key

# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server".  This is an
# important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server".  The build-key-server
# script in the easy-rsa folder will do this.
ns-cert-type server

# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
cipher AES-128-CBC

# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo

# Set log file verbosity.
verb 3

# Silence repeating messages
;mute 20

This ine is the client match for the second server configuration.
Code:

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tap

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
dev-node tap0

# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
;remote 192.168.2.1 4091
remote 192.168.168.168 4091
;remote my-server-2 1194

# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
#nobind

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nobody

# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
ca ca.crt
cert carlos.crt
key carlos.key

# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server".  This is an
# important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server".  The build-key-server
# script in the easy-rsa folder will do this.
ns-cert-type server

mssfix

# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
cipher AES-256-CBC

# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo

# Set log file verbosity.
verb 3

# Silence repeating messages
;mute 20


scheidel21 09-11-2009 08:00 AM

Notes:

I think your are getting assigned a private IP address (169.x.x.x) because openVPN is not configured to hand out IP addresses or DHCP passthrough is not enabled in the config.

You cannot test from a machine that is on the same subnet as the openVPN server your routing tables will go to hell and it won't work.

YOu cannot test from a LAN connected to a router that knows exactly how to route to the openVPN LAN or again your routing won't work properly.

For instance We have a LAN here that has specialized equipment on it, and we needed remote access to it, I had to set up a second router to be able to get it to work porperly (THis is server config and client config 2) The ASCII diagram below I hope will show you how this works.

Code:

192.168.100.xLAN--->SSG140 Router ETH port 1--->SSG140 ETH port 4--->192.168.168.xLAN--->SOnicWall WAN PORT--->SonicWallLAN Port--->192.168.1.xLAN with openVPN Server
For a bridged VPN you NEED to have a tap0 Interface AND a Bridge interface that is what the bridge script does, it is also much better than playing with the interfaces file too. The bridge script does the following
Quote:

1)Creates Bridge interface, usually br0
2)Creates Tap virtual interface, usually tap0
3)Takes down physical interface, usually eth0
4)Adds physical interface (eth0) and virtual interface (tap0) to the bridge interface (br0)
5)Configures bridge interface to given IP address and Subnet information
6)COnfigures eth0 and tap0 so that they are promiscuous
7)Brings all interfaces up.
So now When you type the IP address it is directed to br0 instead of eth0 and both eth0 and tap0 see the information because they are part of the bridge and will ready all infomation becuase they are in promiscuos mode.

Here is my Interface and bridge script
Code:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.100.11
        netmask 255.255.255.0
        broadcast 192.168.100.255
        network 192.168.100.0
        gateway 192.168.100.1

allow-hotplug eth1
iface eth1 inet static
        address 192.168.100.2
        netmask 255.255.255.0
        broadcast 192.168.100.255
        network 192.168.100.0
        gateway 192.168.100.1

Code:

#!/bin/bash 
# Create global variables 
# 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.100.11"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.100.255"
gw="192.168.100.1" 
start_bridge () { 
################################# 
# Set up Ethernet bridge on Linux 
# Requires: bridge-utils 
#################################   
for t in $tap; do
openvpn --mktun --dev $t 
done   
for t in $tap; do
ifconfig $t 0.0.0.0 promisc up 
done
ifconfig $eth 0.0.0.0 promisc up
brctl addbr $br
brctl addif $br $eth
for t in $tap; do
brctl addif $br $t 
done   
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast up 
route add default gw $gw $br
}
stop_bridge () { 
#################################### 
# Tear Down Ethernet bridge on Linux 
####################################   
ifconfig $br down
brctl delbr $br   
for t in $tap; do
openvpn --rmtun --dev $t 
done 
ifconfig $eth $eth_ip netmask $eth_netmask broadcast $eth_broadcast up 
route add default gw $gw $eth

case "$1" in
start) 
echo -n "Starting Bridge" 
start_bridge 
;;
stop) 
echo -n "Stopping Bridge" 
stop_bridge 
;;
restart) 
stop_bridge 
sleep 2 
start_bridge 
;;
*) 
echo "Usage: $0 {start|stop|restart}" >&2 
exit 1 
;;
esac

Of the utmost importance here too, is that the bridge script bring up the routing table default entry too, I initially had a script that did not do that and after the bridge script ran I would never have internet access, addign the deafult route fixes that. This script does add the default route.

Hope this information helps you.

frenchn00b 09-13-2009 11:56 AM

Now I note that I have same problem too

my friend cannot vpn logins from outside my router



Code:

    * ct: Re: [Openvpn-users] OpenVPN - Pass through router - General LAN access
    * From: Tom Brown <tom@xxxxxxxx>
    * Date: Tue, 13 Jun 2006 10:44:22 +0100

       

> Well, in a routed environment you need routes and you need to enable IP
> forwarding.
>
> Do not forget the return routes to your VN connected clients/networks.

thanks for the reply - so....

IP forwarding needs to be enabled on the VPN server and the machines on
the LAN need their gateway setting to this servers IP??

i work on that conf


any helps?

scheidel21 09-13-2009 07:31 PM

The last post from you is in regards to a routed VPN not a bridged VPN, there is a distinct difference. Bridged VPNs make it so that the remote computer appears to be plugged directly into the infrastucture of you LAN, while routed networks look like the remote computer is on a different LAN and the VPN box acts as the router between the Remote LAN and the local LAN. You need to decide which one you want/need and be dlear about that before we can try to assist you in implementing it.

frenchn00b 09-13-2009 10:46 PM

Quote:

Originally Posted by scheidel21 (Post 3681591)
The last post from you is in regards to a routed VPN not a bridged VPN, there is a distinct difference. Bridged VPNs make it so that the remote computer appears to be plugged directly into the infrastucture of you LAN, while routed networks look like the remote computer is on a different LAN and the VPN box acts as the router between the Remote LAN and the local LAN. You need to decide which one you want/need and be dlear about that before we can try to assist you in implementing it.

Well I have to say that yesterday I gave up a bit, lost all hopes about install VPN. I am not informatics skilled because not my job, and openvpn is not meant easy for big newbies .... informatic is so difficult.

My reply is Bridge. I would like to get an IP 192.xxxx like on the router for the client. the client is outside the router blocking the ingoing, ie regular router(internet), opened to 1194.

Here is my configs

To know what is installed? Nothing I installed my server as 578mb. so it has the minimum and a ssh. thats all. Mutt and sendmail are there.

My /etc/network/interface is:
Code:

$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

my IP is 192.168.2.100
the router is at 192.168.2.1
it has no dyndns (it sends me per email the IP via mutt).

So you can try, it's a clean installation.

regards, thanks

scheidel21 09-14-2009 12:26 AM

Ok here are some steps to hopefully make this work

1)Change your interfaces file so that the IP address for eth0 is assigned statically

Code:

allow-hotplug eth0
iface eth0 inet static
    address 192.168.2.100
    subnet 255.255.255.0
    broadcast 192.168.2.255
    gateway 192.168.2.1

2)Next, take the bridging script from my post above and copy it, install it in init.d folder under /etc and make the file executable. Then fill in the appropriate values in the settings (The same ones for your static assignment for eth0 in your interfaces file.)

3)Next copy the first server config file I posted above for openVPN and place that in /etc/openVPN name the file server.conf make sure there are no other server config files in the directory.

4)run /etc/init.d/openvpn restart

5) Run netstat -l and see if you are listening on port 1194 if you are that is a good start your server is listening for connections.

I will get back to you but I have to run right now.


All times are GMT -5. The time now is 09:07 AM.