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:

84054

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-03-28
dash - 2.18.2
Ebuild name:

sci-visualization/dash-2.18.2

Description

Python framework for building ML & data science web apps

Added to portage

2026-03-28

dash - 3.0.4
Ebuild name:

sci-visualization/dash-3.0.4

Description

Python framework for building ML & data science web apps

Added to portage

2026-03-28

dash - 3.1.1
Ebuild name:

sci-visualization/dash-3.1.1

Description

Python framework for building ML & data science web apps

Added to portage

2026-03-28

dash - 3.2.0
Ebuild name:

sci-visualization/dash-3.2.0

Description

Python framework for building ML & data science web apps

Added to portage

2026-03-28

dash - 3.3.0
Ebuild name:

sci-visualization/dash-3.3.0

Description

Python framework for building ML & data science web apps

Added to portage

2026-03-28

dash - 3.4.0
Ebuild name:

sci-visualization/dash-3.4.0

Description

Python framework for building ML & data science web apps

Added to portage

2026-03-28

picard - 3.0.0_alpha4-r2
Ebuild name:

media-sound/picard-3.0.0_alpha4-r2

Description

Cross-platform music tagger

Added to portage

2026-03-28

2026-03-27
awscli - 1.44.67
Ebuild name:

app-admin/awscli-1.44.67

Description

Universal Command Line Environment for AWS

Added to portage

2026-03-27

bind - 9.18.47
Ebuild name:

net-dns/bind-9.18.47

Description

Berkeley Internet Name Domain - Name Server

Added to portage

2026-03-27

bind - 9.20.21
Ebuild name:

net-dns/bind-9.20.21

Description

Berkeley Internet Name Domain - Name Server

Added to portage

2026-03-27

boto3 - 1.42.77
Ebuild name:

dev-python/boto3-1.42.77

Description

The AWS SDK for Python

Added to portage

2026-03-27

botocore - 1.42.77
Ebuild name:

dev-python/botocore-1.42.77

Description

Low-level, data-driven core of boto 3

Added to portage

2026-03-27

caffe2 - 2.11.0-r1
Ebuild name:

sci-ml/caffe2-2.11.0-r1

Description

A deep learning framework

Added to portage

2026-03-27

check-jsonschema - 0.37.1
Ebuild name:

app-misc/check-jsonschema-0.37.1

Description

A CLI and set of pre-commit hooks for jsonschema validation

Added to portage

2026-03-27

chrome-binary-plugins - 147.0.7727.24_beta
Ebuild name:

www-plugins/chrome-binary-plugins-147.0.7727.24_beta

Description

Binary plugins from Google Chrome for use in C

Added to portage

2026-03-27

chromium - 147.0.7727.24
Ebuild name:

www-client/chromium-147.0.7727.24

Description

Open-source version of Google Chrome web browser

Added to portage

2026-03-27

claude-code - 2.1.85
Ebuild name:

dev-util/claude-code-2.1.85

Description

Claude Code - an agentic coding tool by Anthropic

Added to portage

2026-03-27

cookiecutter - 2.7.1
Ebuild name:

dev-util/cookiecutter-2.7.1

Description

Command-line utility to create projects from cookiecutters (project tem

Added to portage

2026-03-27

deadbeef - 1.10.2
Ebuild name:

media-sound/deadbeef-1.10.2

Description

DeaDBeeF is a modular audio player similar to foobar2000

Added to portage

2026-03-27

dovecot - 2.4.3
Ebuild name:

net-mail/dovecot-2.4.3

Description

An IMAP and POP3 server written with security primarily in mind

Added to portage

2026-03-27

dracut - 110-r4
Ebuild name:

sys-kernel/dracut-110-r4

Description

Generic initramfs generation tool

Added to portage

2026-03-27

ecdsa - 0.19.2
Ebuild name:

dev-python/ecdsa-0.19.2

Description

ECDSA cryptographic signature library in pure Python

Added to portage

2026-03-27

ecl - 26.3.27
Ebuild name:

dev-lisp/ecl-26.3.27

Description

ECL is an embeddable Common Lisp implementation

Added to portage

2026-03-27

epson-inkjet-printer-escpr - 1.8.8
Ebuild name:

net-print/epson-inkjet-printer-escpr-1.8.8

Description

Epson Inkjet Printer Driver (ESC/P-R)

Added to portage

2026-03-27

fotocx - 26.2-r1
Ebuild name:

media-gfx/fotocx-26.2-r1

Description

Program for improving image files made with a digital camera

Added to portage

2026-03-27

fotocx - 26.3-r1
Ebuild name:

media-gfx/fotocx-26.3-r1

Description

Program for improving image files made with a digital camera

Added to portage

2026-03-27

gitui - 0.28.1
Ebuild name:

dev-vcs/gitui-0.28.1

Description

blazing fast terminal-ui for git

Added to portage

2026-03-27

google-chrome-beta - 147.0.7727.24
Ebuild name:

www-client/google-chrome-beta-147.0.7727.24

Description

The web browser from Google

Added to portage

2026-03-27

googleapis-common-protos - 1.73.1
Ebuild name:

dev-python/googleapis-common-protos-1.73.1

Description

Python classes generated from the common protos in the g

Added to portage

2026-03-27

gunicorn - 25.3.0
Ebuild name:

www-servers/gunicorn-25.3.0

Description

A WSGI HTTP Server for UNIX

Added to portage

2026-03-27

intellij-idea - 2026.1
Ebuild name:

dev-util/intellij-idea-2026.1

Description

A complete toolset for web, mobile and enterprise development

Added to portage

2026-03-27

jaq - 3.0.0
Ebuild name:

app-misc/jaq-3.0.0

Description

Just another JSON query tool

Added to portage

2026-03-27

libwebsockets - 4.5.8
Ebuild name:

net-libs/libwebsockets-4.5.8

Description

A flexible pure-C library for implementing network protocols

Added to portage

2026-03-27

mattermost-desktop-bin - 5.13.5
Ebuild name:

net-im/mattermost-desktop-bin-5.13.5

Description

Mattermost Desktop application

Added to portage

2026-03-27

microsoft-edge-beta - 147.0.3912.26
Ebuild name:

www-client/microsoft-edge-beta-147.0.3912.26

Description

The web browser from Microsoft

Added to portage

2026-03-27

nextcloud - 32.0.7
Ebuild name:

www-apps/nextcloud-32.0.7

Description

Personal cloud that runs on your own server

Added to portage

2026-03-27

nextcloud - 33.0.1
Ebuild name:

www-apps/nextcloud-33.0.1

Description

Personal cloud that runs on your own server

Added to portage

2026-03-27

nextcloud-client - 33.0.0-r1
Ebuild name:

net-misc/nextcloud-client-33.0.0-r1

Description

Desktop Syncing Client for Nextcloud

Added to portage

2026-03-27

nginx - 1.28.3
Ebuild name:

www-servers/nginx-1.28.3

Description

Added to portage

2026-03-27

nginx - 1.29.7-r1
Ebuild name:

www-servers/nginx-1.29.7-r1

Description

Added to portage

2026-03-27

oct2py - 6.0.1
Ebuild name:

dev-python/oct2py-6.0.1

Description

Python to GNU Octave bridge

Added to portage

2026-03-27

openpgp-keys-gentoo-developers - 20260323
Ebuild name:

sec-keys/openpgp-keys-gentoo-developers-20260323

Description

Gentoo Authority Keys (GLEP 79)

Added to portage

2026-03-27

opensmtpd - 7.8.0_p1
Ebuild name:

mail-mta/opensmtpd-7.8.0_p1

Description

Lightweight but featured SMTP daemon from OpenBSD

Added to portage

2026-03-27

opera - 129.0.5823.28
Ebuild name:

www-client/opera-129.0.5823.28

Description

A fast and secure web browser

Added to portage

2026-03-27

orage - 4.20.3
Ebuild name:

app-office/orage-4.20.3

Description

A calendar application for Xfce

Added to portage

2026-03-27

peewee - 4.0.3
Ebuild name:

dev-python/peewee-4.0.3

Description

Small Python ORM

Added to portage

2026-03-27

proto-plus - 1.27.2
Ebuild name:

dev-python/proto-plus-1.27.2

Description

Beautiful, Pythonic protocol buffers

Added to portage

2026-03-27

python-discovery - 1.2.1
Ebuild name:

dev-python/python-discovery-1.2.1

Description

Python interpreter discovery

Added to portage

2026-03-27

radarr-bin - 6.1.2.10359
Ebuild name:

www-apps/radarr-bin-6.1.2.10359

Description

A fork of Sonarr to work with movies a la Couchpotato

Added to portage

2026-03-27

ruff - 0.15.8
Ebuild name:

dev-util/ruff-0.15.8

Description

An extremely fast Python linter, written in Rust

Added to portage

2026-03-27

setuptools-rust - 1.12.1
Ebuild name:

dev-python/setuptools-rust-1.12.1

Description

A plugin for setuptools to build Rust Python extensions

Added to portage

2026-03-27

setuptools-scm - 10.0.3
Ebuild name:

dev-python/setuptools-scm-10.0.3

Description

Manage versions by scm tags via setuptools

Added to portage

2026-03-27

sybil - 10.0.1
Ebuild name:

dev-python/sybil-10.0.1

Description

Automated testing for the examples in your documentation

Added to portage

2026-03-27

tigervnc - 1.16.2
Ebuild name:

net-misc/tigervnc-1.16.2

Description

Remote desktop viewer display system

Added to portage

2026-03-27

tigervnc-xorg-module - 1.16.2
Ebuild name:

net-misc/tigervnc-xorg-module-1.16.2

Description

Metapackage for the xorg module provided by tigervnc

Added to portage

2026-03-27

transformers - 5.0.0
Ebuild name:

sci-ml/transformers-5.0.0

Description

State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow

Added to portage

2026-03-27

uv - 0.11.2
Ebuild name:

dev-python/uv-0.11.2

Description

A Python package installer and resolver, written in Rust

Added to portage

2026-03-27

uv-build - 0.11.2
Ebuild name:

dev-python/uv-build-0.11.2

Description

PEP517 uv build backend

Added to portage

2026-03-27

vanilla-sources - 6.12.79
Ebuild name:

sys-kernel/vanilla-sources-6.12.79

Description

Full sources for the Linux kernel

Added to portage

2026-03-27

xdoctest - 1.3.2
Ebuild name:

dev-python/xdoctest-1.3.2

Description

A rewrite of Python's builtin doctest module but without all the weirdnes

Added to portage

2026-03-27

xfdesktop - 4.20.2
Ebuild name:

xfce-base/xfdesktop-4.20.2

Description

Desktop manager for the Xfce desktop environment

Added to portage

2026-03-27

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