Gentoo/Vpnc Non Root

Page last edited 3,768 days ago
From Alon Bar-Lev's Site
Jump to navigation Jump to search

vpnc Non Root

End result, user can use own tool (I use knemo) to connect/disconnect from net-misc/vpnc.

The logic is to create tun device and allow users to access it, and wrapping the /sbin/ip and /sbin/resolvconf using sudo.

Setup

Linux Kernel Configuration: Add tap
  Device Drivers  ---> 
    [*] Network device support  --->
      <M>   Universal TUN/TAP device driver support

Setup portage overlay from here.

emerge net-misc/vpnc net-dns/openresolv

net-dns/openresolv is optional, but makes life much easier, see Gentoo/Openresolv.

It is very recommended to configure firewall on your computer, see firehol configuration.

Add:

File: /etc/conf.d/net
rc_net_vpn0_need="firewall" # optional, if you setup firewall.
rc_net_vpn0_provide="!net"
tuntap_vpn0="tun"
iproute2_vpn0="group users"
config_vpn0="null"
txqueuelen_vpn0="100"
metric_vpn0="10"
ln -s net.lo /etc/init.d/net.vpn0 rc-update add net.vpn0 default /etc/init.d/net.vpn0 start
mkdir -p ~/vpnc/run

Add the following to your configuration:

File: ~/vpnc/site.conf
Interface name vpn0
Local Port 0
Pidfile /home/@USER@/vpnc/run/pid
Script VAR_RUN="/home/@USER@/vpnc/run" ROUTE_METRIC="10" IPROUTE="sudo /sbin/ip" RESOLVCONF="sudo /sbin/resolvconf" /etc/vpnc/vpnc-script
Xauth interactive
File: /etc/sudoers.d/vpnc
%users ALL=(ALL) NOPASSWD: /sbin/ip
%users ALL=(ALL) NOPASSWD: /sbin/resolvconf

cli

Start:

/usr/sbin/vpnc /home/@USER@/vpnc/site.conf

Stop:

VAR_RUN="/home/@USER@/vpnc/run" /usr/sbin/vpnc-disconnect

knemo

Dialogs

File: ~/vpnc/vpnc-getpass
#!/bin/sh

die() {
        local m="$1"
        echo "FATAL: $1" >&2
        exit 1
}

prompt="$1"

[ -z "${prompt}" ] && die "usage: $0 prompt"

kdialog --title "vpnc" --password "$prompt" || die "password"

Add the following to your configuration:

File: ~/vpnc/site.conf
Password Program /home/@USER@/vpnc/vpnc-getpass

Context menu

Start/stop same as cli above.

Maintainer

Alon Bar-Lev

Authors

Originally written by: Alon Bar-Lev - 2012-08-15


Authors are people who have worked on this document and have made significant changes to its content. If you have edited this article and wish to add yourself to the authors list please read "Who are Authors".