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:

82616

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
2025-12-26
android-studio - 2025.2.2.8
Ebuild name:

dev-util/android-studio-2025.2.2.8

Description

Android development environment based on IntelliJ IDEA

Added to portage

2025-12-26

cargo-c - 0.10.19
Ebuild name:

dev-util/cargo-c-0.10.19

Description

Helper program to build and install c-like libraries

Added to portage

2025-12-26

charliecloud - 0.43
Ebuild name:

sys-cluster/charliecloud-0.43

Description

Lightweight user-defined software stacks for high-performance computi

Added to portage

2025-12-26

cmd2 - 3.1.0
Ebuild name:

dev-python/cmd2-3.1.0

Description

Extra features for standard library's cmd module

Added to portage

2025-12-26

containerd - 2.2.0
Ebuild name:

app-containers/containerd-2.2.0

Description

A daemon to control runC

Added to portage

2025-12-26

docker - 29.1.3
Ebuild name:

app-containers/docker-29.1.3

Description

The core functions you need to create Docker images and run Docker con

Added to portage

2025-12-26

docker-cli - 29.1.3
Ebuild name:

app-containers/docker-cli-29.1.3

Description

the command line binary for docker

Added to portage

2025-12-26

doxygen - 1.15.0-r2
Ebuild name:

app-text/doxygen-1.15.0-r2

Description

Documentation system for most programming languages

Added to portage

2025-12-26

eselect-ruby - 20251225
Ebuild name:

app-eselect/eselect-ruby-20251225

Description

Manages multiple Ruby versions

Added to portage

2025-12-26

gnatformat - 25.0.0-r2
Ebuild name:

dev-ada/gnatformat-25.0.0-r2

Description

Opinionated code formatter for the Ada language

Added to portage

2025-12-26

gpr - 26.0.0
Ebuild name:

dev-ada/gpr-26.0.0

Description

LibGPR2 - Parser for GPR Project files

Added to portage

2025-12-26

granite - 7.7.0
Ebuild name:

dev-libs/granite-7.7.0

Description

Elementary OS library that extends GTK+

Added to portage

2025-12-26

intellij-idea - 2025.3.1
Ebuild name:

dev-util/intellij-idea-2025.3.1

Description

A complete toolset for web, mobile and enterprise development

Added to portage

2025-12-26

langkit - 26.0.0
Ebuild name:

dev-ada/langkit-26.0.0

Description

A Python framework to generate language parsers

Added to portage

2025-12-26

libnpupnp - 6.2.3
Ebuild name:

net-libs/libnpupnp-6.2.3

Description

A C++ base UPnP library, derived from Portable UPnP, a.k.a libupnp

Added to portage

2025-12-26

librt - 0.7.5
Ebuild name:

dev-python/librt-0.7.5

Description

Mypyc runtime library

Added to portage

2025-12-26

multi_json - 1.19.0
Ebuild name:

dev-ruby/multi_json-1.19.0

Description

A gem to provide swappable JSON backends

Added to portage

2025-12-26

oneDNN - 3.10.2
Ebuild name:

sci-ml/oneDNN-3.10.2

Description

oneAPI Deep Neural Network Library

Added to portage

2025-12-26

openhab - 1
Ebuild name:

acct-user/openhab-1

Description

Added to portage

2025-12-26

openhab-bin - 5.1.0
Ebuild name:

app-misc/openhab-bin-5.1.0

Description

An open-source automation software for your home

Added to portage

2025-12-26

org-static-blog - 9999
Ebuild name:

app-emacs/org-static-blog-9999

Description

Static site generator using Emacs's org-mode

Added to portage

2025-12-26

org-superstar-mode - 1.5.0
Ebuild name:

app-emacs/org-superstar-mode-1.5.0

Description

Prettify headings and plain lists in Org mode (use UTF8 bullets)

Added to portage

2025-12-26

osm - 1.10
Ebuild name:

app-emacs/osm-1.10

Description

OpenStreetMap tile-based viewer for GNU Emacs

Added to portage

2025-12-26

osm - 1.9
Ebuild name:

app-emacs/osm-1.9

Description

OpenStreetMap tile-based viewer for GNU Emacs

Added to portage

2025-12-26

portage - 3.0.69.3-r3
Ebuild name:

sys-apps/portage-3.0.69.3-r3

Description

The package management and distribution system for Gentoo

Added to portage

2025-12-26

primecount - 8.0
Ebuild name:

sci-mathematics/primecount-8.0

Description

Highly optimized CLI and library to count primes

Added to portage

2025-12-26

primecountpy - 0.1.1-r1
Ebuild name:

dev-python/primecountpy-0.1.1-r1

Description

Cython interface to sci-mathematics/primecount

Added to portage

2025-12-26

q4wine - 1.4.2
Ebuild name:

app-emulation/q4wine-1.4.2

Description

Qt GUI configuration tool for Wine

Added to portage

2025-12-26

qemu - 10.1.3-r1
Ebuild name:

app-emulation/qemu-10.1.3-r1

Description

QEMU + Kernel-based Virtual Machine userland tools

Added to portage

2025-12-26

rbs - 3.10.0
Ebuild name:

dev-ruby/rbs-3.10.0

Description

The language for type signatures for Ruby and standard library definitions

Added to portage

2025-12-26

runc - 1.4.0
Ebuild name:

app-containers/runc-1.4.0

Description

runc container cli tools

Added to portage

2025-12-26

typer - 0.21.0
Ebuild name:

dev-python/typer-0.21.0

Description

Build great CLIs. Easy to code. Based on Python type hints

Added to portage

2025-12-26

upmpdcli - 1.9.8
Ebuild name:

media-sound/upmpdcli-1.9.8

Description

UPnP Media Renderer front-end for MPD, the Music Player Daemon

Added to portage

2025-12-26

vdr-femon - 2.4.0_p20240910-r2
Ebuild name:

media-plugins/vdr-femon-2.4.0_p20240910-r2

Description

VDR Plugin DVB Frontend Status Monitor (signal strength/

Added to portage

2025-12-26

vdr-wirbelscan - 2024.09.15-r1
Ebuild name:

media-plugins/vdr-wirbelscan-2024.09.15-r1

Description

VDR Plugin Scan for channels on DVB-? and on PVR*-Cards

Added to portage

2025-12-26

worldofpadman - 1.7.0-r3
Ebuild name:

games-fps/worldofpadman-1.7.0-r3

Description

Cartoon style multiplayer first-person shooter

Added to portage

2025-12-26

2025-12-25
86Box - 5.3
Ebuild name:

app-emulation/86Box-5.3

Description

Emulator of x86-based machines based on PCem

Added to portage

2025-12-25

dbeaver-bin - 25.3.1
Ebuild name:

dev-db/dbeaver-bin-25.3.1

Description

Free universal database tool (community edition)

Added to portage

2025-12-25

django-polymorphic - 4.5.1
Ebuild name:

dev-python/django-polymorphic-4.5.1

Description

Seamless Polymorphic Inheritance for Django Models

Added to portage

2025-12-25

fcitx - 5.1.17
Ebuild name:

app-i18n/fcitx-5.1.17

Description

Fcitx 5 is a generic input method framework

Added to portage

2025-12-25

fcitx-chewing - 5.1.10
Ebuild name:

app-i18n/fcitx-chewing-5.1.10

Description

Chewing Wrapper for Fcitx.

Added to portage

2025-12-25

fcitx-chinese-addons - 5.1.11
Ebuild name:

app-i18n/fcitx-chinese-addons-5.1.11

Description

Addons related to Chinese, including IME previous bundled insi

Added to portage

2025-12-25

fcitx-configtool - 5.1.12
Ebuild name:

app-i18n/fcitx-configtool-5.1.12

Description

Configuration module for Fcitx

Added to portage

2025-12-25

fcitx-gtk - 5.1.5
Ebuild name:

app-i18n/fcitx-gtk-5.1.5

Description

Gtk im module for fcitx5 and glib based dbus client library

Added to portage

2025-12-25

fcitx-qt - 5.1.12
Ebuild name:

app-i18n/fcitx-qt-5.1.12

Description

Qt library and IM module for fcitx5

Added to portage

2025-12-25

fcitx-table-extra - 5.1.10
Ebuild name:

app-i18n/fcitx-table-extra-5.1.10

Description

Provides extra table for Fcitx, including Boshiamy, Zhengma, Cang

Added to portage

2025-12-25

ffmpeg-chromium - 138
Ebuild name:

media-video/ffmpeg-chromium-138

Description

FFmpeg built specifically for codec support in Chromium-based brows

Added to portage

2025-12-25

gamescope - 3.16.19
Ebuild name:

gui-wm/gamescope-3.16.19

Description

Efficient micro-compositor for running games

Added to portage

2025-12-25

hashie - 5.1.0
Ebuild name:

dev-ruby/hashie-5.1.0

Description

Hashie is a small collection of tools that make hashes more powerful

Added to portage

2025-12-25

hoe - 4.5.0
Ebuild name:

dev-ruby/hoe-4.5.0

Description

Hoe extends rake to provide full project automation

Added to portage

2025-12-25

jaraco-context - 6.0.2
Ebuild name:

dev-python/jaraco-context-6.0.2

Description

Context managers by jaraco

Added to portage

2025-12-25

jaraco-test - 5.6.0
Ebuild name:

dev-python/jaraco-test-5.6.0

Description

Testing support by jaraco

Added to portage

2025-12-25

ledger - 3.4.1
Ebuild name:

app-office/ledger-3.4.1

Description

Double-entry accounting system with a command-line reporting interface

Added to portage

2025-12-25

libdecor - 0.2.5
Ebuild name:

gui-libs/libdecor-0.2.5

Description

A client-side decorations library for Wayland clients

Added to portage

2025-12-25

libime - 1.1.13
Ebuild name:

app-i18n/libime-1.1.13

Description

Fcitx5 Next generation of fcitx

Added to portage

2025-12-25

librime - 1.15.0
Ebuild name:

app-i18n/librime-1.15.0

Description

RIME (Rime Input Method Engine) core library

Added to portage

2025-12-25

mergiraf - 0.16.1
Ebuild name:

dev-vcs/mergiraf-0.16.1

Description

Syntax-aware git merge driver

Added to portage

2025-12-25

multi_xml - 0.8.0
Ebuild name:

dev-ruby/multi_xml-0.8.0

Description

A generic swappable back-end for XML parsing

Added to portage

2025-12-25

oslo-serialization - 5.9.0
Ebuild name:

dev-python/oslo-serialization-5.9.0

Description

Oslo Serialization library

Added to portage

2025-12-25

python-engineio - 4.13.0
Ebuild name:

dev-python/python-engineio-4.13.0

Description

Python implementation of the Engine.IO realtime server

Added to portage

2025-12-25

rime-data - 1.0.20251206
Ebuild name:

app-i18n/rime-data-1.0.20251206

Description

Added to portage

2025-12-25

ruby2ruby - 2.6.0
Ebuild name:

dev-ruby/ruby2ruby-2.6.0

Description

Generates readable ruby from ParseTree

Added to portage

2025-12-25

sexp_processor - 4.17.5
Ebuild name:

dev-ruby/sexp_processor-4.17.5

Description

Processor for s-expressions created as part of the ParseTree project

Added to portage

2025-12-25

subrandr - 1.0.1
Ebuild name:

media-libs/subrandr-1.0.1

Description

Subtitle rendering library for rendering non-ASS subtitles

Added to portage

2025-12-25

test-unit - 3.7.6
Ebuild name:

dev-ruby/test-unit-3.7.6

Description

An xUnit family unit testing framework for Ruby

Added to portage

2025-12-25

vivaldi - 7.7.3851.66
Ebuild name:

www-client/vivaldi-7.7.3851.66

Description

A browser for our friends

Added to portage

2025-12-25

vivaldi-snapshot - 7.8.3899.3
Ebuild name:

www-client/vivaldi-snapshot-7.8.3899.3

Description

A browser for our friends

Added to portage

2025-12-25

xsimd - 14.0.0
Ebuild name:

dev-cpp/xsimd-14.0.0

Description

C++ wrappers for SIMD intrinsics

Added to portage

2025-12-25

xyzservices - 2025.11.0
Ebuild name:

sci-geosciences/xyzservices-2025.11.0

Description

Source of XYZ tiles providers

Added to portage

2025-12-25

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