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:

89560

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-10-26
aria2 - 1.37.0-r1
Ebuild name:

net-misc/aria2-1.37.0-r1

Description

A download utility with segmented downloading with BitTorrent support

Added to portage

2026-10-26

curl - 8.23.0-r1
Ebuild name:

net-misc/curl-8.23.0-r1

Description

A Client that groks URLs

Added to portage

2026-10-26

gawk - 5.4.1c
Ebuild name:

sys-apps/gawk-5.4.1c

Description

GNU awk pattern-matching language

Added to portage

2026-10-26

johntheripper - 1.8.0-r2
Ebuild name:

app-crypt/johntheripper-1.8.0-r2

Description

fast password cracker

Added to portage

2026-10-26

johntheripper - 1.9.0
Ebuild name:

app-crypt/johntheripper-1.9.0

Description

fast password cracker

Added to portage

2026-10-26

johntheripper-jumbo - 1.9.0_p20240102
Ebuild name:

app-crypt/johntheripper-jumbo-1.9.0_p20240102

Description

Fast password cracker, community enhanced version

Added to portage

2026-10-26

johntheripper-jumbo - 1.9.0_p20250216-r1
Ebuild name:

app-crypt/johntheripper-jumbo-1.9.0_p20250216-r1

Description

Fast password cracker, community enhanced version

Added to portage

2026-10-26

johntheripper-jumbo - 1.9.0_p20250703
Ebuild name:

app-crypt/johntheripper-jumbo-1.9.0_p20250703

Description

Fast password cracker, community enhanced version

Added to portage

2026-10-26

johntheripper-jumbo - 9999
Ebuild name:

app-crypt/johntheripper-jumbo-9999

Description

Fast password cracker, community enhanced version

Added to portage

2026-10-26

kali-archive-keyring - 2020.2
Ebuild name:

app-crypt/kali-archive-keyring-2020.2

Description

GnuPG archive keys of the Kali archive

Added to portage

2026-10-26

kbfs - 6.0.2
Ebuild name:

app-crypt/kbfs-6.0.2

Description

Keybase Filesystem (KBFS)

Added to portage

2026-10-26

kbfs - 6.2.4
Ebuild name:

app-crypt/kbfs-6.2.4

Description

Keybase Filesystem (KBFS)

Added to portage

2026-10-26

language-c - 0.10.2
Ebuild name:

dev-haskell/language-c-0.10.2

Description

Analysis and generation of C code

Added to portage

2026-10-26

openssh-legacy - 9.9_p2-r1
Ebuild name:

net-misc/openssh-legacy-9.9_p2-r1

Description

Old versions of OpenSSH installed separately for legacy machines

Added to portage

2026-10-26

systemd - 262.1
Ebuild name:

sys-apps/systemd-262.1

Description

System and service manager for Linux

Added to portage

2026-10-26

tls - 2.0.1
Ebuild name:

dev-tcltk/tls-2.0.1

Description

TLS OpenSSL extension to Tcl

Added to portage

2026-10-26

2026-10-25
amf-headers - 1.5.2
Ebuild name:

media-libs/amf-headers-1.5.2

Description

The Advanced Media Framework (AMF) SDK

Added to portage

2026-10-25

apprise - 2.1.0
Ebuild name:

dev-python/apprise-2.1.0

Description

Push Notifications that work with just about every platform

Added to portage

2026-10-25

berkeleydb - 18.1.17
Ebuild name:

dev-python/berkeleydb-18.1.17

Description

Python bindings for Oracle Berkeley DB

Added to portage

2026-10-25

capnproto - 1.5.0
Ebuild name:

dev-libs/capnproto-1.5.0

Description

RPC/Serialization system with capabilities support

Added to portage

2026-10-25

cmd2 - 4.3.1
Ebuild name:

dev-python/cmd2-4.3.1

Description

Extra features for standard library's cmd module

Added to portage

2026-10-25

discord - 1.0.166
Ebuild name:

net-im/discord-1.0.166

Description

All-in-one voice and text chat for gamers

Added to portage

2026-10-25

efitools - 1.9.2_p1
Ebuild name:

app-crypt/efitools-1.9.2_p1

Description

Tools for manipulating UEFI secure boot platforms

Added to portage

2026-10-25

electrum - 4.8.3
Ebuild name:

net-misc/electrum-4.8.3

Description

User friendly Bitcoin client

Added to portage

2026-10-25

gallery-dl - 1.32.17-r1
Ebuild name:

net-misc/gallery-dl-1.32.17-r1

Description

Download image galleries and collections from several image hosting

Added to portage

2026-10-25

gallery-dl - 1.32.18
Ebuild name:

net-misc/gallery-dl-1.32.18

Description

Download image galleries and collections from several image hosting sit

Added to portage

2026-10-25

git - 2.56.0-r1
Ebuild name:

dev-vcs/git-2.56.0-r1

Description

Stupid content tracker distributed VCS designed for speed and efficiency

Added to portage

2026-10-25

gnupg - 2.5.24-r2
Ebuild name:

app-crypt/gnupg-2.5.24-r2

Description

The GNU Privacy Guard, a GPL OpenPGP implementation

Added to portage

2026-10-25

icu4j - 79.1
Ebuild name:

dev-java/icu4j-79.1

Description

A set of Java libraries providing Unicode and Globalization support

Added to portage

2026-10-25

isync - 1.5.1-r1
Ebuild name:

net-mail/isync-1.5.1-r1

Description

MailDir mailbox synchronizer

Added to portage

2026-10-25

jsonpatch - 1.37
Ebuild name:

dev-python/jsonpatch-1.37

Description

Apply JSON-Patches like http

Added to portage

2026-10-25

jsonpointer - 3.5
Ebuild name:

dev-python/jsonpointer-3.5

Description

Identify specific nodes in a JSON document (according to draft 08)

Added to portage

2026-10-25

log4j-core - 2.26.0-r1
Ebuild name:

dev-java/log4j-core-2.26.0-r1

Description

The Apache Log4j Implementation

Added to portage

2026-10-25

lucene - 2.4.1-r6
Ebuild name:

dev-java/lucene-2.4.1-r6

Description

High-performance, full-featured text search engine written entirely in Jav

Added to portage

2026-10-25

multidict - 7.2.1
Ebuild name:

dev-python/multidict-7.2.1

Description

multidict implementation

Added to portage

2026-10-25

mysql-connector-c - 26.10.0
Ebuild name:

dev-db/mysql-connector-c-26.10.0

Description

C client library for MariaDB/MySQL

Added to portage

2026-10-25

mysql-connector-c - 8.0.46
Ebuild name:

dev-db/mysql-connector-c-8.0.46

Description

C client library for MariaDB/MySQL

Added to portage

2026-10-25

openssh - 0-r2
Ebuild name:

virtual/openssh-0-r2

Description

Virtual for net-misc/openssh and variants

Added to portage

2026-10-25

pam_p11 - 0.6.1
Ebuild name:

sys-auth/pam_p11-0.6.1

Description

PAM module for authenticating against PKCS11 tokens

Added to portage

2026-10-25

pcsc-lite - 2.5.3
Ebuild name:

sys-apps/pcsc-lite-2.5.3

Description

PC/SC Architecture smartcard middleware library

Added to portage

2026-10-25

pcsc-tools - 1.7.5
Ebuild name:

sys-apps/pcsc-tools-1.7.5

Description

PC/SC Architecture smartcard tools

Added to portage

2026-10-25

pkcs11-provider - 1.3.0
Ebuild name:

dev-libs/pkcs11-provider-1.3.0

Description

OpenSSL 3+ provider to access hardware or software tokens via PKCS11

Added to portage

2026-10-25

pkgcheck - 0.10.49
Ebuild name:

dev-util/pkgcheck-0.10.49

Description

pkgcore-based QA utility for ebuild repos

Added to portage

2026-10-25

pkgcore - 0.12.48
Ebuild name:

sys-apps/pkgcore-0.12.48

Description

a framework for package management

Added to portage

2026-10-25

pkgdev - 0.2.19
Ebuild name:

dev-util/pkgdev-0.2.19

Description

Collection of tools for Gentoo development

Added to portage

2026-10-25

publicsuffix-db - 20260907
Ebuild name:

net-misc/publicsuffix-db-20260907

Description

The Public Suffix List

Added to portage

2026-10-25

pycryptodome - 4.2.0
Ebuild name:

dev-python/pycryptodome-4.2.0

Description

A self-contained cryptographic library for Python

Added to portage

2026-10-25

qbittorrent - 5.3.0
Ebuild name:

net-p2p/qbittorrent-5.3.0

Description

BitTorrent client in C++ and Qt

Added to portage

2026-10-25

simdutf - 9.3.2
Ebuild name:

dev-cpp/simdutf-9.3.2

Description

Unicode validation and transcoding at billions of characters per second

Added to portage

2026-10-25

softhsm - 2.7.0
Ebuild name:

dev-libs/softhsm-2.7.0

Description

A software PKCS11 implementation

Added to portage

2026-10-25

starlette - 1.10.0
Ebuild name:

dev-python/starlette-1.10.0

Description

The little ASGI framework that shines

Added to portage

2026-10-25

sun-jai-bin - 1.1.3-r4
Ebuild name:

dev-java/sun-jai-bin-1.1.3-r4

Description

JAI is a class library for managing images

Added to portage

2026-10-25

sunshine - 2026.914.233613
Ebuild name:

net-misc/sunshine-2026.914.233613

Description

Self-hosted game stream host for Moonlight

Added to portage

2026-10-25

wcwidth - 0.9.4
Ebuild name:

dev-python/wcwidth-0.9.4

Description

Measures number of Terminal column cells of wide-character codes

Added to portage

2026-10-25

wtforms - 3.3.1
Ebuild name:

dev-python/wtforms-3.3.1

Description

Flexible forms validation and rendering library for python web development

Added to portage

2026-10-25

zoitechat - 2.19.1
Ebuild name:

net-irc/zoitechat-2.19.1

Description

GTK+ IRC client that's a fork of HexChat

Added to portage

2026-10-25

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