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:

85324

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-05-24
2026-05-23
awscli - 1.45.14
Ebuild name:

app-admin/awscli-1.45.14

Description

Universal Command Line Environment for AWS

Added to portage

2026-05-23

blessed - 1.42.0
Ebuild name:

dev-python/blessed-1.42.0

Description

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

Added to portage

2026-05-23

boto3 - 1.43.14
Ebuild name:

dev-python/boto3-1.43.14

Description

The AWS SDK for Python

Added to portage

2026-05-23

botocore - 1.43.14
Ebuild name:

dev-python/botocore-1.43.14

Description

Low-level, data-driven core of boto 3

Added to portage

2026-05-23

c2ffi - 21.1.0.20260104
Ebuild name:

dev-lisp/c2ffi-21.1.0.20260104

Description

Clang-based FFI wrapper generator for Common Lisp

Added to portage

2026-05-23

click - 8.4.1
Ebuild name:

dev-python/click-8.4.1

Description

A Python package for creating beautiful command line interfaces

Added to portage

2026-05-23

crossdev - 20260501-r1
Ebuild name:

sys-devel/crossdev-20260501-r1

Description

Gentoo Cross-toolchain generator

Added to portage

2026-05-23

cucumber-expressions - 19.0.1
Ebuild name:

dev-python/cucumber-expressions-19.0.1

Description

Human friendly alternative to Regular Expressions

Added to portage

2026-05-23

deno-bin - 2.8.0
Ebuild name:

dev-lang/deno-bin-2.8.0

Description

Modern runtime for JavaScript and TypeScript

Added to portage

2026-05-23

faker - 40.19.1
Ebuild name:

dev-python/faker-40.19.1

Description

A Python package that generates fake data for you

Added to portage

2026-05-23

gentoo-sources - 7.0.9-r5
Ebuild name:

sys-kernel/gentoo-sources-7.0.9-r5

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-05-23

gnome-settings-daemon - 49.1-r1
Ebuild name:

gnome-base/gnome-settings-daemon-49.1-r1

Description

Gnome Settings Daemon

Added to portage

2026-05-23

gr-rds - 0.0_p20250404-r1
Ebuild name:

net-wireless/gr-rds-0.0_p20250404-r1

Description

GNU Radio FM RDS Receiver

Added to portage

2026-05-23

graph-tool - 2.98
Ebuild name:

dev-python/graph-tool-2.98

Description

An efficient python module for manipulation and statistical analysis of

Added to portage

2026-05-23

griddataformats - 1.2.0
Ebuild name:

dev-python/griddataformats-1.2.0

Description

Reading and writing of data on regular grids in Python

Added to portage

2026-05-23

icalendar - 7.1.2
Ebuild name:

dev-python/icalendar-7.1.2

Description

RFC 5545 compatible parser and generator of iCalendar files

Added to portage

2026-05-23

jellyfin-bin - 10.11.9
Ebuild name:

www-apps/jellyfin-bin-10.11.9

Description

Jellyfin puts you in control of managing and streaming your media

Added to portage

2026-05-23

jinxed - 2.0.1
Ebuild name:

dev-python/jinxed-2.0.1

Description

A pure-Python implementation of a subset of the Python curses library

Added to portage

2026-05-23

jwt-cpp - 0.7.2-r1
Ebuild name:

dev-cpp/jwt-cpp-0.7.2-r1

Description

header only library for creating and validating JSON Web Tokens in C++11

Added to portage

2026-05-23

libgit2 - 1.9.4
Ebuild name:

dev-libs/libgit2-1.9.4

Description

A linkable library for Git

Added to portage

2026-05-23

liblms7002m - 0.0_p20200518-r3
Ebuild name:

net-wireless/liblms7002m-0.0_p20200518-r3

Description

Compact LMS7002M library suitable for resource-limited MC

Added to portage

2026-05-23

lmod - 9.2.2
Ebuild name:

sys-cluster/lmod-9.2.2

Description

Environment Module System based on Lua

Added to portage

2026-05-23

more-itertools - 11.1.0
Ebuild name:

dev-python/more-itertools-11.1.0

Description

More routines for operating on iterables, beyond itertools

Added to portage

2026-05-23

multi-term - 1.4-r1
Ebuild name:

app-emacs/multi-term-1.4-r1

Description

Manage multiple terminal buffers in Emacs

Added to portage

2026-05-23

nginx - 1.30.2
Ebuild name:

www-servers/nginx-1.30.2

Description

Added to portage

2026-05-23

nvidia-drivers - 595.44.09
Ebuild name:

x11-drivers/nvidia-drivers-595.44.09

Description

NVIDIA Accelerated Graphics Driver

Added to portage

2026-05-23

pika - 1.4.1
Ebuild name:

dev-python/pika-1.4.1

Description

Pure-Python implementation of the AMQP

Added to portage

2026-05-23

portage - 3.0.79
Ebuild name:

sys-apps/portage-3.0.79

Description

The package management and distribution system for Gentoo

Added to portage

2026-05-23

pypdf - 6.12.1
Ebuild name:

dev-python/pypdf-6.12.1

Description

Python library to work with PDF files

Added to portage

2026-05-23

pytest-rerunfailures - 16.3
Ebuild name:

dev-python/pytest-rerunfailures-16.3

Description

pytest plugin to re-run tests to eliminate flaky failures

Added to portage

2026-05-23

qtdeclarative - 6.11.1-r1
Ebuild name:

dev-qt/qtdeclarative-6.11.1-r1

Description

Qt Declarative (Quick 2)

Added to portage

2026-05-23

qtile - 0.36.0
Ebuild name:

x11-wm/qtile-0.36.0

Description

A full-featured, hackable tiling window manager written in Python

Added to portage

2026-05-23

raspberrypi-firmware - 1.20260521
Ebuild name:

sys-boot/raspberrypi-firmware-1.20260521

Description

Raspberry Pi (all versions) bootloader and GPU firmware

Added to portage

2026-05-23

raspberrypi-image - 6.18.32_p20260521
Ebuild name:

sys-kernel/raspberrypi-image-6.18.32_p20260521

Description

Raspberry Pi (all versions) kernel and modules

Added to portage

2026-05-23

raspberrypi-sources - 6.18.32_p20260521
Ebuild name:

sys-kernel/raspberrypi-sources-6.18.32_p20260521

Description

Raspberry Pi kernel sources

Added to portage

2026-05-23

snapd-glib - 1.72
Ebuild name:

sys-libs/snapd-glib-1.72

Description

glib library for communicating with snapd

Added to portage

2026-05-23

sunshine - 2026.516.143833
Ebuild name:

net-misc/sunshine-2026.516.143833

Description

Self-hosted game stream host for Moonlight

Added to portage

2026-05-23

superlu_mt - 4.0.2
Ebuild name:

sci-libs/superlu_mt-4.0.2

Description

Multithreaded sparse LU factorization library

Added to portage

2026-05-23

trove-classifiers - 2026.5.22.10
Ebuild name:

dev-python/trove-classifiers-2026.5.22.10

Description

Canonical source for classifiers on PyPI (pypi.org)

Added to portage

2026-05-23

virt-firmware - 26.5.4
Ebuild name:

app-emulation/virt-firmware-26.5.4

Description

Tools for ovmf/armvirt firmware volumes

Added to portage

2026-05-23

vpl-gpu-rt - 26.2.0
Ebuild name:

media-libs/vpl-gpu-rt-26.2.0

Description

Intel Video Processing Library GPU Runtime

Added to portage

2026-05-23

wrapt - 2.2.1
Ebuild name:

dev-python/wrapt-2.2.1

Description

Module for decorators, wrappers and monkey patching

Added to portage

2026-05-23

yle-dl - 20260520
Ebuild name:

media-video/yle-dl-20260520

Description

Download media files from Yle Areena

Added to portage

2026-05-23

zotero-bin - 9.0.4
Ebuild name:

app-text/zotero-bin-9.0.4

Description

Helps you collect, organize, cite, and share your research sources

Added to portage

2026-05-23

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