from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites: www.linuxhowtos.org
toolsntoys.linuxhowtos.org



Last additions:
How to make X listen on port 6000

How to make X listen on port 6000

words:

34

views:

82790

userrating:

average rating: 1.2 (52 votes) (1=very good 6=terrible)


May, 25th 2007:
April, 26th 2007:
Apr, 10th. 2007:
Druckversion . pdf icon
You are here: Tutorials per portage category->net-misc->openvpn

OpenVPN primer


There are as many advantages to VPN tunnels as there are different VPN scenarios. One easy implementation is the "OpenVPN via tun-device" solution. An example: you'd like to connect your laptop to your LAN at home so that you can use your mail client without reconfiguring it anytime you switch from home to internet and back. Let's say your mail-server is 192.168.1.10 in your LAN (192.168.1.0/24) at home, and you have got a router/firewall providing access to the Internet. You connect from work or school and want to read mail. OpenVPN can create two virtual devices for you when connecting two computers through an encrypted tunnel. Naturally you then have the possibility of forwarding traffic into the networks behind them, and thus would be "virtually connected" to your LAN behind the firewall. To enable this, either your firewall or a server behind it should run OpenVPN (if you choose a server in your LAN, you'll have to forward the destination port to the OpenVPN server).

Here's what you need to do:
Code Listing 1: Enable the tun module in your kernel: Kernel config - tun module
          [*] Networking support    
Networking options --->
[ ] Amateur Radio support --->
< > IrDA (infrared) subsystem support --->
< > Bluetooth subsystem support --->
[*] Network device support
< > Dummy net driver support
< > Bonding driver support
< > EQL (serial line load balancing) support
Universal TUN/TAP device driver support
// This option must be enabled


Make sure this module exists and can be loaded. Next, install OpenVPN and it dependencies.
Code Listing 2: Install OpenVPN
emerge openvpn

Now on both server and client, create a directory for your configuration:

Code Listing 3: Make directory
mkdir /etc/openvpn    
mkdir /etc/openvpn/myhomelan


Inside that directory, create a shared key for your VPN session and copy that key to the client's directory, /etc/openvpn/myhomelan.

Code Listing 4: Generate shared key
cd /etc/openvpn/myhomelan    
openvpn --genkey --secret myhomelan-key.txt


Now for the tricky part, the routing. It is important that the two tun devices on the client and server use IP addresses from the same subnet. The configuration files shown below list the type of device, the two end-points of the tunnel, the compression method and the UDP-port on which the tunnel is established. Finally privileges are dropped to user and group as listed:

Code Listing 5: Server-side configuration file /etc/openvpn/myhomelan/local.conf
dev tun    
ifconfig 172.16.1.1 172.16.1.20 // IP of the local
// tun device and its peer
secret /etc/openvpn/myhomelan/myhomelan-key.txt
comp-lzo
port 5000
user nobody
group nobody


The client's configuration needs the tunnel's destination address. This is often a dynamic DNS address, sometimes a fixed IP, depending on your ISP. You also need to route to your home LAN (192.168.1.0 in our example). You can call a shell script from the configuration file that accordingly sets a route.

Code Listing 6: Client-side configuration file /etc/openvpn/myhomelan/local.conf
remote    // or your VPN 
// server's external IP if you have a fixed one
dev tun
ifconfig 172.16.1.20 172.16.1.1 // IP of the local tun
// device and its peer
secret /etc/openvpn/myhomelan/myhomelan-key.txt
comp-lzo
port 5000
user nobody
group nobody
up /etc/openvpn/myhomelan/route.sh // sets up the route
//to the network behind the VPN server


The route command would need to set the client's gateway for the network 192.168.1.0 to its peer's address (172.16.1.1 in our setup).

Code Listing 7: /etc/openvpn/myhomelan/route.sh
#!/bin/bash    
route add -net 192.168.1.0 netmask 255.255.255.0 gw 172.16.1.1


That's it. Start OpenVPN on the server and the client, and check the devices with ifconfig and the routes with route -n. Success!

From http://www.gentoo.org/news/en/gwn/20041011-newsletter.xml
rate this article:
current rating: average rating: 1.6 (45 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back



Support us on Content Nation

New Packages

- as rdf newsfeed
- as rss newsfeed
- as Atom newsfeed
2026-01-12
binary-orphans - 1.0.5
Ebuild name:

dev-haskell/binary-orphans-1.0.5

Description

Compatibility package for binary; provides instances

Added to portage

2026-01-12

bitvec - 1.1.5.0
Ebuild name:

dev-haskell/bitvec-1.1.5.0

Description

Space-efficient bit vectors

Added to portage

2026-01-12

calligraplan - 4.0.1
Ebuild name:

app-office/calligraplan-4.0.1

Description

Project management application

Added to portage

2026-01-12

dulwich - 0.25.2
Ebuild name:

dev-python/dulwich-0.25.2

Description

Pure-Python implementation of the Git file formats and protocols

Added to portage

2026-01-12

hishel - 1.1.8
Ebuild name:

dev-python/hishel-1.1.8

Description

An elegant HTTP Cache implementation for HTTPX and HTTP Core

Added to portage

2026-01-12

inkscape - 1.4.3
Ebuild name:

media-gfx/inkscape-1.4.3

Description

SVG based generic vector-drawing program

Added to portage

2026-01-12

kdevelop - 25.12.1-r1
Ebuild name:

dev-util/kdevelop-25.12.1-r1

Description

Integrated Development Environment, supporting KF6/Qt, C/C++ and much

Added to portage

2026-01-12

onetuple - 0.4.2.1
Ebuild name:

dev-haskell/onetuple-0.4.2.1

Description

Singleton Tuple

Added to portage

2026-01-12

openpgp-keys-gentoo-developers - 20260105
Ebuild name:

sec-keys/openpgp-keys-gentoo-developers-20260105

Description

Gentoo Authority Keys (GLEP 79)

Added to portage

2026-01-12

pcsx2 - 2.6.2
Ebuild name:

games-emulation/pcsx2-2.6.2

Description

PlayStation 2 emulator

Added to portage

2026-01-12

regex-base - 0.94.0.3
Ebuild name:

dev-haskell/regex-base-0.94.0.3

Description

Common

Added to portage

2026-01-12

regex-posix - 0.96.0.2
Ebuild name:

dev-haskell/regex-posix-0.96.0.2

Description

POSIX Backend for

Added to portage

2026-01-12

ruby-cairo-gobject - 4.3.4
Ebuild name:

dev-ruby/ruby-cairo-gobject-4.3.4

Description

Ruby cairo-gobject bindings

Added to portage

2026-01-12

ruby-gio2 - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-gio2-4.3.4-r1

Description

Ruby binding of gio-2

Added to portage

2026-01-12

ruby-glib2 - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-glib2-4.3.4-r1

Description

Ruby Glib2 bindings

Added to portage

2026-01-12

ruby-gobject-introspection - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-gobject-introspection-4.3.4-r1

Description

Ruby GObjectIntrospection bindings

Added to portage

2026-01-12

ruby-poppler - 4.3.4
Ebuild name:

dev-ruby/ruby-poppler-4.3.4

Description

Ruby poppler-glib bindings

Added to portage

2026-01-12

systemd - 259
Ebuild name:

sys-apps/systemd-259

Description

System and service manager for Linux

Added to portage

2026-01-12

whenever - 0.9.5
Ebuild name:

dev-python/whenever-0.9.5

Description

Modern datetime library for Python

Added to portage

2026-01-12

2026-01-11
aiodns - 4.0.0
Ebuild name:

dev-python/aiodns-4.0.0

Description

Simple DNS resolver for asyncio

Added to portage

2026-01-11

alsa-firmware - 1.2.4-r2
Ebuild name:

sys-firmware/alsa-firmware-1.2.4-r2

Description

Advanced Linux Sound Architecture firmware

Added to portage

2026-01-11

alsa-tools - 1.2.15-r1
Ebuild name:

media-sound/alsa-tools-1.2.15-r1

Description

Advanced Linux Sound Architecture tools

Added to portage

2026-01-11

ansi-terminal - 1.1.5
Ebuild name:

dev-haskell/ansi-terminal-1.1.5

Description

Simple ANSI terminal support

Added to portage

2026-01-11

ansi-terminal-types - 1.1.3
Ebuild name:

dev-haskell/ansi-terminal-types-1.1.3

Description

Types and functions used to represent SGR aspects

Added to portage

2026-01-11

assoc - 1.1.1
Ebuild name:

dev-haskell/assoc-1.1.1

Description

swap and assoc Symmetric and Semigroupy Bifunctors

Added to portage

2026-01-11

bcachefs-kmod - 1.34.0
Ebuild name:

sys-fs/bcachefs-kmod-1.34.0

Description

Linux bcachefs kernel module for sys-fs/bcachefs-tools

Added to portage

2026-01-11

bcachefs-kmod - 9999
Ebuild name:

sys-fs/bcachefs-kmod-9999

Description

Linux bcachefs kernel module for sys-fs/bcachefs-tools

Added to portage

2026-01-11

bifunctors - 5.6.3
Ebuild name:

dev-haskell/bifunctors-5.6.3

Description

Haskell 98 bifunctors, bifoldables and bitraversables

Added to portage

2026-01-11

clock - 0.8.4
Ebuild name:

dev-haskell/clock-0.8.4

Description

High-resolution clock functions monotonic, realtime, cputime

Added to portage

2026-01-11

cmake - 4.2.1-r1
Ebuild name:

dev-build/cmake-4.2.1-r1

Description

Cross platform Make

Added to portage

2026-01-11

comonad - 5.0.10
Ebuild name:

dev-haskell/comonad-5.0.10

Description

Provides comonads, the categorical dual of monads

Added to portage

2026-01-11

cstruct - 6.2
Ebuild name:

dev-python/cstruct-6.2

Description

C-style structs for Python

Added to portage

2026-01-11

cyme - 2.2.10
Ebuild name:

sys-apps/cyme-2.2.10

Description

List system USB buses and devices; a modern cross-platform `lsusb`

Added to portage

2026-01-11

data-array-byte - 0.1.0.2
Ebuild name:

dev-haskell/data-array-byte-0.1.0.2

Description

Compatibility layer for Data.Array.Byte

Added to portage

2026-01-11

data-fix - 0.3.4
Ebuild name:

dev-haskell/data-fix-0.3.4

Description

Fixpoint data types

Added to portage

2026-01-11

flexmock - 0.13.0
Ebuild name:

dev-python/flexmock-0.13.0

Description

Testing library to create mocks, stubs and fakes

Added to portage

2026-01-11

foldable1-classes-compat - 0.1.3
Ebuild name:

dev-haskell/foldable1-classes-compat-0.1.3

Description

Compatibility package for the Foldable1 and Bifoldable1

Added to portage

2026-01-11

generically - 0.1.1-r2
Ebuild name:

dev-haskell/generically-0.1.1-r2

Description

Generically newtype to use with DerivingVia

Added to portage

2026-01-11

git - 4.1.2
Ebuild name:

dev-ruby/git-4.1.2

Description

Library for using Git in Ruby

Added to portage

2026-01-11

hashable - 1.4.7.0
Ebuild name:

dev-haskell/hashable-1.4.7.0

Description

A class for types that can be converted to a hash value

Added to portage

2026-01-11

indexed-traversable - 0.1.4
Ebuild name:

dev-haskell/indexed-traversable-0.1.4

Description

FunctorWithIndex, FoldableWithIndex, TraversableWithIndex

Added to portage

2026-01-11

indexed-traversable-instances - 0.1.2
Ebuild name:

dev-haskell/indexed-traversable-instances-0.1.2

Description

More instances of FunctorWithIndex, FoldableWithInd

Added to portage

2026-01-11

inspection-testing - 0.6
Ebuild name:

dev-haskell/inspection-testing-0.6

Description

GHC plugin to do inspection testing

Added to portage

2026-01-11

libmateweather - 1.28.1-r2
Ebuild name:

dev-libs/libmateweather-1.28.1-r2

Description

MATE library to access weather information from online services

Added to portage

2026-01-11

linux-firmware - 20251125_p20251229
Ebuild name:

sys-kernel/linux-firmware-20251125_p20251229

Description

Linux firmware files

Added to portage

2026-01-11

mtl - 2.2.2-r2
Ebuild name:

dev-haskell/mtl-2.2.2-r2

Description

Monad classes, using functional dependencies

Added to portage

2026-01-11

mutter - 48.6-r1
Ebuild name:

x11-wm/mutter-48.6-r1

Description

GNOME compositing window manager based on Clutter

Added to portage

2026-01-11

onnx - 1.20.1
Ebuild name:

sci-ml/onnx-1.20.1

Description

Open Neural Network Exchange (ONNX)

Added to portage

2026-01-11

os-string - 2.0.7
Ebuild name:

dev-haskell/os-string-2.0.7

Description

Library for manipulating Operating system strings

Added to portage

2026-01-11

os-string - 2.0.8
Ebuild name:

dev-haskell/os-string-2.0.8

Description

Library for manipulating Operating system strings

Added to portage

2026-01-11

pcre-light - 0.4.1.3
Ebuild name:

dev-haskell/pcre-light-0.4.1.3

Description

Portable regex library for Perl 5 compatible regular expressions

Added to portage

2026-01-11

postfix - 3.12_pre20260110
Ebuild name:

mail-mta/postfix-3.12_pre20260110

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2026-01-11

qpdf - 12.3.0
Ebuild name:

app-text/qpdf-12.3.0

Description

Command-line tool for structural, content-preserving transformation of PDF fil

Added to portage

2026-01-11

quickcheck - 2.14.3-r1
Ebuild name:

dev-haskell/quickcheck-2.14.3-r1

Description

Automatic testing of Haskell programs

Added to portage

2026-01-11

quickcheck-classes-base - 0.6.2.0-r1
Ebuild name:

dev-haskell/quickcheck-classes-base-0.6.2.0-r1

Description

QuickCheck common typeclasses from 'base'

Added to portage

2026-01-11

random - 1.2.1.3
Ebuild name:

dev-haskell/random-1.2.1.3

Description

Pseudo-random number generation

Added to portage

2026-01-11

rb_sys - 0.9.124
Ebuild name:

dev-ruby/rb_sys-0.9.124

Description

Easily build Ruby native extensions in Rust

Added to portage

2026-01-11

scipy - 1.17.0
Ebuild name:

dev-python/scipy-1.17.0

Description

Scientific algorithms library for Python

Added to portage

2026-01-11

starlette - 0.51.0
Ebuild name:

dev-python/starlette-0.51.0

Description

The little ASGI framework that shines

Added to portage

2026-01-11

statevar - 1.2.2-r1
Ebuild name:

dev-haskell/statevar-1.2.2-r1

Description

State variables

Added to portage

2026-01-11

syd - 3.48.4
Ebuild name:

sys-apps/syd-3.48.4

Description

seccomp and landlock based application sandbox with support for namespaces

Added to portage

2026-01-11

tagged - 0.8.10
Ebuild name:

dev-haskell/tagged-0.8.10

Description

Haskell 98 phantom types to avoid unsafely passing dummy arguments

Added to portage

2026-01-11

tasty-inspection-testing - 0.2.1-r1
Ebuild name:

dev-haskell/tasty-inspection-testing-0.2.1-r1

Description

Inspection testing support for tasty

Added to portage

2026-01-11

tavern - 3.1.0
Ebuild name:

dev-python/tavern-3.1.0

Description

A tool, library, and Pytest plugin for testing RESTful APIs

Added to portage

2026-01-11

th-abstraction - 0.7.2.0
Ebuild name:

dev-haskell/th-abstraction-0.7.2.0

Description

Nicer interface for reified information about data types

Added to portage

2026-01-11

tomli - 2.4.0
Ebuild name:

dev-python/tomli-2.4.0

Description

A lil' TOML parser

Added to portage

2026-01-11

vector - 0.13.2.0
Ebuild name:

dev-haskell/vector-0.13.2.0

Description

Efficient Arrays

Added to portage

2026-01-11

vector-stream - 0.1.0.1
Ebuild name:

dev-haskell/vector-stream-0.1.0.1

Description

Efficient Streams

Added to portage

2026-01-11

rdf newsfeed | rss newsfeed | Atom newsfeed
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
- Copyright and legal notices -
Time to create this page: 64.7 ms