LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 02-03-2009, 03:26 AM   #1
ElLunchbox
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Rep: Reputation: 0
VPN - OpenVPN/PPTP


Hi,

I currently have a server that sits behind a router at home (router IP 192.168.1.254, server IP 192.168.1.100). I would like to setup a VPN to a) access files hosted on the server b) have as a secure gateway when using unsecured wireless. I realise that this can be acomplished by 2 types of VPN, but if possible would like a bit of guidance about which is which and how to configure them (i.e. setting up the routing/IPs of the network). Thanks in advance.
 
Old 02-03-2009, 09:54 AM   #2
watcher69b
Member
 
Registered: Nov 2007
Location: /home/watcher69b
Distribution: RH, Fedora & CentOS
Posts: 539

Rep: Reputation: 39
a. i think your best bet would be openvpn. there is an extensive how to on their website that will tell you step by step how to configure it as well as how to make the files you want accessable. You will also find that there is lots of support for the oVPN software.

b. I think I know what your saying. You want to be able to use your vpn sever to browse the internet while on a non-secure wireless?
 
Old 02-04-2009, 02:22 AM   #3
ElLunchbox
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by watcher69b View Post
b. I think I know what your saying. You want to be able to use your vpn sever to browse the internet while on a non-secure wireless?
Thanks for the reply. Yer essentially I want to be able to VPN into my server at home from my laptop (for instance if I were on the unsecured wireless on the train), so that the internet is tunneled through the server at home and is therefore as secure as the home network. Can this be achieved via openvpn, or would it be worth setting up a different VPN for this? Basically, there are 2 instances that I would use VPN for a) accessing samba shared files but still browsing through loactions connection (e.g. @friends house) so you're suggesting openvpn, and b) securing unsecured wireless for using internet banking when on the train etc...

Thanks in advance.
 
Old 02-05-2009, 05:53 AM   #4
watcher69b
Member
 
Registered: Nov 2007
Location: /home/watcher69b
Distribution: RH, Fedora & CentOS
Posts: 539

Rep: Reputation: 39
OpenVPN sounds like your best bet. you can have a simple connection like that up and running in about an hour.

if you google openvpn and click on the howto link it will walk you through the whole process. it looks daunting but its really not. just make sure you read the steps in their entirety before you do anything.

As a tip:
The only problem i had with it was allowing my openvpn IP range access to the lan 192.168.1.x
Because the 10.8.0.x they tell you to use didnt mesh with out route statements. I ended up having my vpn 192.168.2.x and telling my router that it was on a class b (192.168.x.x) now it works perfectly.

Also if you dont have a static IP such as with Comcast/Metrocast sign up for a dydns account. They are free and it will allow you to connect even if your IP changes...
www.dyndns.com

to help you on your way here is my client config.
I will post my server config later...
#######################################################
client
dev tun
proto UDP # you can also choose TCP if you want to...
remote myddnshostname.com 1194
resolv-retry infinite
nobind
# Downgrade privileges after initialization (non-Windows only)
user nobody
group nobody
# Try to preserve some state across restarts.
persist-key
persist-tun
# Wireless networks often produce a lot
# of duplicate packets. Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings
ca /home/.../vpn/cert-authority-name.crt
cert /home/.../vpn/laptopname.crt
key /home/.../vpn/laptopname.key
ns-cert-type server
tls-auth /home/.../vpn/ta.key 1
cipher CIPHERNAME
comp-lzo
# Set log file verbosity.
verb 3
# Silence repeating messages
mute 5
#######################################################
 
Old 02-05-2009, 06:55 AM   #5
watcher69b
Member
 
Registered: Nov 2007
Location: /home/watcher69b
Distribution: RH, Fedora & CentOS
Posts: 539

Rep: Reputation: 39
Server config

# Which local IP address should OpenVPN
# listen on? (optional)
local 192.168.2.1

# Which TCP/UDP port should OpenVPN listen on?
# You will need to
# open up this port on your firewall.
port 1194

# TCP or UDP server?
proto udp

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
;dev tap
dev tun


# SSL/TLS root certificate (ca), certificate

ca /etc/openvpn/.../CA-NAME.crt
cert /etc/openvpn/.../SERVERNAME.crt
key /etc/openvpn/.../SERVERNAME.key

# Diffie hellman parameters.
dh /etc/openvpn/.../dh1024.pem

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
server 192.168.2.0 255.255.255.0

# Maintain a record of client <-> virtual IP address
# associations in this file. If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist ipp.txt


;server-bridge

# Push routes to the client to allow it
# to reach other private subnets behind
# the server. Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
push "route 192.168.0.0 255.255.0.0"


# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
# iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN. This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
# ifconfig-push 10.9.0.1 10.9.0.2

# Suppose that you want to enable different
# firewall access policies for different groups
# of clients. There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
# group, and firewall the TUN/TAP interface
# for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
# modify the firewall in response to access
# from different clients. See man
# page for more info on learn-address script.
;learn-address ./script

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly).
push "redirect-gateway def1 bypass-dhcp"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses. CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
push "dhcp-option DNS 192.168.1.1"
push "dhcp-option DNS 192.168.2.1"
push "dhcp-option WINS 192.168.1.1"


# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
;client-to-client

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120

# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
# openvpn --genkey --secret ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
tls-auth /etc/openvpn/.../ta.key 0

# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
cipher CIPHERNAME

# Enable compression on the VPN link.
# If you enable it here, you must also
# enable it in the client config file.
comp-lzo

# The maximum number of concurrently connected
# clients we want to allow.
max-clients #

# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this out on
# non-Windows systems.
user nobody
group nobody

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status openvpn-status.log

# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it. Use one
# or the other (but not both).
;log openvpn.log
log-append openvpn.log

# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 4

# Silence repeating messages. At most 20
# sequential messages of the same message
# category will be output to the log.
mute 20
 
Old 02-05-2009, 08:36 AM   #6
ElLunchbox
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks for posting your config files. Really appreciate it. I'll have a forray into it at the weekend and let you know how I get on.

I'd already had a small foray into openvpn (i.e. set up dyndns, opened ports on router, setup cerficates etc), but after a few hours/days of trying I couldn't get it to work so gave up. Hopefully this time I'll be more successful. I think that the routing was giving me the problems tho. My server has a static IP of 192.168.1.100, with the router at 192.168.1.254. Could you explain what you mean by

Quote:
I ended up having my vpn 192.168.2.x and telling my router that it was on a class b (192.168.x.x) now it works perfectly.
Do I need to change the servers IP, and where do I need to forward the ports to?
 
Old 02-06-2009, 05:39 AM   #7
watcher69b
Member
 
Registered: Nov 2007
Location: /home/watcher69b
Distribution: RH, Fedora & CentOS
Posts: 539

Rep: Reputation: 39
well the easy answer is that you dont want your VPN clients bumping into your LAN clients.

If your local LAN is 192.168.1.1-254 then you should make your VPN addresses like 192.168.2.x something different so that clients to not have the same IP address.

192.168.1.x is considered a class c address space, giving you only 254 total IP addresses.
192.168.x.x is a class b, giving you 65,536 IP addresses
wiki -> http://en.wikipedia.org/wiki/Classfu...k#Class_ranges


I went one step further and made my VPN 192.168.2.x so that i could have 254 VPN connections and my LAN is 192.168.1.x for 254 internal users.
This way there would be no way that there would ever be a conflict with the IP addresses because each connection have its own private network.

Problem is that the 192.168.1.x sub net wont know about the 192.168.2.x subnet with out a route statement because their subnet masks would both be 255.255.255.0 (or 192.168.1.0/24).

so what i did was change my router from the default 192.168.1.254 255.255.255.0 to be 192.168.1.254 255.255.0.0 so that it could see both 192.168.2.x and 192.168.1.x with out adding route statements...



sorry i cant explain it well. if you really want to know how the networking side works. you may want to grab a ccna or Network+ book from amazon.com
 
Old 02-06-2009, 06:26 AM   #8
ElLunchbox
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by watcher69b View Post
so what i did was change my router from the default 192.168.1.254 255.255.255.0 to be 192.168.1.254 255.255.0.0 so that it could see both 192.168.2.x and 192.168.1.x with out adding route statements...

This is the bit that I didn't do last time! I could connect to the VPN but then couldn't see anything on it, or do anything with it, so this will be why. Thanks for clearing that up. One last (n00bish) question... is there any reason that I couldn't use 192.168.4.x as a subnet? If i'm correct some routers (netgear i think) use 192.168.2.x as their default IP range so there could be conflict there... Thanks again for all your help.
 
Old 02-07-2009, 05:39 AM   #9
watcher69b
Member
 
Registered: Nov 2007
Location: /home/watcher69b
Distribution: RH, Fedora & CentOS
Posts: 539

Rep: Reputation: 39
Sure you can use 192.168.x...
(any numbers from 0-254)

I just picked 1 and 2 because they are sequential
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vpn pptp kristhor Linux - Networking 3 09-08-2008 01:40 PM
pptp vpn connetion from behind non vpn router paind Linux - Networking 0 07-18-2008 02:44 PM
LXer: Linux Configure point to point tunneling PPTP VPN client for Microsoft PPTP vpn server LXer Syndicated Linux News 0 06-13-2007 08:46 AM
Pptp Vpn coolb Linux - General 2 08-01-2006 07:42 AM
Vpn, Pptp???? ABL Linux - Networking 3 03-11-2005 04:54 PM


All times are GMT -5. The time now is 05:06 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration