X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/9fd9a6fba13ac55698990ecc7bcf293e817ff86e..cd2cec3e5aa5961634616339d6b29678ecd6ab43:/Docs/vpn/practical-vpns.xml?ds=inline
diff --git a/Docs/vpn/practical-vpns.xml b/Docs/vpn/practical-vpns.xml
index 8c4aaf5..9e5593b 100644
--- a/Docs/vpn/practical-vpns.xml
+++ b/Docs/vpn/practical-vpns.xml
@@ -30,22 +30,28 @@
- This document was compiled from the administrator's point of
+
+ This document was compiled from the administrator's point of
view, to explain what are VPNs, how they are deployed today
and to detail the necessary steps and tools to achieve and
create a fully working VPN solution, integrated with RADIUS
- systems for AAA.
+ systems for AAA.
+
- I will not dwell in this document on how to compile source
+
+ I will not dwell in this document on how to compile source
packages or kernel patching, and with the same tone I'm
- assuming the reader is an exprerienced Linux user.
+ assuming the reader is an exprerienced Linux user.
+
- VPNs have their share amount of gossip for being a very
+
+ VPNs have their share amount of gossip for being a very
complex thing, and in some cases this may be true as they tend
to be more security intenssive which require adding more and
more layers to the scheme. With this said, we'll take a look
at how fairly straight-forward it is to setup VPNs and
- maintain them with varius Open-Source tools.
+ maintain them with varius Open-Source tools.
+
@@ -53,16 +59,19 @@
Overview of VPNs and IPsecVirtual Private Networks
- The purpose of a VPN is to create a secure channel ontop of an
+
+ The purpose of a VPN is to create a secure channel ontop of an
un-secure medium, where a computer or a device are put in each
end-point in order to establish communication, each of these
- end-points are often reffered to as Point of Presense, or POP.
+ end-points are often reffered to as Point of Presense, or POP.
This kind of a communication allows the capability of creating
a Virtual Private Network, which is accesable over a medium
such as the Internet and thus, extend the physical boundaries
- of an existing local network.
+ of an existing local network.
+
- VPNs have three forms:
+
+ VPNs have three forms:
Site-To-Site VPNs
@@ -79,7 +88,7 @@
where a central VPN server is able to achieve multiple
- connections, often reffered to as RoadWarrior VPNs.
+ connections, often reffered to as RoadWarrior VPNs.
(This setup is very common among ISPs)
@@ -98,7 +107,8 @@
- shows a Site-To-Site VPN diagram.
+
+ shows a Site-To-Site VPN diagram.
- IP/VPNs are connections which are based upon IP tunnels. A
+
+ IP/VPNs are connections which are based upon IP tunnels. A
tunnel is a way to encapsulate an IP packet inside another IP
packet or some other type of packet. Why do we need
tunneling? A Virtual Private Network is identified by IANA's
private IP assignments and so such packet can not go beyond
- the uplink Internet interface.
+ the uplink Internet interface.
+
- shows the tunneling process.
+
+ shows the tunneling process.
- Several tunneling protocols are available for manifesting
+
+ Several tunneling protocols are available for manifesting
VPNs.
L2F
- Layer 2 Forwarding, an older implementation which assume
- position at the link layer of the OSI. It has no
- encryption capabilities and hence, deprecated.
+
+ Layer 2 Forwarding, an older implementation which
+ assume position at the link layer of the OSI. It has
+ no encryption capabilities and hence, deprecated.
+ L2TP
- Layer 2 Tunneling Protocol, still no encryption
- capabilities.
+
+ Layer 2 Tunneling Protocol, still no encryption
+ capabilities.
+ PPTP
- Point-to-Point Tunneling Protocol, and yet again, no
- encryption.
+
+ Point-to-Point Tunneling Protocol, and yet again, no
+ encryption.
+
- As seen, the requirement of encryption enhancement is
- urgent in order to assure authentication, data integrity and
- privacy. IPsec solves this by providing a suite of security
- measures implemented at layer 3.
+
+ As seen, the requirement of encryption enhancement is urgent
+ in order to assure authentication, data integrity and privacy.
+ IPsec solves this by providing a suite of security measures
+ implemented at layer 3.
+ IP Security Suite (IPsec)
- VPN Security is now appearing, this complex things. How so?
+
+ VPN Security is now appearing, this complex things. How so?
VPN tunnels by themselves are easily maintained by
- single-standalone tools like pppd, l2tpns, stunnel and others.
+ single-standalone tools like pppd, l2tpns, stunnel and others.
Involving security with VPNs though requires more:
@@ -183,12 +206,15 @@
- Keys are secrets being shared by two end-points to provide a
- secure mean of communication against a third-party connection
- from sniffing the actual data.
+
+ Keys are secrets being shared by two end-points to provide a
+ secure mean of communication against a third-party
+ connection from sniffing the actual data.
+
- Different ways to handle key management include RADIUS (Remote
+
+ Different ways to handle key management include RADIUS (Remote
Authentication Dial In User Service) systems which provide AAA
(Authentication, Authorization and Accounting). Another
solution is ISAKMP/Oackly - Internet Security Association and
@@ -210,16 +236,19 @@
- The more requirements you meet the more secure is the
- medium, once established. Let's review, something we have is
- like a certificate, it proves who we are. Something we know,
- is a key, a secret password which we were told in a whisper,
- and something we are is our-fingerprint which identifies
- ourselves from other individuals.
+
+ The more requirements you meet the more secure is the medium,
+ once established. Let's review, something we have is like a
+ certificate, it proves who we are. Something we know, is a
+ key, a secret password which we were told in a whisper, and
+ something we are is our-fingerprint which identifies ourselves
+ from other individuals.
+ IPsec in Depth
- IPsec consists of two main protocols, an Authentication
+
+ IPsec consists of two main protocols, an Authentication
Header and Encapsulation Security Payload, also known as AH
and ESP. Although it is not bound to these and can be
extended (and often is) to other standarts such as
@@ -251,14 +280,17 @@
- We'll be deploying an IKE daemon to handle the key
+
+ We'll be deploying an IKE daemon to handle the key
management, which uses the Diffie- Hellman cryptography
protocol in order to allow two parties to establish a
connection based upon a shared secret key that both parties
posess. (Authentication within IKE is handled by MD5
- hashing)
+ hashing)
+
- IKE is responsible for authentication of two IPsec parties,
+
+ IKE is responsible for authentication of two IPsec parties,
negotiation of keys for encryption algorithms and security
associations. This process is commonly regarded as two
phases:
@@ -267,77 +299,93 @@
Phase 1: IKE Security Association
- The IKE daemon authenticates against the peers in
+
+ The IKE daemon authenticates against the peers in
order to achieve a secure channel, according to the
- Diffie-Hellman key agreement.
+ Diffie-Hellman key agreement.
+ Phase 2: IKE IPsec Negotiation
- After achieving an authenticated channel, the
+
+ After achieving an authenticated channel, the
parties now negotiate a secure transform (the way to
encrypt and secure the medium) where the sender is
offering his/hers transform set after which the
receiver decides upon one. An IPsec session can now
- safely begin.
+ safely begin.
+
- Just to be clear, a Security Association is an agreed
+
+ Just to be clear, a Security Association is an agreed
relation between two parties which describes how they will
- use security services (from IPsec) to communicate.
+ use security services (from IPsec) to communicate.
+ IPsec Modes
- IPsec can operate in two different modes:
+
+ IPsec can operate in two different modes:
Transport mode
- takes place when two devices (like a station and a
+
+ takes place when two devices (like a station and a
gateway (now considered a host)) are establishing a
- connection which upon they both support IPsec.
+ connection which upon they both support IPsec.
+ Tunnel mode
- we require tunnel mode when we proxy IPsec
+
+ we require tunnel mode when we proxy IPsec
connetions between two stations behind the IPsec
gateway. For example, in a Site-to-Site VPN a
tunnel mode lives, since it exists in order to
provide the stations behind these gateways runing
the VPN/IPsec to communicate securely. In this
situation, both end-points are runing an IPsec
- software.
+ software.
+
- In definition, a tunnel mode IPsec is better secured than
+
+ In definition, a tunnel mode IPsec is better secured than
transport. Without going too deep into the ins-and-outs of
the technical side, transport mode doesn't encapsulate the
actual IP layer but only the tcp/udp (Transport layer of the
OSI) where-as a tunnel mode encapsulate both the Transport
- layer and the IP layer into a new IP packet.
-
- To summarize, we need VPNs for data-exchange methods and a
- set of IPsec tools for security reasons.
+ layer and the IP layer into a new IP packet.
+
+
+
+ To summarize, we need VPNs for data-exchange methods and a
+ set of IPsec tools for security reasons.
+ VPN Deployment
- I've assembled another diagram to view the actual VPN setup.
+
+ I've assembled another diagram to view the actual VPN setup.
gives a general description of
how the network will be layed out in real-world scenario.
@@ -351,14 +399,17 @@
- We notice that a single Linux box is acting as a Gateway and
- has all the services included with it. This is a bad idea from a
+
+ We notice that a single Linux box is acting as a Gateway and has
+ all the services included with it. This is a bad idea from a
security prespective but it's easy to just deploy the FreeRADIUS
and MySQL servers on another machine. Of course the L2TPns and
the rest of the IPsec tools suite would have to remain on the
- Gateway box (not necessarily the Firewall).
+ Gateway box (not necessarily the Firewall).
+
- attempts to explain the actual
+
+ attempts to explain the actual
process that the VPN takes and to detail the place that each of
that application-in-charge takes place.
@@ -376,7 +427,8 @@
RequirementsThe Toolbox
- Following is a description of the requirements you will
+
+ Following is a description of the requirements you will
have to meet:
@@ -384,11 +436,14 @@
A Linux boxpreferably a 2.4.27 kernel or higher.
- Debian is the chosen distribution which means we'll
- be using apt-get for installation, but I'll also focus
- on basic source tarballs installation.
+
+ Debian is the chosen distribution which means we'll
+ be using apt-get for installation, but I'll also
+ focus on basic source tarballs installation.
+
- Dependencies:
+
+ Dependencies:
@@ -412,8 +467,10 @@
- tun/tap interface compiled in the kernel or
- as a module
+
+ tun/tap interface compiled in the kernel or as
+ a module
+
@@ -446,9 +503,11 @@
Kernel Support
- Debian stock kernel 2.4.27 and up are ipsec compatible
+
+ Debian stock kernel 2.4.27 and up are ipsec compatible
although if you think otherwise check for the
- kernel-patch-openswan package.
+ kernel-patch-openswan package.
+
@@ -459,27 +518,34 @@
Installation
- L2TPns is a layer 2 tunneling protocol network server
+
+ L2TPns is a layer 2 tunneling protocol network server
(LNS). It supports up to 65535 concurrent sessions per
server/cluster plus ISP features such as rate limiting,
- walled garden, usage accounting, and more.
+ walled garden, usage accounting, and more.
+
- In a personal note - L2TPns is highly configurable for
+
+ In a personal note - L2TPns is highly configurable for
many cases, and extremely reliable for
- production/commerical use.
+ production/commerical use.
+ Step 1:
- Make sure you have libcli-1.8 development
- package installed:
- # apt-cache search libcli
+
+ Make sure you have libcli-1.8 development package
+ installed:
+
+# apt-cache search libcli
libcli-dev - emulates a cisco style telnet command-line interface (dev files)
libcli1 - emulates a cisco style telnet command-line interface
-# apt-get install libcli-dev
+# apt-get install libcli-dev
+
@@ -487,45 +553,57 @@ libcli1 - emulates a cisco style telnet command-line interface
Step 2:
- Download the source from
+
+ Download the source from
- SourceForge.
+ SourceForge.
+ Step 3:
- Build and install:
- make && make install
+
+ Build and install:
+ make && make install
+
- Alternately, you can skip these steps and simply
- apt-get install l2tpns.
+
+ Alternately, you can skip these steps and simply
+ apt-get install l2tpns.
+
- On RPM-based distributions, you should be able to make
+
+ On RPM-based distributions, you should be able to make
packages from the libcli and l2tpns source tarballs with
- rpmbuild -ta.
+ rpmbuild -ta.
+
- Once compiliation is done you will have l2tpns in
+
+ Once compiliation is done you will have l2tpns in
/usr/sbin/l2tpns, and all
configuration files can be found in
- /etc/l2tpns/.
+ /etc/l2tpns/.
+ Configuration
- The only configuration that L2TPns takes is
- centralized in the configuration file
+
+ The only configuration that L2TPns takes is centralized in
+ the configuration file
/etc/l2tpns/startup-config.
- set debug 2 # Debugging level
+
+set debug 2 # Debugging level
set log_file "/var/log/l2tpns" # Log file: comment out to use stderr, use
# "syslog:facility" for syslog
set pid_file "/var/run/l2tpns.pid" # Write pid to this file
@@ -544,13 +622,17 @@ set peer_address 192.168.0.1 # Gateway address
load plugin "sessionctl" # Drop/kill sessions
load plugin "autothrottle" # Throttle/snoop based on RADIUS
load plugin "throttlectl" # Control throttle/snoop with nsctl
-load plugin "snoopctl"
+load plugin "snoopctl"
+
- This is the trimmed down version of probably most of
- the common configuration and even some extra options.
+
+ This is the trimmed down version of probably most of
+ the common configuration and even some extra options.
+
- Important configuration options are highlited and you
+
+ Important configuration options are highlited and you
should adjust these to meet your network needs. We can
deploy all of the environment into one box which is of
course not a very good idea from a security point of view,
@@ -558,9 +640,11 @@ load plugin "snoopctl"
aliased IP addresses so once you've decided to move the
FreeRADIUS daemon to another computer on the LAN it will
be fairly easy and won't take too much configuration into
- it.
+ it.
+
- Next, we need to setup the IP pool that L2TPns will
+
+ Next, we need to setup the IP pool that L2TPns will
provide to each VPN client. The configuration file is
located at /etc/l2tpns/ip_pool and
should look like the following:
@@ -568,32 +652,38 @@ load plugin "snoopctl"
- Of course you can change this pool to anything else
+
+ Of course you can change this pool to anything else
(IANA IPs assigned for private internets only) just make
sure it is not conflicting with your current LAN network
addresses. This means that if you've assigned addresses
of 192.168.0.1 and 192.168.0.2 to your LAN boxes you
can't have a pool of 192.168.0.1/24 defined since L2TPns
will try to route those addresses from the tun device,
- which is needless to say a bad idea...
+ which is needless to say a bad idea...
+ Next up, creating the access-list for L2TPns.
- Add a username and password into
+
+ Add a username and password into
/etc/l2tpns/users:
admin:12345
The password may either be plain-text as above, or
encrypted with MD5 or DES (to distinguish DES from
plain-text passwords, prefix the value with
- {crypt}).
+ {crypt}).
+
- L2TPns utilizes a terminal connection on port 23 which you
+
+ L2TPns utilizes a terminal connection on port 23 which you
would feel very comfortable in if you have worked with
routers and switches devices before. The terminal
provides control over the ppp termination which is why
- we've created an account to log on to.
+ we've created an account to log on to.
+
@@ -601,65 +691,86 @@ load plugin "snoopctl"
IPsecInstallation
- User-space IPsec tools for various IPsec implementations
+
+ User-space IPsec tools for various IPsec implementations
exist for linux, among them is the port of KAME's
libipsec, setkey, and racoon. Others are the OpenSWAN (a
- successor to the FreeSWAN project).
+ successor to the FreeSWAN project).
+
- Getting IPsec installed is fairly easy with Debian:
+
+ Getting IPsec installed is fairly easy with Debian:
# apt-get install openswan
- The OpenSWAN project provides packages for RPM-based
- distributions.
+
+ The OpenSWAN project provides packages for RPM-based
+ distributions.
+
- Alternately, you may download the
+
+ Alternately, you may download the
source
from the OpenSWAN project:
-
- # tar xvzf openswan-2.4.4.tar.gz
+
+# tar xvzf openswan-2.4.4.tar.gz
# cd openswan-2.4.4
-# ./configure && make && make install
+# ./configure && make && make install
+Configuration
- OpenSWAN acts as the IKE daemon (remember IKE? it's
- job is to authenticate between the two peers and negotiate
- a secure medium). We will be setting up the IKE daemon as
- a RoadWarrior configuration, a term for remote access
- VPNs.
-
- We desire this approach for compatibilty because after
- our VPN solution will be complete any user from a Windows
+
+ OpenSWAN acts as the IKE daemon (remember IKE? it's job
+ is to authenticate between the two peers and negotiate a
+ secure medium). We will be setting up the IKE daemon as a
+ RoadWarrior configuration, a term for remote access
+ VPNs.
+
+
+
+ We desire this approach for compatibilty because after our
+ VPN solution will be complete any user from a Windows
machine will be easily ready to connect without any 3rd
- party applications, same for Linux.
-
- Configuration files are placed in
+ party applications, same for Linux.
+
+
+
+ Configuration files are placed in
/etc/ipsec.d/,
/etc/ipsec.conf and
- /etc/ipsec.secrets.
-
- Let's start by choosing the remote client and it's PSK
+ /etc/ipsec.secrets.
+
+
+
+ Let's start by choosing the remote client and it's PSK
(Private Shared Key) /etc/ipsec.secrets:
- hostname_or_ipaddress %any : PSK "mysecretkeyisverylong"
+
+hostname_or_ipaddress %any : PSK "mysecretkeyisverylong"
+
- This is an IP/key pair. The IP or FQDN defines the
- local peer (like a SOHO branch), then the remote host.
- Here we defined %any for all hosts, though it's possible
- to define only a specific IP. At last, we define the key
- associated with it.
+
+ This is an IP/key pair. The IP or FQDN defines the local
+ peer (like a SOHO branch), then the remote host. Here we
+ defined %any for all hosts, though it's possible to define
+ only a specific IP. At last, we define the key associated
+ with it.
+
- A better way to create a key is to utilize /dev/random
- for creating a unique key.
+
+ A better way to create a key is to utilize /dev/random for
+ creating a unique key.
# dd if=/dev/random count=16 bs=1 2>/dev/null | xxd -ps
- Next, let's prepare the configuration file
+
+ Next, let's prepare the configuration file
/etc/ipsec.conf:
- version 2.0
+
+version 2.0
config setup
nat_traversal=yes
@@ -674,47 +785,58 @@ conn l2tp
rightprotoport=17/%any
auto=add
-include /etc/ipsec.d/examples/no_oe.conf
+include /etc/ipsec.d/examples/no_oe.conf
+
- In this file we have first defined version 2 which is
- a must, then enabled NAT Traversal. To understand the
+
+ In this file we have first defined version 2 which is a
+ must, then enabled NAT Traversal. To understand the
importance of this feature think of the following
scenario: A remote user attempts to connect while he's
- behind a router and there-fore NATed. The router has to
- de-encapsulate the packet, change things and then build
- it up again and send it. IPsec doesn't like other people
+ behind a router and therefore NATed. The router has to
+ de-encapsulate the packet, change things and then build it
+ up again and send it. IPsec doesn't like other people
messing with it's packet. That's why we solve this issue
- with NAT Traversal.
+ with NAT Traversal.
+
- Next up we configure authentication type (certificates,
+
+ Next up we configure authentication type (certificates,
psk, rsa keys, etc) then the left and right peers. The
default mode OpenSWAN takes is tunnel unless told
otherwise. I won't go into in-depth explanation of every
method, you can take a quick look at
/etc/ipsec.d/examples for more
explanation and other variations of working with RSA keys,
- Certificates, host-to-host, and more.
+ Certificates, host-to-host, and more.
+
- In summary:
+
+ In summary:
- We've configured an almost complete IPsec VPN
- setup.
+
+ We've configured an almost complete IPsec VPN setup.
+
- We've installed and configured a VPN server
- (L2TPns) and our IPsec security suite.
+
+ We've installed and configured a VPN server (L2TPns)
+ and our IPsec security suite.
+
- To control both of them we use:
+
+ To control both of them we use:
/etc/init.d/l2tpns and
/etc/init.d/racoon (location
of start-up scripts may vary on non-Debian systems,
or if you've installed from
- source).
+ source).
+
@@ -723,160 +845,211 @@ include /etc/ipsec.d/examples/no_oe.conf
FreeRADIUS
- The VPN setup needs to authenticate against something,
- that is the users database which we chose to be a FreeRADIUS
- server backed with a MySQL database.
+
+ The VPN setup needs to authenticate against something, that
+ is the users database which we chose to be a FreeRADIUS
+ server backed with a MySQL database.
+ Installation
- FreeRADIUS is the premiere open source RADIUS
- server. While detailed statistics are not available, we
- believe that FreeRADIUS is well within the top 5 RADIUS
- servers world-wide, in terms of the number of people who
- use it daily for authentication. It scales from embedded
- systems with small amounts of memory, to systems with
- millions of users. It is fast, flexible, configurable,
- and supports more authentication protocols than many
- commercial servers.
+
+ FreeRADIUS is the premiere open source RADIUS server.
+ While detailed statistics are not available, we believe
+ that FreeRADIUS is well within the top 5 RADIUS servers
+ world-wide, in terms of the number of people who use it
+ daily for authentication. It scales from embedded
+ systems with small amounts of memory, to systems with
+ millions of users. It is fast, flexible, configurable,
+ and supports more authentication protocols than many
+ commercial servers.
+
- Installing on Debian:
+
+ Installing on Debian:
# apt-get install freeradius freeradius-mysql
- From source: Download the latest freeradius package from
+
+ From source: Download the latest freeradius package from
freeradius.org
- # tar xvzf freeradius.tar.gz
+
+# tar xvzf freeradius.tar.gz
# cd freeradius
-# ./configure && make && make install
+# ./configure && make && make install
+Configuration
- This will appear a bit complex but it isn't, it's just
- a lot of configuration.
+
+ This will appear a bit complex but it isn't, it's just a
+ lot of configuration.
+
- Following are the configurations you need to have in your
- /etc/freeradius/ files.
+
+ Following are the configurations you need to have in your
+ /etc/freeradius/ files.
+
- In this section I will not give you a dump of the
- configuration since they are very long and mostly default.
- I'll just post which changes to make.
+
+ In this section I will not give you a dump of the
+ configuration since they are very long and mostly default.
+ I'll just post which changes to make.
+
- We haven't yet configured MySQL, but it'll come
- afterwards, don't worry.
+
+ We haven't yet configured MySQL, but it'll come
+ afterwards, don't worry.
+
- Make the following changes to the file
+
+ Make the following changes to the file
/etc/freeradius/sql.conf:
- server = "192.168.0.1"
+
+server = "192.168.0.1"
login = "radius"
password = "12345678"
- Add the following to the file
+
+ Add the following to the file
/etc/freeradius/clients.conf:
- client 192.168.0.1 {
+
+client 192.168.0.1 {
secret = my_secret
shortname = localhost
nastype = other
-}
+}
+
- Don't confuse the secret directive there with IPsec.
+
+ Don't confuse the secret directive there with IPsec.
RADIUS server are using secret keys also to identify their
allowed NAS (Network Access Servers), these are the
- clients that talk to the RADIUS server.
+ clients that talk to the RADIUS server.
+
- Also, change the client 127.0.0.1 {}
+
+ Also, change the client 127.0.0.1 {}
directive to hold the secret "my_secret" like we
- configured for 192.168.0.1 to avoid conflicts.
+ configured for 192.168.0.1 to avoid conflicts.
+
- Uncomment the sql directive in the
+
+ Uncomment the sql directive in the
authorize, accounting, and
session sections of
- /etc/freeradius/radiusd.conf.
+ /etc/freeradius/radiusd.conf.
+
- Now for populating FreeRADIUS with MySQL. If you
- don't know or haven't set root password for MySQL you can
- do it now with:
+
+ Now for populating FreeRADIUS with MySQL. If you don't
+ know or haven't set root password for MySQL you can do it
+ now with:
# mysqladmin -u root password password_here
Then add the following to
/root/.my.cnf:
- [mysqladmin]
+
+[mysqladmin]
user = root
-password = password_here
+password = password_here
+
- Create the radius database, using the
+
+ Create the radius database, using the
schema given in
/usr/share/doc/freeradius/examples/db_mysql.sql.gz
- .
+ .
+
- It may be necessary to modify the column definition
- of id in the nas table,
- removing DEFAULT '0' such that the
- definition reads:
+
+ It may be necessary to modify the column definition of
+ id in the nas table, removing
+ DEFAULT '0' such that the definition reads:
id int(10) NOT NULL auto_increment,
- # mysqladmin create radius
+
+# mysqladmin create radius
# mysql radius
mysql> source db_mysql.sql
-mysql> GRANT ALL ON * TO 'radius'@'localhost' IDENTIFIED BY 'radius_password';
-
- All the configuration is now done. Let's add a user
- to our VPN database.
- # mysql radius
-mysql> INSERT INTO radcheck values (0, "test", "User-Password", "==", "1234");
+mysql> GRANT ALL ON * TO 'radius'@'localhost' IDENTIFIED BY 'radius_password';
+
+
+ All the configuration is now done. Let's add a user to
+ our VPN database.
+
+# mysql radius
+mysql> INSERT INTO radcheck values (0, "test", "User-Password", "==", "1234");
+
- We have now created a user in the database of username
- test and password 1234.
+
+ We have now created a user in the database of username
+ test and password 1234.
+
- Testing the RADIUS setup is simple using the radtest
+
+ Testing the RADIUS setup is simple using the radtest
utility provided with it.
- # radtest
+
+# radtest
Usage: radtest user passwd radius-server[:port] nas-port-number secret [ppphint] [nasname]
-# radtest test 1234 192.168.0.1 1812 my_secret
+# radtest test 1234 192.168.0.1 1812 my_secret
+
- radtest sends an Access-Request to the RADIUS server
- and expects an Access-Accept back from it. If you're not
+
+ radtest sends an Access-Request to the RADIUS server and
+ expects an Access-Accept back from it. If you're not
getting an Access-Accept from the RADIUS you're advised to
check the configuration again and see what you might have
- missed.
+ missed.
+ Firewall Configuration
- We need to apply a few things to iptables configuration
- and kernel networking.
+
+ We need to apply a few things to iptables configuration and
+ kernel networking.
+
- First off, we need to accept VPN-specific packets
- through the firewall. Of course you will have to adjust the
- rules to fits you needs, in this case, ppp0 is the Internet
+
+ First off, we need to accept VPN-specific packets through
+ the firewall. Of course you will have to adjust the rules
+ to fits you needs, in this case, ppp0 is the Internet
interface.
- # iptables --append INPUT --in-interface ppp0 -p udp --dport 1701 -j ACCEPT
+
+# iptables --append INPUT --in-interface ppp0 -p udp --dport 1701 -j ACCEPT
# iptables --append INPUT --in-interface ppp0 -p udp --dport 500 -j ACCEPT
# iptables --append INPUT --in-interface ppp0 -p udp --dport 4500 -j ACCEPT
-# iptables --append INPUT --in-interface ppp0 -p 50 -j ACCEPT
+# iptables --append INPUT --in-interface ppp0 -p 50 -j ACCEPT
+
- If you haven't setup your Linux box as a gateway yet
- then you have to allow forwarding/masqing for the boxes on
+
+ If you haven't setup your Linux box as a gateway yet then
+ you have to allow forwarding/masqing for the boxes on
the LAN (and therefore for the VPN clients):
- # iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
+
+# iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
# iptables --append FORWARD --in-interface eth0 -j ACCEPT
-# echo 1 > /proc/sys/net/ipv4/ip_forward
+# echo 1 > /proc/sys/net/ipv4/ip_forward
+