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:

87171

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-07-25
courier-common - 3.1.5-r2
Ebuild name:

net-mail/courier-common-3.1.5-r2

Description

Mail delivery agent/filter

Added to portage

2026-07-25

courier-common - 3.3.0
Ebuild name:

net-mail/courier-common-3.3.0

Description

Mail delivery agent/filter

Added to portage

2026-07-25

2026-07-24
android-studio - 2026.1.2.11
Ebuild name:

dev-util/android-studio-2026.1.2.11

Description

Android development environment based on IntelliJ IDEA

Added to portage

2026-07-24

annotated-types - 0.8.0
Ebuild name:

dev-python/annotated-types-0.8.0

Description

Reusable constraint types to use with typing.Annotated

Added to portage

2026-07-24

aws-crt-cpp - 0.37.4-r2
Ebuild name:

dev-cpp/aws-crt-cpp-0.37.4-r2

Description

C++ wrapper around the aws-c-* libraries

Added to portage

2026-07-24

awscli - 1.45.55
Ebuild name:

app-admin/awscli-1.45.55

Description

Universal Command Line Environment for AWS

Added to portage

2026-07-24

boto3 - 1.43.55
Ebuild name:

dev-python/boto3-1.43.55

Description

The AWS SDK for Python

Added to portage

2026-07-24

botocore - 1.43.55
Ebuild name:

dev-python/botocore-1.43.55

Description

Low-level, data-driven core of boto 3

Added to portage

2026-07-24

cachetools - 7.1.6
Ebuild name:

dev-python/cachetools-7.1.6

Description

Extensible memoizing collections and decorators

Added to portage

2026-07-24

cfn-lint - 1.53.2
Ebuild name:

dev-python/cfn-lint-1.53.2

Description

CloudFormation Linter

Added to portage

2026-07-24

dump1090 - 11.1
Ebuild name:

net-wireless/dump1090-11.1

Description

Simple Mode S decoder for RTLSDR devices

Added to portage

2026-07-24

geekbench - 7.0.0
Ebuild name:

app-benchmarks/geekbench-7.0.0

Description

A Cross-Platform Benchmark for Android, iOS, Linux, MacOS and Window

Added to portage

2026-07-24

gentoo-sources - 6.1.178
Ebuild name:

sys-kernel/gentoo-sources-6.1.178

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-07-24

gentoo-sources - 6.12.97
Ebuild name:

sys-kernel/gentoo-sources-6.12.97

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-07-24

gentoo-sources - 6.18.40
Ebuild name:

sys-kernel/gentoo-sources-6.18.40

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-07-24

gentoo-sources - 6.6.145
Ebuild name:

sys-kernel/gentoo-sources-6.6.145

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-07-24

gentoo-sources - 7.1.5
Ebuild name:

sys-kernel/gentoo-sources-7.1.5

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-07-24

gnumach - 1.8_p20260630
Ebuild name:

sys-kernel/gnumach-1.8_p20260630

Description

GNU Mach microkernel, for the Hurd

Added to portage

2026-07-24

grpcio - 1.83.0
Ebuild name:

dev-python/grpcio-1.83.0

Description

HTTP/2-based RPC framework

Added to portage

2026-07-24

grpcio-status - 1.83.0
Ebuild name:

dev-python/grpcio-status-1.83.0

Description

Reference package for GRPC Python status proto mapping

Added to portage

2026-07-24

h2 - 4.4.0
Ebuild name:

dev-python/h2-4.4.0

Description

HTTP/2 State-Machine based protocol implementation

Added to portage

2026-07-24

httpx2 - 2.9.0
Ebuild name:

dev-python/httpx2-2.9.0

Description

The next generation HTTP client (Pydantic fork)

Added to portage

2026-07-24

hurd - 0.9_p20260630
Ebuild name:

sys-kernel/hurd-0.9_p20260630

Description

GNU Hurd is the GNU project's replacement for UNIX

Added to portage

2026-07-24

hypothesis - 6.161.1
Ebuild name:

dev-python/hypothesis-6.161.1

Description

A library for property based testing

Added to portage

2026-07-24

intellij-idea - 2026.2.0.1
Ebuild name:

dev-util/intellij-idea-2026.2.0.1

Description

A complete toolset for web, mobile and enterprise development

Added to portage

2026-07-24

kirigami-app-components - 1.0.1-r1
Ebuild name:

dev-libs/kirigami-app-components-1.0.1-r1

Description

Kirigami addons and modules necessary to do a full featur

Added to portage

2026-07-24

lego - 5.3.1
Ebuild name:

app-crypt/lego-5.3.1

Description

Let's Encrypt/ACME client (like certbot or acme.sh) and library written in Go

Added to portage

2026-07-24

libacpica - 0_pre20220331_p7
Ebuild name:

sys-power/libacpica-0_pre20220331_p7

Description

ACPICA as a library

Added to portage

2026-07-24

metamath-mode - 0_p20221005
Ebuild name:

app-emacs/metamath-mode-0_p20221005

Description

Major GNU Emacs mode for metamath files

Added to portage

2026-07-24

mew - 6.8_p20230203
Ebuild name:

app-emacs/mew-6.8_p20230203

Description

Great MIME mail reader for Emacs/XEmacs

Added to portage

2026-07-24

mic-paren - 3.15-r1
Ebuild name:

app-emacs/mic-paren-3.15-r1

Description

Advanced highlighting of matching parentheses

Added to portage

2026-07-24

mldonkey - 0.0.4b-r2
Ebuild name:

app-emacs/mldonkey-0.0.4b-r2

Description

An Emacs Lisp interface to the MLDonkey core

Added to portage

2026-07-24

patatt - 0.8.0
Ebuild name:

dev-python/patatt-0.8.0

Description

A simple library to add cryptographic attestation to patches sent via email

Added to portage

2026-07-24

pkgcheck - 0.10.41
Ebuild name:

dev-util/pkgcheck-0.10.41

Description

pkgcore-based QA utility for ebuild repos

Added to portage

2026-07-24

pkgcore - 0.12.36
Ebuild name:

sys-apps/pkgcore-0.12.36

Description

a framework for package management

Added to portage

2026-07-24

quart - 0.21.0
Ebuild name:

dev-python/quart-0.21.0

Description

A Python ASGI web microframework with the same API as Flask

Added to portage

2026-07-24

rnv - 1.7.11-r5
Ebuild name:

app-text/rnv-1.7.11-r5

Description

A lightweight Relax NG Compact Syntax validator

Added to portage

2026-07-24

rust - 1.97.1
Ebuild name:

dev-lang/rust-1.97.1

Description

Systems programming language originally developed by Mozilla

Added to portage

2026-07-24

rust-bin - 1.97.1
Ebuild name:

dev-lang/rust-bin-1.97.1

Description

Added to portage

2026-07-24

rust-common - 1.97.1
Ebuild name:

dev-lang/rust-common-1.97.1

Description

Common files shared between multiple slots of Rust

Added to portage

2026-07-24

rust-std - 1.97.1
Ebuild name:

sys-devel/rust-std-1.97.1

Description

Rust standard library, standalone (for crossdev)

Added to portage

2026-07-24

snakeoil - 0.11.2
Ebuild name:

dev-python/snakeoil-0.11.2

Description

misc common functionality and useful optimizations

Added to portage

2026-07-24

stalwart-cli - 1.0.11
Ebuild name:

net-mail/stalwart-cli-1.0.11

Description

Stalwart Mail Server command line utility

Added to portage

2026-07-24

stalwart-mail - 0.16.14
Ebuild name:

net-mail/stalwart-mail-0.16.14

Description

Stalwart Mail Server

Added to portage

2026-07-24

telegram-desktop-bin - 7.0.5
Ebuild name:

net-im/telegram-desktop-bin-7.0.5

Description

Official desktop client for Telegram (binary package)

Added to portage

2026-07-24

urwid - 4.0.6
Ebuild name:

dev-python/urwid-4.0.6

Description

Curses-based user interface library for Python

Added to portage

2026-07-24

uv - 0.11.32
Ebuild name:

dev-python/uv-0.11.32

Description

A Python package installer and resolver, written in Rust

Added to portage

2026-07-24

uv-build - 0.11.32
Ebuild name:

dev-python/uv-build-0.11.32

Description

PEP517 uv build backend

Added to portage

2026-07-24

vanilla-sources - 6.1.178
Ebuild name:

sys-kernel/vanilla-sources-6.1.178

Description

Full sources for the Linux kernel

Added to portage

2026-07-24

vanilla-sources - 6.12.97
Ebuild name:

sys-kernel/vanilla-sources-6.12.97

Description

Full sources for the Linux kernel

Added to portage

2026-07-24

vanilla-sources - 6.18.40
Ebuild name:

sys-kernel/vanilla-sources-6.18.40

Description

Full sources for the Linux kernel

Added to portage

2026-07-24

vanilla-sources - 6.6.145
Ebuild name:

sys-kernel/vanilla-sources-6.6.145

Description

Full sources for the Linux kernel

Added to portage

2026-07-24

vanilla-sources - 7.1.5
Ebuild name:

sys-kernel/vanilla-sources-7.1.5

Description

Full sources for the Linux kernel

Added to portage

2026-07-24

webrtc-audio-processing - 1.3-r5
Ebuild name:

media-libs/webrtc-audio-processing-1.3-r5

Description

AudioProcessing library from the webrtc.org codebase

Added to portage

2026-07-24

xvfbwrapper - 0.2.29
Ebuild name:

dev-python/xvfbwrapper-0.2.29

Description

Python wrapper for running a display inside X virtual framebuffer

Added to portage

2026-07-24

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