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:

87732

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.5 (69 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-08-17
DBI - 1.652.0
Ebuild name:

dev-perl/DBI-1.652.0

Description

Database independent interface for Perl

Added to portage

2026-08-17

arti - 2.5.1
Ebuild name:

net-p2p/arti-2.5.1

Description

Implementation of Tor in Rust

Added to portage

2026-08-17

chrony_exporter - 0.14.0
Ebuild name:

app-metrics/chrony_exporter-0.14.0

Description

Chrony NTP exporter for Prometheus

Added to portage

2026-08-17

codipack - 3.1.2
Ebuild name:

sys-cluster/codipack-3.1.2

Description

Fast gradient evaluation in C++ based on Expression Templates

Added to portage

2026-08-17

exfatprogs - 1.4.3
Ebuild name:

sys-fs/exfatprogs-1.4.3

Description

Userspace utilities for the exFAT filesystem

Added to portage

2026-08-17

gagit - 4
Ebuild name:

dev-vcs/gagit-4

Description

Gentoo AGit workflow tool

Added to portage

2026-08-17

htop - 3.5.3
Ebuild name:

sys-process/htop-3.5.3

Description

Interactive process viewer

Added to portage

2026-08-17

kguiaddons - 6.29.0-r1
Ebuild name:

kde-frameworks/kguiaddons-6.29.0-r1

Description

Framework providing assorted high-level user interface componen

Added to portage

2026-08-17

kirigami - 6.29.0-r1
Ebuild name:

kde-frameworks/kirigami-6.29.0-r1

Description

Lightweight user interface framework for mobile and convergent ap

Added to portage

2026-08-17

libquo - 1.4.1
Ebuild name:

sys-cluster/libquo-1.4.1

Description

Run-time tuning of process binding policies made easy

Added to portage

2026-08-17

nushell - 0.115.0
Ebuild name:

app-shells/nushell-0.115.0

Description

A new type of shell, written in Rust

Added to portage

2026-08-17

openpgp-keys-patrick96 - 20260816
Ebuild name:

sec-keys/openpgp-keys-patrick96-20260816

Description

OpenPGP keys used by Patrick Ziegler

Added to portage

2026-08-17

openpgp-keys-putty-release - 2026
Ebuild name:

sec-keys/openpgp-keys-putty-release-2026

Description

PuTTY Release Key

Added to portage

2026-08-17

polybar - 3.7.2-r1
Ebuild name:

x11-misc/polybar-3.7.2-r1

Description

A fast and easy-to-use tool for creating status bars

Added to portage

2026-08-17

putty - 0.85
Ebuild name:

net-misc/putty-0.85

Description

A Free Telnet/SSH Client

Added to portage

2026-08-17

tree-sitter - 0.26.12
Ebuild name:

dev-libs/tree-sitter-0.26.12

Description

Tree-sitter is a parser generator tool and an incremental parsing libr

Added to portage

2026-08-17

tree-sitter-cli - 0.26.12
Ebuild name:

dev-util/tree-sitter-cli-0.26.12

Description

Command-line tool for creating and testing tree-sitter grammars

Added to portage

2026-08-17

xaos - 4.3.7
Ebuild name:

x11-misc/xaos-4.3.7

Description

Very fast real-time fractal zoomer

Added to portage

2026-08-17

zsh - 5.9.2
Ebuild name:

app-shells/zsh-5.9.2

Description

UNIX Shell similar to the Korn shell

Added to portage

2026-08-17

zxing-cpp - 3.1.1
Ebuild name:

media-libs/zxing-cpp-3.1.1

Description

C++ Multi-format 1D/2D barcode image processing library

Added to portage

2026-08-17

2026-08-16
arj - 3.10.22_p29
Ebuild name:

app-arch/arj-3.10.22_p29

Description

Utility for opening arj archives

Added to portage

2026-08-16

backports-zstd - 1.7.0
Ebuild name:

dev-python/backports-zstd-1.7.0

Description

Backport of PEP-784 adding Zstandard to the standard library

Added to portage

2026-08-16

borgmatic - 2.1.7
Ebuild name:

app-backup/borgmatic-2.1.7

Description

Automatically create, prune and verify backups with borgbackup

Added to portage

2026-08-16

charset-normalizer - 3.5.1
Ebuild name:

dev-python/charset-normalizer-3.5.1

Description

The Real First Universal Charset Detector

Added to portage

2026-08-16

containerd - 2.3.4
Ebuild name:

app-containers/containerd-2.3.4

Description

A daemon to control runC

Added to portage

2026-08-16

crun - 1.29.1
Ebuild name:

app-containers/crun-1.29.1

Description

Fast and low-memory footprint OCI Container Runtime fully written in C

Added to portage

2026-08-16

duplicity - 3.2.0.1
Ebuild name:

app-backup/duplicity-3.2.0.1

Description

Secure backup system using GnuPG to encrypt data

Added to portage

2026-08-16

fastjsonschema - 2.22.2
Ebuild name:

dev-python/fastjsonschema-2.22.2

Description

Fast JSON schema validator for Python

Added to portage

2026-08-16

gcc - 13.4.1_p20260812
Ebuild name:

sys-devel/gcc-13.4.1_p20260812

Description

The GNU Compiler Collection

Added to portage

2026-08-16

gcc - 14.4.1_p20260813
Ebuild name:

sys-devel/gcc-14.4.1_p20260813

Description

The GNU Compiler Collection

Added to portage

2026-08-16

gcc - 15.3.1_p20260814
Ebuild name:

sys-devel/gcc-15.3.1_p20260814

Description

The GNU Compiler Collection

Added to portage

2026-08-16

gcc - 16.2.1_p20260815
Ebuild name:

sys-devel/gcc-16.2.1_p20260815

Description

The GNU Compiler Collection

Added to portage

2026-08-16

ggml - 0.19.0-r1
Ebuild name:

sci-ml/ggml-0.19.0-r1

Description

Tensor library for machine learning

Added to portage

2026-08-16

ggml - 0.20.0-r1
Ebuild name:

sci-ml/ggml-0.20.0-r1

Description

Tensor library for machine learning

Added to portage

2026-08-16

kitinerary - 26.04.3-r2
Ebuild name:

kde-apps/kitinerary-26.04.3-r2

Description

Data Model and Extraction System for Travel Reservation information

Added to portage

2026-08-16

libatasmart - 0.19_p6
Ebuild name:

dev-libs/libatasmart-0.19_p6

Description

Small and lightweight parser library for ATA S.M.A.R.T. hard disks

Added to portage

2026-08-16

macrostep-geiser - 0.2.0_p20210717
Ebuild name:

app-emacs/macrostep-geiser-0.2.0_p20210717

Description

Emacs macrostep back-end powered by geiser

Added to portage

2026-08-16

magit - 4.5.0-r1
Ebuild name:

app-emacs/magit-4.5.0-r1

Description

A Git porcelain inside Emacs

Added to portage

2026-08-16

magit - 4.6.0
Ebuild name:

app-emacs/magit-4.6.0

Description

A Git porcelain inside Emacs

Added to portage

2026-08-16

magit - 4.7.0
Ebuild name:

app-emacs/magit-4.7.0

Description

A Git porcelain inside Emacs

Added to portage

2026-08-16

magit - 9999
Ebuild name:

app-emacs/magit-9999

Description

A Git porcelain inside Emacs

Added to portage

2026-08-16

magit-popup - 2.13.3-r1
Ebuild name:

app-emacs/magit-popup-2.13.3-r1

Description

Define prefix-infix-suffix command combos

Added to portage

2026-08-16

mailcrypt - 3.5.9-r3
Ebuild name:

app-emacs/mailcrypt-3.5.9-r3

Description

Provides a simple interface to public key cryptography with OpenPGP

Added to portage

2026-08-16

man-pages-ja - 20260815
Ebuild name:

app-i18n/man-pages-ja-20260815

Description

Collection of manual pages translated into Japanese

Added to portage

2026-08-16

marginalia - 2.10
Ebuild name:

app-emacs/marginalia-2.10

Description

Marginalia in the minibuffer

Added to portage

2026-08-16

nanobind - 2.15.0
Ebuild name:

dev-python/nanobind-2.15.0

Description

Tiny and efficient C++/Python bindings

Added to portage

2026-08-16

nauty - 2.9.3
Ebuild name:

sci-mathematics/nauty-2.9.3

Description

Computing automorphism groups of graphs and digraphs

Added to portage

2026-08-16

obs-studio - 32.2.2
Ebuild name:

media-video/obs-studio-32.2.2

Description

Software for Recording and Streaming Live Video Content

Added to portage

2026-08-16

ollama - 0.32.9-r2
Ebuild name:

sci-ml/ollama-0.32.9-r2

Description

Get up and running with Llama 3, Mistral, Gemma, and other language models

Added to portage

2026-08-16

openbsd-netcat - 1.238_p1
Ebuild name:

net-analyzer/openbsd-netcat-1.238_p1

Description

The OpenBSD network swiss army knife

Added to portage

2026-08-16

openrgb - 1.0_rc3
Ebuild name:

app-misc/openrgb-1.0_rc3

Description

Open source RGB lighting control

Added to portage

2026-08-16

podman - 5.8.6
Ebuild name:

app-containers/podman-5.8.6

Description

A tool for managing OCI containers and pods with Docker-compatible CLI

Added to portage

2026-08-16

podman - 6.1.0
Ebuild name:

app-containers/podman-6.1.0

Description

A tool for managing OCI containers and pods with Docker-compatible CLI

Added to portage

2026-08-16

python-json-logger - 4.2.0
Ebuild name:

dev-python/python-json-logger-4.2.0

Description

Standard python logging to output log data as json objects

Added to portage

2026-08-16

pywayland - 0.4.19
Ebuild name:

dev-python/pywayland-0.4.19

Description

Python bindings for the libwayland library

Added to portage

2026-08-16

qemu - 10.2.3-r1
Ebuild name:

app-emulation/qemu-10.2.3-r1

Description

QEMU + Kernel-based Virtual Machine userland tools

Added to portage

2026-08-16

shtab - 1.11.0
Ebuild name:

dev-python/shtab-1.11.0

Description

Automagic shell tab completion for Python CLI applications

Added to portage

2026-08-16

sip - 6.16.1
Ebuild name:

dev-python/sip-6.16.1

Description

Python bindings generator for C/C++ libraries

Added to portage

2026-08-16

tifffile - 2026.8.16
Ebuild name:

dev-python/tifffile-2026.8.16

Description

Read and write TIFF files

Added to portage

2026-08-16

webencodings - 0.6.1
Ebuild name:

dev-python/webencodings-0.6.1

Description

Character encoding aliases for legacy web content

Added to portage

2026-08-16

wrapt - 2.4.0_rc4
Ebuild name:

dev-python/wrapt-2.4.0_rc4

Description

Module for decorators, wrappers and monkey patching

Added to portage

2026-08-16

zabbix - 6.0.48
Ebuild name:

net-analyzer/zabbix-6.0.48

Description

ZABBIX is software for monitoring of your applications, network and serv

Added to portage

2026-08-16

zabbix - 7.0.29
Ebuild name:

net-analyzer/zabbix-7.0.29

Description

ZABBIX is software for monitoring of your applications, network and serv

Added to portage

2026-08-16

zabbix - 7.4.13
Ebuild name:

net-analyzer/zabbix-7.4.13

Description

ZABBIX is software for monitoring of your applications, network and serv

Added to portage

2026-08-16

zip - 3.0_p16
Ebuild name:

app-arch/zip-3.0_p16

Description

Info ZIP (encryption support)

Added to portage

2026-08-16

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