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:

86324

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-06-27
7zip - 26.02
Ebuild name:

app-arch/7zip-26.02

Description

Free file archiver for extremely high compression

Added to portage

2026-06-27

buildah - 1.44.0-r1
Ebuild name:

app-containers/buildah-1.44.0-r1

Description

A tool that facilitates building OCI images

Added to portage

2026-06-27

closure-compiler-bin - 20260622
Ebuild name:

dev-lang/closure-compiler-bin-20260622

Description

JavaScript optimizing compiler

Added to portage

2026-06-27

container-libs - 0.68.0
Ebuild name:

app-containers/container-libs-0.68.0

Description

Several utilities from the containers project

Added to portage

2026-06-27

docker-buildx - 0.35.0
Ebuild name:

app-containers/docker-buildx-0.35.0

Description

Docker CLI plugin for extended build capabilities with BuildKit

Added to portage

2026-06-27

editline - 2.0.0
Ebuild name:

dev-libs/editline-2.0.0

Description

line editing library for UNIX call compatible with the FSF readline

Added to portage

2026-06-27

edk2 - 202605
Ebuild name:

sys-firmware/edk2-202605

Description

TianoCore EDK II UEFI firmware for virtual machines

Added to portage

2026-06-27

edk2-bin - 202605
Ebuild name:

sys-firmware/edk2-bin-202605

Description

TianoCore EDK II UEFI firmware for virtual machines

Added to portage

2026-06-27

eisl - 5.67
Ebuild name:

dev-lang/eisl-5.67

Description

Interpreter and compiler compatible with the ISLisp standard

Added to portage

2026-06-27

firefox - 152.0.3
Ebuild name:

www-client/firefox-152.0.3

Description

Firefox Web Browser

Added to portage

2026-06-27

firefox-bin - 152.0.3
Ebuild name:

www-client/firefox-bin-152.0.3

Description

Firefox Web Browser

Added to portage

2026-06-27

firefox-l10n - 152.0.3
Ebuild name:

www-client/firefox-l10n-152.0.3

Description

Firefox Web Browser's translation files

Added to portage

2026-06-27

fuzzylite - 6.0
Ebuild name:

dev-libs/fuzzylite-6.0

Description

A fuzzy logic control library in C++

Added to portage

2026-06-27

libsquish - 1.15.1.4
Ebuild name:

media-libs/libsquish-1.15.1.4

Description

Library for compressing images with the DXT/S3TC standard

Added to portage

2026-06-27

mlt - 7.40.0
Ebuild name:

media-libs/mlt-7.40.0

Description

Open source multimedia framework for television broadcasting

Added to portage

2026-06-27

modus-themes - 5.3.0
Ebuild name:

app-emacs/modus-themes-5.3.0

Description

Highly accessible themes for GNU Emacs

Added to portage

2026-06-27

nerdctl - 2.3.3
Ebuild name:

app-containers/nerdctl-2.3.3

Description

Docker-compatible CLI for containerd, with support for Compose

Added to portage

2026-06-27

netavark - 2.0.0
Ebuild name:

app-containers/netavark-2.0.0

Description

A container network stack

Added to portage

2026-06-27

podman - 6.0.0
Ebuild name:

app-containers/podman-6.0.0

Description

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

Added to portage

2026-06-27

podman-tui - 1.11.2
Ebuild name:

app-containers/podman-tui-1.11.2

Description

Terminal UI frontend for Podman

Added to portage

2026-06-27

racket-mode - 1_p20260303
Ebuild name:

app-emacs/racket-mode-1_p20260303

Description

Emacs modes for Racket edit, REPL, check-syntax, debug, profile,

Added to portage

2026-06-27

rclone - 1.74.3
Ebuild name:

net-misc/rclone-1.74.3

Description

A program to sync files to and from various cloud storage providers

Added to portage

2026-06-27

reason - 3.18.0
Ebuild name:

dev-ml/reason-3.18.0

Description

Simple, fast & type safe language that leverages JavaScript and OCaml

Added to portage

2026-06-27

rsyslog - 8.2606.0
Ebuild name:

app-admin/rsyslog-8.2606.0

Description

An enhanced multi-threaded syslogd with database support and more

Added to portage

2026-06-27

skopeo - 1.23.0-r1
Ebuild name:

app-containers/skopeo-1.23.0-r1

Description

Work with remote container images registries

Added to portage

2026-06-27

sonarr-bin - 4.0.19.2979
Ebuild name:

www-apps/sonarr-bin-4.0.19.2979

Description

Sonarr is a Smart PVR for newsgroup and bittorrent users

Added to portage

2026-06-27

tree-sitter-racket - 0.24.7_p1
Ebuild name:

dev-libs/tree-sitter-racket-0.24.7_p1

Description

Racket programming language grammar for Tree-sitter

Added to portage

2026-06-27

tree-sitter-unison - 2.1.3
Ebuild name:

dev-libs/tree-sitter-unison-2.1.3

Description

Unison programming language grammar for Tree-sitter

Added to portage

2026-06-27

vcmi - 1.7.4
Ebuild name:

games-strategy/vcmi-1.7.4

Description

Open-source engine for Heroes of Might and Magic III

Added to portage

2026-06-27

2026-06-26
R - 4.6.1
Ebuild name:

dev-lang/R-4.6.1

Description

Language and environment for statistical computing and graphics

Added to portage

2026-06-26

alembic - 1.18.5
Ebuild name:

dev-python/alembic-1.18.5

Description

Database migrations tool, written by the author of SQLAlchemy

Added to portage

2026-06-26

blis - 2.1
Ebuild name:

sci-libs/blis-2.1

Description

BLAS-like Library Instantiation Software Framework

Added to portage

2026-06-26

cifs-utils - 7.6
Ebuild name:

net-fs/cifs-utils-7.6

Description

Tools for Managing Linux CIFS Client Filesystems

Added to portage

2026-06-26

delve - 1.27.0
Ebuild name:

dev-go/delve-1.27.0

Description

A source-level debugger for the Go programming language

Added to portage

2026-06-26

dxvk - 3.0
Ebuild name:

app-emulation/dxvk-3.0

Description

Vulkan-based implementation of D3D9, D3D10 and D3D11 for Linux / Wine

Added to portage

2026-06-26

glycin-loaders - 2.1.5
Ebuild name:

media-libs/glycin-loaders-2.1.5

Description

Loaders for glycin clients (glycin crate or libglycin)

Added to portage

2026-06-26

google-api-python-client - 2.198.0
Ebuild name:

dev-python/google-api-python-client-2.198.0

Description

Google API Client for Python

Added to portage

2026-06-26

google-auth - 2.55.1
Ebuild name:

dev-python/google-auth-2.55.1

Description

Google Authentication Library

Added to portage

2026-06-26

incus - 7.2
Ebuild name:

app-containers/incus-7.2

Description

Modern, secure and powerful system container and virtual machine manager

Added to portage

2026-06-26

ispc - 1.31.0
Ebuild name:

dev-lang/ispc-1.31.0

Description

Intel SPMD Program Compiler

Added to portage

2026-06-26

libtorrent - 0.16.15
Ebuild name:

net-libs/libtorrent-0.16.15

Description

BitTorrent library written in C++ for *nix

Added to portage

2026-06-26

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-06-26

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-06-26

mutagen - 1.48.1
Ebuild name:

media-libs/mutagen-1.48.1

Description

Audio metadata tag reader and writer implemented in pure Python

Added to portage

2026-06-26

newsboat - 2.44
Ebuild name:

net-news/newsboat-2.44

Description

An RSS/Atom feed reader for text terminals

Added to portage

2026-06-26

pdns - 5.0.6
Ebuild name:

net-dns/pdns-5.0.6

Description

The PowerDNS Daemon

Added to portage

2026-06-26

pdns - 5.1.2
Ebuild name:

net-dns/pdns-5.1.2

Description

The PowerDNS Daemon

Added to portage

2026-06-26

pdns-recursor - 5.3.8
Ebuild name:

net-dns/pdns-recursor-5.3.8

Description

The PowerDNS Recursor

Added to portage

2026-06-26

pdns-recursor - 5.4.3
Ebuild name:

net-dns/pdns-recursor-5.4.3

Description

The PowerDNS Recursor

Added to portage

2026-06-26

photoqt - 5.4
Ebuild name:

media-gfx/photoqt-5.4

Description

Simple but powerful Qt-based image viewer

Added to portage

2026-06-26

photoqt-extensions - 5.4
Ebuild name:

media-plugins/photoqt-extensions-5.4

Description

Official extensions for PhotoQt

Added to portage

2026-06-26

postfix - 3.12_pre20260624
Ebuild name:

mail-mta/postfix-3.12_pre20260624

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2026-06-26

pugixml - 1.16
Ebuild name:

dev-libs/pugixml-1.16

Description

Light-weight, simple, and fast XML parser for C++ with XPath support

Added to portage

2026-06-26

pygraphviz - 2.0
Ebuild name:

dev-python/pygraphviz-2.0

Description

Python wrapper for the Graphviz Agraph data structure

Added to portage

2026-06-26

pyproject-fmt - 2.25.1
Ebuild name:

dev-python/pyproject-fmt-2.25.1

Description

Format your pyproject.toml file

Added to portage

2026-06-26

rtorrent - 0.16.15
Ebuild name:

net-p2p/rtorrent-0.16.15

Description

BitTorrent Client using libtorrent

Added to portage

2026-06-26

rutorrent - 5.3.3
Ebuild name:

www-apps/rutorrent-5.3.3

Description

ruTorrent is a front-end for the popular Bittorrent client rTorrent

Added to portage

2026-06-26

samba - 4.23.9
Ebuild name:

net-fs/samba-4.23.9

Description

Samba Suite Version 4

Added to portage

2026-06-26

setuptools-scm - 10.2.0
Ebuild name:

dev-python/setuptools-scm-10.2.0

Description

Manage versions by scm tags via setuptools

Added to portage

2026-06-26

sphinx-autodoc-typehints - 3.12.0
Ebuild name:

dev-python/sphinx-autodoc-typehints-3.12.0

Description

Type hints support for the Sphinx autodoc extension

Added to portage

2026-06-26

sslscan - 2.2.2
Ebuild name:

net-analyzer/sslscan-2.2.2

Description

Fast SSL configuration scanner

Added to portage

2026-06-26

tox - 4.56.1
Ebuild name:

dev-python/tox-4.56.1

Description

virtualenv-based automation of test activities

Added to portage

2026-06-26

uhd - 4.10.0.0-r1
Ebuild name:

net-wireless/uhd-4.10.0.0-r1

Description

Universal Software Radio Peripheral (USRP) Hardware Driver

Added to portage

2026-06-26

urwid - 4.0.3
Ebuild name:

dev-python/urwid-4.0.3

Description

Curses-based user interface library for Python

Added to portage

2026-06-26

vcs-versioning - 2.2.0
Ebuild name:

dev-python/vcs-versioning-2.2.0

Description

Core VCS versioning functionality from setuptools-scm

Added to portage

2026-06-26

vlc - 4.0.0_pre20260625
Ebuild name:

media-video/vlc-4.0.0_pre20260625

Description

Media player and framework with support for most multimedia files

Added to portage

2026-06-26

wand - 0.7.2
Ebuild name:

dev-python/wand-0.7.2

Description

Ctypes-based simple ImageMagick binding for Python

Added to portage

2026-06-26

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