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:

82887

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-21
biboumi - 10.0_pre20260110
Ebuild name:

net-im/biboumi-10.0_pre20260110

Description

XMPP gateway to IRC

Added to portage

2026-01-21

caffe2 - 2.9.1-r3
Ebuild name:

sci-ml/caffe2-2.9.1-r3

Description

A deep learning framework

Added to portage

2026-01-21

less - 691
Ebuild name:

sys-apps/less-691

Description

Excellent text file viewer

Added to portage

2026-01-21

openpgp-keys-inetutils - 20260120
Ebuild name:

sec-keys/openpgp-keys-inetutils-20260120

Description

OpenPGP keys used for net-misc/inetutils

Added to portage

2026-01-21

openpgp-keys-martinlambers - 20260120
Ebuild name:

sec-keys/openpgp-keys-martinlambers-20260120

Description

OpenPGP key used by Martin Lambers

Added to portage

2026-01-21

pytokens - 0.4.0-r1
Ebuild name:

dev-python/pytokens-0.4.0-r1

Description

A fast, spec compliant Python 3.13+ tokenizer that runs on older Pytho

Added to portage

2026-01-21

sslscan - 2.2.1
Ebuild name:

net-analyzer/sslscan-2.2.1

Description

Fast SSL configuration scanner

Added to portage

2026-01-21

tomcat-native - 1.3.5
Ebuild name:

dev-java/tomcat-native-1.3.5

Description

Allows Tomcat to use certain native resources for better performance

Added to portage

2026-01-21

2026-01-20
amq-protocol - 2.5.1
Ebuild name:

dev-ruby/amq-protocol-2.5.1

Description

An AMQP 0.9.1 serialization library for Ruby

Added to portage

2026-01-20

aws-sdk-cpp - 1.11.686-r1
Ebuild name:

dev-cpp/aws-sdk-cpp-1.11.686-r1

Description

AWS SDK for C++

Added to portage

2026-01-20

azure-core - 1.16.2
Ebuild name:

dev-cpp/azure-core-1.16.2

Description

Azure SDK for C++

Added to portage

2026-01-20

azure-identity - 1.13.3
Ebuild name:

dev-cpp/azure-identity-1.13.3

Description

Azure SDK for C++

Added to portage

2026-01-20

blessed - 1.27.0
Ebuild name:

dev-python/blessed-1.27.0

Description

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

Added to portage

2026-01-20

busybox - 1.37.0
Ebuild name:

sys-apps/busybox-1.37.0

Description

Utilities for rescue and embedded systems

Added to portage

2026-01-20

candy - 6.1.6
Ebuild name:

net-vpn/candy-6.1.6

Description

A reliable, low-latency, and anti-censorship virtual private network

Added to portage

2026-01-20

claude-code - 2.1.12
Ebuild name:

dev-util/claude-code-2.1.12

Description

Claude Code - an agentic coding tool by Anthropic

Added to portage

2026-01-20

dist-kernel - 5.10.248
Ebuild name:

virtual/dist-kernel-5.10.248

Description

Virtual to depend on any Distribution Kernel

Added to portage

2026-01-20

dist-kernel - 5.15.198
Ebuild name:

virtual/dist-kernel-5.15.198

Description

Virtual to depend on any Distribution Kernel

Added to portage

2026-01-20

dist-kernel - 6.1.161
Ebuild name:

virtual/dist-kernel-6.1.161

Description

Virtual to depend on any Distribution Kernel

Added to portage

2026-01-20

django-polymorphic - 4.10.4
Ebuild name:

dev-python/django-polymorphic-4.10.4

Description

Seamless Polymorphic Inheritance for Django Models

Added to portage

2026-01-20

fido2 - 2.1.1
Ebuild name:

dev-python/fido2-2.1.1

Description

Python based FIDO 2.0 library

Added to portage

2026-01-20

freerdp - 3.21.0
Ebuild name:

net-misc/freerdp-3.21.0

Description

Free implementation of the Remote Desktop Protocol

Added to portage

2026-01-20

gentoo-kernel - 5.10.248
Ebuild name:

sys-kernel/gentoo-kernel-5.10.248

Description

Linux kernel built with Gentoo patches

Added to portage

2026-01-20

gentoo-kernel - 5.15.198
Ebuild name:

sys-kernel/gentoo-kernel-5.15.198

Description

Linux kernel built with Gentoo patches

Added to portage

2026-01-20

gentoo-kernel - 6.1.161
Ebuild name:

sys-kernel/gentoo-kernel-6.1.161

Description

Linux kernel built with Gentoo patches

Added to portage

2026-01-20

gentoo-kernel-bin - 5.10.248
Ebuild name:

sys-kernel/gentoo-kernel-bin-5.10.248

Description

Pre-built Linux kernel with Gentoo patches

Added to portage

2026-01-20

gentoo-kernel-bin - 5.15.198
Ebuild name:

sys-kernel/gentoo-kernel-bin-5.15.198

Description

Pre-built Linux kernel with Gentoo patches

Added to portage

2026-01-20

gentoo-kernel-bin - 6.1.161
Ebuild name:

sys-kernel/gentoo-kernel-bin-6.1.161

Description

Pre-built Linux kernel with Gentoo patches

Added to portage

2026-01-20

gentoo-sources - 5.15.198
Ebuild name:

sys-kernel/gentoo-sources-5.15.198

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-01-20

gentoo-sources - 6.1.161
Ebuild name:

sys-kernel/gentoo-sources-6.1.161

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-01-20

gentoo-sources - 6.12.66
Ebuild name:

sys-kernel/gentoo-sources-6.12.66

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-01-20

gentoo-sources - 6.18.6
Ebuild name:

sys-kernel/gentoo-sources-6.18.6

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-01-20

gentoo-sources - 6.6.121
Ebuild name:

sys-kernel/gentoo-sources-6.6.121

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-01-20

git - 4.3.0
Ebuild name:

dev-ruby/git-4.3.0

Description

Library for using Git in Ruby

Added to portage

2026-01-20

glm - 1.0.2
Ebuild name:

media-libs/glm-1.0.2

Description

OpenGL Mathematics

Added to portage

2026-01-20

gnucash - 5.14
Ebuild name:

app-office/gnucash-5.14

Description

Personal finance manager

Added to portage

2026-01-20

gopls - 0.21.0
Ebuild name:

dev-go/gopls-0.21.0

Description

Added to portage

2026-01-20

inetutils - 2.7
Ebuild name:

net-misc/inetutils-2.7

Description

Collection of common network programs

Added to portage

2026-01-20

isort - 7.0.0-r1
Ebuild name:

dev-python/isort-7.0.0-r1

Description

A python utility/library to sort imports

Added to portage

2026-01-20

jellyfin-bin - 10.11.6
Ebuild name:

www-apps/jellyfin-bin-10.11.6

Description

Jellyfin puts you in control of managing and streaming your media

Added to portage

2026-01-20

keystoneauth1 - 5.13.0
Ebuild name:

dev-python/keystoneauth1-5.13.0

Description

This package contains tools for authenticating to an OpenStack-base

Added to portage

2026-01-20

kramdown - 2.5.2
Ebuild name:

dev-ruby/kramdown-2.5.2

Description

Yet-another-markdown-parser but fast, pure Ruby, using strict syntax defini

Added to portage

2026-01-20

libfilezilla - 0.54.0
Ebuild name:

dev-libs/libfilezilla-0.54.0

Description

C++ library offering some basic functionality for platform-independent

Added to portage

2026-01-20

mattermost-desktop-bin - 6.0.4
Ebuild name:

net-im/mattermost-desktop-bin-6.0.4

Description

Mattermost Desktop application

Added to portage

2026-01-20

mkdocstrings - 1.0.1
Ebuild name:

dev-python/mkdocstrings-1.0.1

Description

Automatic documentation from sources, for MkDocs

Added to portage

2026-01-20

multiprocess - 0.70.19
Ebuild name:

dev-python/multiprocess-0.70.19

Description

Better multiprocessing and multithreading in Python

Added to portage

2026-01-20

nagios-plugins - 2.4.12-r4
Ebuild name:

net-analyzer/nagios-plugins-2.4.12-r4

Description

Official plugins for Nagios

Added to portage

2026-01-20

nushell - 0.110.0
Ebuild name:

app-shells/nushell-0.110.0

Description

A new type of shell, written in Rust

Added to portage

2026-01-20

openhab-bin - 5.1.1
Ebuild name:

app-misc/openhab-bin-5.1.1

Description

An open-source automation software for your home

Added to portage

2026-01-20

openpgp-keys-martinmares - 20260120
Ebuild name:

sec-keys/openpgp-keys-martinmares-20260120

Description

OpenPGP key used by Martin Mareš

Added to portage

2026-01-20

openpgp-keys-pevik - 20260120
Ebuild name:

sec-keys/openpgp-keys-pevik-20260120

Description

OpenPGP key used by Petr Vorel (pevik)

Added to portage

2026-01-20

openstacksdk - 4.9.0
Ebuild name:

dev-python/openstacksdk-4.9.0

Description

A collection of libraries for building applications to work with Open

Added to portage

2026-01-20

pidgin-led-notification - 0.1-r3
Ebuild name:

x11-plugins/pidgin-led-notification-0.1-r3

Description

Pidgin plugin to notify by writing user defined strings

Added to portage

2026-01-20

pixi - 0.63.2
Ebuild name:

dev-util/pixi-0.63.2

Description

A package management and workflow tool

Added to portage

2026-01-20

pylast - 7.0.2
Ebuild name:

dev-python/pylast-7.0.2

Description

Python interface to last.fm and other api-compatible websites

Added to portage

2026-01-20

pylint - 4.0.4-r1
Ebuild name:

dev-python/pylint-4.0.4-r1

Description

Python code static checker

Added to portage

2026-01-20

qpdf - 12.3.1
Ebuild name:

app-text/qpdf-12.3.1

Description

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

Added to portage

2026-01-20

scdrand - 0.3.5
Ebuild name:

app-crypt/scdrand-0.3.5

Description

Feed kernel entropy pool from smartcard's TRNG

Added to portage

2026-01-20

selenium-webdriver - 4.40.0
Ebuild name:

dev-ruby/selenium-webdriver-4.40.0

Description

This gem provides Ruby bindings for WebDriver

Added to portage

2026-01-20

shadow - 4.19.2
Ebuild name:

sys-apps/shadow-4.19.2

Description

Utilities to deal with user accounts

Added to portage

2026-01-20

stalwart-cli - 0.15.4
Ebuild name:

net-mail/stalwart-cli-0.15.4

Description

Stalwart Mail Server command line utility

Added to portage

2026-01-20

stalwart-mail - 0.15.4
Ebuild name:

net-mail/stalwart-mail-0.15.4

Description

Stalwart Mail Server

Added to portage

2026-01-20

stestr - 4.2.0-r1
Ebuild name:

dev-python/stestr-4.2.0-r1

Description

A parallel Python test runner built around subunit

Added to portage

2026-01-20

vanilla-kernel - 5.10.248
Ebuild name:

sys-kernel/vanilla-kernel-5.10.248

Description

Linux kernel built from vanilla upstream sources

Added to portage

2026-01-20

vanilla-kernel - 5.15.198
Ebuild name:

sys-kernel/vanilla-kernel-5.15.198

Description

Linux kernel built from vanilla upstream sources

Added to portage

2026-01-20

vanilla-kernel - 6.1.161
Ebuild name:

sys-kernel/vanilla-kernel-6.1.161

Description

Linux kernel built from vanilla upstream sources

Added to portage

2026-01-20

vanilla-sources - 5.10.248
Ebuild name:

sys-kernel/vanilla-sources-5.10.248

Description

Full sources for the Linux kernel

Added to portage

2026-01-20

vanilla-sources - 5.15.198
Ebuild name:

sys-kernel/vanilla-sources-5.15.198

Description

Full sources for the Linux kernel

Added to portage

2026-01-20

vanilla-sources - 6.1.161
Ebuild name:

sys-kernel/vanilla-sources-6.1.161

Description

Full sources for the Linux kernel

Added to portage

2026-01-20

vanilla-sources - 6.12.66
Ebuild name:

sys-kernel/vanilla-sources-6.12.66

Description

Full sources for the Linux kernel

Added to portage

2026-01-20

vanilla-sources - 6.18.6
Ebuild name:

sys-kernel/vanilla-sources-6.18.6

Description

Full sources for the Linux kernel

Added to portage

2026-01-20

vanilla-sources - 6.6.121
Ebuild name:

sys-kernel/vanilla-sources-6.6.121

Description

Full sources for the Linux kernel

Added to portage

2026-01-20

weasyprint - 68.0
Ebuild name:

dev-python/weasyprint-68.0

Description

Visual rendering engine for HTML and CSS that can export to PDF

Added to portage

2026-01-20

wesnoth - 1.18.6
Ebuild name:

games-strategy/wesnoth-1.18.6

Description

Battle for Wesnoth - A fantasy turn-based strategy game

Added to portage

2026-01-20

wesnoth - 1.19.19
Ebuild name:

games-strategy/wesnoth-1.19.19

Description

Battle for Wesnoth - A fantasy turn-based strategy game

Added to portage

2026-01-20

winbox - 4.0_beta47
Ebuild name:

app-admin/winbox-4.0_beta47

Description

Management Software for MikroTik RouterOS

Added to portage

2026-01-20

zellij - 0.43.1-r1
Ebuild name:

app-misc/zellij-0.43.1-r1

Description

A terminal workspace with batteries included

Added to portage

2026-01-20

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