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:

86233

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-24
ant-ivy - 2.5.3
Ebuild name:

dev-java/ant-ivy-2.5.3

Description

Ivy is a free java based dependency manager

Added to portage

2026-06-24

assertj-core - 3.27.7
Ebuild name:

dev-java/assertj-core-3.27.7

Description

Rich and fluent assertions for testing for Java

Added to portage

2026-06-24

awscli - 1.45.35
Ebuild name:

app-admin/awscli-1.45.35

Description

Universal Command Line Environment for AWS

Added to portage

2026-06-24

bcmail - 1.84
Ebuild name:

dev-java/bcmail-1.84

Description

The Bouncy Castle Java S/MIME APIs for handling S/MIME protocols

Added to portage

2026-06-24

bcpg - 1.84
Ebuild name:

dev-java/bcpg-1.84

Description

Java cryptography APIs

Added to portage

2026-06-24

bcpkix - 1.84
Ebuild name:

dev-java/bcpkix-1.84

Description

Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation

Added to portage

2026-06-24

bcprov - 1.84
Ebuild name:

dev-java/bcprov-1.84

Description

Java cryptography APIs

Added to portage

2026-06-24

bcutil - 1.84
Ebuild name:

dev-java/bcutil-1.84

Description

Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctl

Added to portage

2026-06-24

bear - 4.1.4
Ebuild name:

dev-util/bear-4.1.4

Description

A tool that generates a compilation database for clang tooling

Added to portage

2026-06-24

blake3 - 1.0.9
Ebuild name:

dev-python/blake3-1.0.9

Description

Python bindings for the BLAKE3 cryptographic hash function

Added to portage

2026-06-24

boto3 - 1.43.35
Ebuild name:

dev-python/boto3-1.43.35

Description

The AWS SDK for Python

Added to portage

2026-06-24

botocore - 1.43.35
Ebuild name:

dev-python/botocore-1.43.35

Description

Low-level, data-driven core of boto 3

Added to portage

2026-06-24

coverage - 7.14.3
Ebuild name:

dev-python/coverage-7.14.3

Description

Code coverage measurement for Python

Added to portage

2026-06-24

cutechess - 1.5.1
Ebuild name:

games-board/cutechess-1.5.1

Description

Cross-platform tools for working with chess engines

Added to portage

2026-06-24

deepmerge - 2.1.0
Ebuild name:

dev-python/deepmerge-2.1.0

Description

Tools to handle merging of nested data structures in python

Added to portage

2026-06-24

desktop-file-utils - 0.28-r1
Ebuild name:

dev-util/desktop-file-utils-0.28-r1

Description

Command line utilities to work with desktop menu entries

Added to portage

2026-06-24

duckdb - 1.5.4
Ebuild name:

dev-db/duckdb-1.5.4

Description

high-performance analytical database system

Added to portage

2026-06-24

fgl - 5.8.3.1
Ebuild name:

dev-haskell/fgl-5.8.3.1

Description

Martin Erwig's Functional Graph Library

Added to portage

2026-06-24

gentoo-dtd - 20260615
Ebuild name:

app-text/gentoo-dtd-20260615

Description

Document Type Definition for Gentoo-related XML files

Added to portage

2026-06-24

gnome-commander - 2.0.3
Ebuild name:

gnome-extra/gnome-commander-2.0.3

Description

A graphical, full featured, twin-panel file manager

Added to portage

2026-06-24

gnu-regexp - 1.1.4-r5
Ebuild name:

dev-java/gnu-regexp-1.1.4-r5

Description

GNU regular expression package for Java

Added to portage

2026-06-24

hspec-contrib - 0.5.2
Ebuild name:

dev-haskell/hspec-contrib-0.5.2

Description

Contributed functionality for Hspec

Added to portage

2026-06-24

jackcess - 4.0.10
Ebuild name:

dev-java/jackcess-4.0.10

Description

A pure Java library for reading from and writing to MS Access databases

Added to portage

2026-06-24

just - 1.52.0
Ebuild name:

dev-build/just-1.52.0

Description

Just a command runner (with syntax inspired by 'make')

Added to portage

2026-06-24

log4j-12-api - 2.26.0
Ebuild name:

dev-java/log4j-12-api-2.26.0

Description

The Apache Log4j 1.x Compatibility API

Added to portage

2026-06-24

log4j-api - 2.26.0
Ebuild name:

dev-java/log4j-api-2.26.0

Description

The Apache Log4j API

Added to portage

2026-06-24

log4j-core - 2.26.0
Ebuild name:

dev-java/log4j-core-2.26.0

Description

The Apache Log4j Implementation

Added to portage

2026-06-24

mistune - 3.3.2
Ebuild name:

dev-python/mistune-3.3.2

Description

The fastest markdown parser in pure Python

Added to portage

2026-06-24

perl - 5.44.0_rc1
Ebuild name:

dev-lang/perl-5.44.0_rc1

Description

Larry Wall's Practical Extraction and Report Language

Added to portage

2026-06-24

phonenumbers - 9.0.33
Ebuild name:

dev-python/phonenumbers-9.0.33

Description

Python port of Google's libphonenumber

Added to portage

2026-06-24

poi - 5.5.1
Ebuild name:

dev-java/poi-5.5.1

Description

Java API to access Mocrosoft format files

Added to portage

2026-06-24

prettytable - 3.18.0
Ebuild name:

dev-python/prettytable-3.18.0

Description

Easily displaying tabular data in a visually appealing ASCII table fo

Added to portage

2026-06-24

pyfuse3 - 3.5.0
Ebuild name:

dev-python/pyfuse3-3.5.0

Description

Python 3 bindings for libfuse 3 with asynchronous API

Added to portage

2026-06-24

pypdf - 6.14.0
Ebuild name:

dev-python/pypdf-6.14.0

Description

Python library to work with PDF files

Added to portage

2026-06-24

python - 0.3.15.0_beta3
Ebuild name:

dev-lang/python-0.3.15.0_beta3

Description

Freethreading (no-GIL) version of Python programming language

Added to portage

2026-06-24

python - 3.15.0_beta3
Ebuild name:

dev-lang/python-3.15.0_beta3

Description

An interpreted, interactive, object-oriented programming language

Added to portage

2026-06-24

python-tests - 0.3.15.0_beta3
Ebuild name:

dev-python/python-tests-0.3.15.0_beta3

Description

Test modules from dev-lang/python

Added to portage

2026-06-24

python-tests - 3.15.0_beta3
Ebuild name:

dev-python/python-tests-3.15.0_beta3

Description

Test modules from dev-lang/python

Added to portage

2026-06-24

sccache - 0.16.0
Ebuild name:

dev-util/sccache-0.16.0

Description

ccache/distcc like tool with support for rust and cloud storage

Added to portage

2026-06-24

setuptools-scm - 10.1.1
Ebuild name:

dev-python/setuptools-scm-10.1.1

Description

Manage versions by scm tags via setuptools

Added to portage

2026-06-24

setuptools-scm - 10.1.2
Ebuild name:

dev-python/setuptools-scm-10.1.2

Description

Manage versions by scm tags via setuptools

Added to portage

2026-06-24

shellcheck - 0.11.0
Ebuild name:

dev-util/shellcheck-0.11.0

Description

Shell script analysis tool

Added to portage

2026-06-24

shelltestrunner - 1.11
Ebuild name:

dev-util/shelltestrunner-1.11

Description

Easy, repeatable testing of CLI programs/commands

Added to portage

2026-06-24

sqlmap - 1.10.6
Ebuild name:

dev-db/sqlmap-1.10.6

Description

An automatic SQL injection and database takeover tool

Added to portage

2026-06-24

trang - 20241231-r1
Ebuild name:

app-text/trang-20241231-r1

Description

Multi-format schema converter based on RELAX NG

Added to portage

2026-06-24

translate-toolkit - 3.19.12
Ebuild name:

dev-python/translate-toolkit-3.19.12

Description

Toolkit to convert between many translation formats

Added to portage

2026-06-24

unison-lang-bin - 1.3.0-r1
Ebuild name:

dev-lang/unison-lang-bin-1.3.0-r1

Description

A friendly programming language from the future

Added to portage

2026-06-24

vcs-versioning - 2.1.0
Ebuild name:

dev-python/vcs-versioning-2.1.0

Description

Core VCS versioning functionality from setuptools-scm

Added to portage

2026-06-24

yara-x - 1.18.0
Ebuild name:

app-forensics/yara-x-1.18.0

Description

A malware identification and classification tool

Added to portage

2026-06-24

zeroconf - 0.150.0
Ebuild name:

dev-python/zeroconf-0.150.0

Description

Pure Python Multicast DNS Service Discovery Library (Bonjour/Avahi comp

Added to portage

2026-06-24

2026-06-23
courier - 2.0.1
Ebuild name:

mail-mta/courier-2.0.1

Description

An MTA designed specifically for maildirs

Added to portage

2026-06-23

courier-authlib - 0.73.0
Ebuild name:

net-libs/courier-authlib-0.73.0

Description

Courier authentication library

Added to portage

2026-06-23

courier-unicode - 2.6.0
Ebuild name:

net-libs/courier-unicode-2.6.0

Description

Unicode library used by the courier mail server

Added to portage

2026-06-23

pkgcheck - 0.10.39-r1
Ebuild name:

dev-util/pkgcheck-0.10.39-r1

Description

pkgcore-based QA utility for ebuild repos

Added to portage

2026-06-23

rspamd - 4.0.1-r1
Ebuild name:

mail-filter/rspamd-4.0.1-r1

Description

Rapid spam filtering system

Added to portage

2026-06-23

rspamd - 4.1.1
Ebuild name:

mail-filter/rspamd-4.1.1

Description

Rapid spam filtering system

Added to portage

2026-06-23

spyder-kernels - 3.1.4_p20260622
Ebuild name:

dev-python/spyder-kernels-3.1.4_p20260622

Description

Kernels used by spyder on its ipython console

Added to portage

2026-06-23

zdkimfilter - 3.24
Ebuild name:

mail-filter/zdkimfilter-3.24

Description

DKIM filter for Courier-MTA

Added to portage

2026-06-23

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