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:

83059

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-02-02
alsa-tools - 1.2.11-r2
Ebuild name:

media-sound/alsa-tools-1.2.11-r2

Description

Advanced Linux Sound Architecture tools

Added to portage

2026-02-02

alsa-tools - 1.2.14-r1
Ebuild name:

media-sound/alsa-tools-1.2.14-r1

Description

Advanced Linux Sound Architecture tools

Added to portage

2026-02-02

alsa-tools - 1.2.15-r2
Ebuild name:

media-sound/alsa-tools-1.2.15-r2

Description

Advanced Linux Sound Architecture tools

Added to portage

2026-02-02

babel - 2.18.0
Ebuild name:

dev-python/babel-2.18.0

Description

Collection of tools for internationalizing Python applications

Added to portage

2026-02-02

blessed - 1.29.0
Ebuild name:

dev-python/blessed-1.29.0

Description

Library for making terminal apps using colors, keyboard input and positio

Added to portage

2026-02-02

cachetools - 7.0.0
Ebuild name:

dev-python/cachetools-7.0.0

Description

Extensible memoizing collections and decorators

Added to portage

2026-02-02

dbus-fast - 4.0.0
Ebuild name:

dev-python/dbus-fast-4.0.0

Description

A faster version of dbus-next

Added to portage

2026-02-02

git-sources - 6.19_rc8
Ebuild name:

sys-kernel/git-sources-6.19_rc8

Description

The very latest -git version of the Linux kernel

Added to portage

2026-02-02

gunicorn - 25.0.0
Ebuild name:

www-servers/gunicorn-25.0.0

Description

A WSGI HTTP Server for UNIX

Added to portage

2026-02-02

libzdb - 3.5.0
Ebuild name:

dev-db/libzdb-3.5.0

Description

A thread safe high level multi-database connection pool library

Added to portage

2026-02-02

nvidia-drivers - 580.126.09-r1
Ebuild name:

x11-drivers/nvidia-drivers-580.126.09-r1

Description

NVIDIA Accelerated Graphics Driver

Added to portage

2026-02-02

poetry - 2.3.2
Ebuild name:

dev-python/poetry-2.3.2

Description

A frontend for poetry - a python dependency management and packaging tool

Added to portage

2026-02-02

poetry-core - 2.3.1
Ebuild name:

dev-python/poetry-core-2.3.1

Description

Poetry PEP 517 Build Backend

Added to portage

2026-02-02

rich - 14.3.2
Ebuild name:

dev-python/rich-14.3.2

Description

Python library for rendering rich text, tables, etc. to the terminal

Added to portage

2026-02-02

shadow - 4.19.3
Ebuild name:

sys-apps/shadow-4.19.3

Description

Utilities to deal with user accounts

Added to portage

2026-02-02

stockfish - 18
Ebuild name:

games-board/stockfish-18

Description

Free UCI chess engine, claimed to be the strongest in the world

Added to portage

2026-02-02

zenlib - 3.2.1
Ebuild name:

dev-python/zenlib-3.2.1

Description

Useful python decorators and utilities

Added to portage

2026-02-02

2026-02-01
caffe2 - 2.10.0-r2
Ebuild name:

sci-ml/caffe2-2.10.0-r2

Description

A deep learning framework

Added to portage

2026-02-01

clang - 23.0.0_pre20260131
Ebuild name:

dev-python/clang-23.0.0_pre20260131

Description

Python bindings for llvm-core/clang

Added to portage

2026-02-01

clang - 23.0.0_pre20260131
Ebuild name:

llvm-core/clang-23.0.0_pre20260131

Description

C language family frontend for LLVM

Added to portage

2026-02-01

clang-common - 23.0.0_pre20260131
Ebuild name:

llvm-core/clang-common-23.0.0_pre20260131

Description

Common files shared between multiple slots of clang

Added to portage

2026-02-01

commons-codec - 1.21.0
Ebuild name:

dev-java/commons-codec-1.21.0

Description

Implementations of common encoders and decoders in Java

Added to portage

2026-02-01

compiler-rt - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/compiler-rt-23.0.0_pre20260131

Description

Compiler runtime library for clang (built-in part)

Added to portage

2026-02-01

compiler-rt-sanitizers - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/compiler-rt-sanitizers-23.0.0_pre20260131

Description

Compiler runtime libraries for clang (sanit

Added to portage

2026-02-01

discord - 0.0.122
Ebuild name:

net-im/discord-0.0.122

Description

All-in-one voice and text chat for gamers

Added to portage

2026-02-01

ensurepip-pip - 26.0
Ebuild name:

dev-python/ensurepip-pip-26.0

Description

Shared pip wheel for ensurepip Python module

Added to portage

2026-02-01

evolution - 3.58.3
Ebuild name:

mail-client/evolution-3.58.3

Description

Integrated mail, addressbook and calendaring functionality

Added to portage

2026-02-01

evolution-data-server - 3.58.3
Ebuild name:

gnome-extra/evolution-data-server-3.58.3

Description

Evolution groupware backend

Added to portage

2026-02-01

evolution-ews - 3.58.3
Ebuild name:

gnome-extra/evolution-ews-3.58.3

Description

Evolution module for connecting to Microsoft Exchange Web Services

Added to portage

2026-02-01

flang - 23.0.0_pre20260131
Ebuild name:

llvm-core/flang-23.0.0_pre20260131

Description

LLVM's Fortran frontend

Added to portage

2026-02-01

flang-rt - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/flang-rt-23.0.0_pre20260131

Description

LLVM's Fortran runtime

Added to portage

2026-02-01

libclc - 23.0.0_pre20260131
Ebuild name:

llvm-core/libclc-23.0.0_pre20260131

Description

OpenCL C library

Added to portage

2026-02-01

libcxx - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/libcxx-23.0.0_pre20260131

Description

New implementation of the C++ standard library, targeting C

Added to portage

2026-02-01

libcxxabi - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/libcxxabi-23.0.0_pre20260131

Description

Low level support for a standard C++ library

Added to portage

2026-02-01

libgcc - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/libgcc-23.0.0_pre20260131

Description

Compiler runtime library for clang, compatible with libgcc_

Added to portage

2026-02-01

libunwind - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/libunwind-23.0.0_pre20260131

Description

C++ runtime stack unwinder from LLVM

Added to portage

2026-02-01

liferea - 1.16.7
Ebuild name:

net-news/liferea-1.16.7

Description

News Aggregator for RDF/RSS/CDF/Atom/Echo feeds

Added to portage

2026-02-01

lit - 23.0.0_pre20260131
Ebuild name:

dev-python/lit-23.0.0_pre20260131

Description

A stand-alone install of the LLVM suite testing tool

Added to portage

2026-02-01

lld - 23.0.0_pre20260131
Ebuild name:

llvm-core/lld-23.0.0_pre20260131

Description

The LLVM linker (link editor)

Added to portage

2026-02-01

lldb - 23.0.0_pre20260131
Ebuild name:

llvm-core/lldb-23.0.0_pre20260131

Description

The LLVM debugger

Added to portage

2026-02-01

llvm - 23.0.0_pre20260131
Ebuild name:

dev-ml/llvm-23.0.0_pre20260131

Description

OCaml bindings for LLVM

Added to portage

2026-02-01

llvm - 23.0.0_pre20260131
Ebuild name:

llvm-core/llvm-23.0.0_pre20260131

Description

Low Level Virtual Machine

Added to portage

2026-02-01

llvm-common - 23.0.0_pre20260131
Ebuild name:

llvm-core/llvm-common-23.0.0_pre20260131

Description

Common files shared between multiple slots of LLVM

Added to portage

2026-02-01

mitmproxy-linux - 0.12.9
Ebuild name:

net-proxy/mitmproxy-linux-0.12.9

Description

mitmproxy's Rust bits

Added to portage

2026-02-01

mitmproxy-rs - 0.12.9
Ebuild name:

net-proxy/mitmproxy-rs-0.12.9

Description

mitmproxy's Rust bits

Added to portage

2026-02-01

mlir - 23.0.0_pre20260131
Ebuild name:

llvm-core/mlir-23.0.0_pre20260131

Description

Multi-Level Intermediate Representation (library only)

Added to portage

2026-02-01

numpy - 2.4.2
Ebuild name:

dev-python/numpy-2.4.2

Description

Fast array and numerical python library

Added to portage

2026-02-01

offload - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/offload-23.0.0_pre20260131

Description

OpenMP offloading support

Added to portage

2026-02-01

openmp - 23.0.0_pre20260131
Ebuild name:

llvm-runtimes/openmp-23.0.0_pre20260131

Description

OpenMP runtime library for LLVM/clang compiler

Added to portage

2026-02-01

pip - 26.0
Ebuild name:

dev-python/pip-26.0

Description

The PyPA recommended tool for installing Python packages

Added to portage

2026-02-01

polly - 23.0.0_pre20260131
Ebuild name:

llvm-core/polly-23.0.0_pre20260131

Description

Polyhedral optimizations for LLVM

Added to portage

2026-02-01

pyproject-fmt - 2.12.1
Ebuild name:

dev-python/pyproject-fmt-2.12.1

Description

Format your pyproject.toml file

Added to portage

2026-02-01

rich-click - 1.9.7
Ebuild name:

dev-python/rich-click-1.9.7

Description

Format click help output nicely with rich

Added to portage

2026-02-01

scitokens-cpp - 1.3.0
Ebuild name:

dev-cpp/scitokens-cpp-1.3.0

Description

C++ implementation of the SciTokens library with a C library interface

Added to portage

2026-02-01

stone-soup - 0.34_beta1
Ebuild name:

games-roguelike/stone-soup-0.34_beta1

Description

Role-playing roguelike game of exploration and treasure-hunti

Added to portage

2026-02-01

upmpdcli - 1.9.12
Ebuild name:

media-sound/upmpdcli-1.9.12

Description

UPnP Media Renderer front-end for MPD, the Music Player Daemon

Added to portage

2026-02-01

vivaldi-snapshot - 7.9.3936.3
Ebuild name:

www-client/vivaldi-snapshot-7.9.3936.3

Description

A browser for our friends

Added to portage

2026-02-01

wcwidth - 0.5.3
Ebuild name:

dev-python/wcwidth-0.5.3

Description

Measures number of Terminal column cells of wide-character codes

Added to portage

2026-02-01

wrapt - 2.1.0
Ebuild name:

dev-python/wrapt-2.1.0

Description

Module for decorators, wrappers and monkey patching

Added to portage

2026-02-01

yt-dlp - 2026.01.31
Ebuild name:

net-misc/yt-dlp-2026.01.31

Description

youtube-dl fork with additional features and fixes

Added to portage

2026-02-01

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