Chapter 9. VPN: 9.1. Overview
Chapter 9. VPN: 9.1. Overview
VPN
This chapter describes VPN usage with NetDefendOS.
9.1. Overview
9.1.1. The Need for VPNs
Most networks are connected to each other through the Internet. Business increasingly utilizes the
Internet since it offers efficient and inexpensive communication. A means is needed for data to
travel across the Internet to its intended recipient without another party being able to read or alter it.
It is equally important that the recipient can verify that no one is falsifying information, in other
words, pretending to be someone else. Virtual Private Networks (VPNs) meet this need, providing a
highly cost effective means of establishing secure links so that data can be exchanged in a secure
manner.
Authentication and Integrity Proof for the recipient that the communication was actually
sent by the expected sender, and that the data has not been
modified in transit. This is accomplished by authentication,
often by use of cryptographic keyed hashes.
Non-repudiation Proof that the sender actually sent the data; the sender cannot
later deny having sent it. Non-repudiation is usually a
side-effect of authentication.
VPNs are normally only concerned with confidentiality and authentication. Non-repudiation is
normally not handled at the network level but rather on a transaction (document-by-document)
basis.
In designing a VPN there are many non-obvious issues that need to be addressed. This includes:
229
9.1.4. Key Distribution Chapter 9. VPN
• Restricting access through the VPN to needed services only, since mobile computers are
vulnerable
• Creating DMZs for services that need to be shared with other companies through VPNs
A common misconception is that VPN-connections are equivalents to the internal network from a
security standpoint and that they can be connected directly to it with no further precautions. It is
important to remember that although the VPN-connection itself may be secure, the total level of
security is only as high as the security of the tunnel endpoints.
It is becoming increasingly common for users on the move to connect directly to their company's
network via VPN from their laptops. However, the laptop itself is often not protected. In other
words, an intruder can gain access to the protected network through an unprotected laptop and
already-opened VPN connections.
A VPN connection should never be regarded as an integral part of a protected network. The VPN
firewall should instead be located in a special DMZ or outside a firewall dedicated to this task. By
doing this, you can restrict which services can be accessed via VPN and modem and ensure that
these services are well protected against intruders. In instances where the firewall features an
integrated VPN feature, it is usually possible to dictate the types of communication permitted. The
NetDefendOS VPN module features such a facility.
• How will keys be distributed? Email is not good. Phone conversations might be secure enough.
• How many different keys should be used? One key per user? One per group of users? One per
LAN-to-LAN connection? One key for all users and one key for all LAN-to-LAN connections?
It is probably better using more keys than is necessary today since it will be easier to adjust
access per user (group) in the future.
• Should the keys be changed? If so, how often? In cases where keys are shared by multiple users,
you may want to consider overlapping schemes, so that the old keys work for a short period of
time when new keys have been issued.
• What happens when an employee in possession of a key leaves the company? If several users are
using the same key, it should be changed.
• In cases where the key is not directly programmed into a network unit, such as a VPN firewall,
how should the key be stored? On a floppy? As a pass phrase to memorize? On a smart card? If
it is a physical token, how should it be handled?
230
9.2. VPN Quickstart Guide Chapter 9. VPN
It outlines the individual steps in setting up VPNs for the most common VPN scenarios. These are:
2. Optionally create a new IKE Proposal List object and/or an IPsec Proposal List object if the
default list settings are not satisfactory. This will depend on the capabilities of the device at the
other side of the tunnel.
• The remote VPN gateway which is the IP address of the network device at the other end of
the tunnel (let's call this object remote_gw).
• The remote network which lies behind the remote VPN gateway (let's call this object
remote_net).
• The local network behind the D-Link Firewall which will communicate across the tunnel.
Here we will assume that this is the pre-defined address lannet and this network is attached
to the NetDefendOS lan interface.
4. Create an IPsec Tunnel object (let's call this object ipsec_tunnel). Specify the following tunnel
parameters:
• For Authentication select the Pre-shared Key object defined in step (1) above.
The IPsec Tunnel object can be treated exactly like any NetDefendOS Interface object in later
steps.
• An Allow rule for outbound traffic that has the previously defined ipsec_tunnel object as
231
9.2.2. IPsec Roaming Clients with Chapter 9. VPN
Pre-shared Keys
the Destination Interface. The rule's Destination Network is the remote network
remote_net.
• An Allow rule for inbound traffic that has the previously defined ipsec_tunnel object as the
Source Interface. The Source Network is remote_net.
Action Src Interface Src Network Dest Interface Dest Network Service
Allow lan lannet ipsec_tunnel remote_net All
Allow ipsec_tunnel remote_net lan lannet All
The Service used in these rules is All but it could be a predefined service.
6. Define a new NetDefendOS Route which specifies that the VPN Tunnel ipsec_tunnel is the
Interface to use for routing packets bound for the remote network at the other end of the tunnel.
• B. The IP address of clients is not known beforehand and must be handed out by NetDefendOS
as they connect.
The IP addresses may be known beforehand and pre-allocated to the roaming clients before they
connect. The client's IP address will be will be manually input into the VPN client software.
1. Set up user authentication. XAuth user authentication is not required with IPsec roaming clients
but is recommended (this step could initially be left out to simplify setup). The authentication
source can be one of the following:
An internal user database is easier to set up and is assumed here. Changing this to an external
server is simple to do later.
• Add individual users to TrustedUsers. This should consist of at least a username and
password combination.
The Group string for a user can be specified if its group's access is to be restricted to
certain source networks. Group can be specified (with the same text string) in the
232
9.2.2. IPsec Roaming Clients with Chapter 9. VPN
Pre-shared Keys
• Create a new User Authentication Rule with the Authentication Source set to
TrustedUsers. The other parameters for the rule are:
2. The IPsec Tunnel object ipsec_tunnel should have the following parameters:
• Set the IKE and IPsec proposal lists to match the capabilities of the clients.
• No routes can be predefined so the option Dynamically add route to the remote network
when tunnel established should be enabled for the tunnel object.
• Enable the option Require IKE XAuth user authentication for inbound IPsec tunnels.
This will enable a search for the first matching XAUTH rule in the authentication rules.
Action Src Interface Src Network Dest Interface Dest Network Service
Allow ipsec_tunnel all-nets lan lannet All
Once an Allow rule permits the connection to be set up, bidirectional traffic flow is allowed which is
why only one rule is used here. Instead of all-nets being used in the above, a more secure defined IP
object could be used which specifies the exact range of the pre-allocated IP addresses.
If the client IP addresses are not known then they must be handed out by NetDefendOS. To do this
the above must be modified with the following:
• Create a Config Mode Pool object (there can only be one associated with a NetDefendOS
installation) and in it specify the address range.
• Enable the IKE Config Mode option in the IPsec Tunnel object ipsec_tunnel.
• Create an IP Pool object and in it specify the DHCP server to use. The DHCP server can be
specified as a simple IP address or alternatively as being accessible on a specific interface.
If an internal DHCP server is to be used then specify the loopback address 127.0.0.1 as the
DHCP server IP address.
233
9.2.3. IPsec Roaming Clients with Chapter 9. VPN
Certificates
• Create a Config Mode Pool object (there can only be one associated with a NetDefendOS
installation) and associate with it the IP Pool object defined in the previous step.
• Enable the IKE Config Mode option in the IPsec Tunnel object ipsec_tunnel.
In both cases (A) and (B) above the IPsec client will need to configured with the URL of the D-Link
Firewall as well as the pre-shared key.
2. When setting up the IPsec Tunnel object, specify the certificates to use under Authentication.
This is done by:
3. The IPsec client software will need to appropriately configured with the certificates and remote
IP addresses.
The step to set up user authentication is optional since this is additional security to certificates.
1. Create an IP object (let's call it l2tp_pool) which defines the range of IP addresses which can be
handed out to clients. The range chosen could be of two types:
• A range taken from the internal network to which clients will connect. If the internal
network is 192.168.0.0/24 then we might use the address range 192.168.0.10 to
192.168.0.20. The danger here is that an IP address might be accidentally used on the
internal network and handed out to a client.
• Use a new address range that is totally different to any internal network. This prevents any
chance of an address in the range also being used on the internal network.
• ip_ext which is the external public IP address through which clients connect (let's assume
this is on the ext interface).
• ip_int which is the internal IP address of the interface to which the internal network is
connected (let's call this interface int).
234
9.2.4. L2TP Roaming Clients with Chapter 9. VPN
Pre-Shared Keys
4. Define an IPsec Tunnel object (let's call this object ipsec_tunnel) with the following
parameters:
• Set Local Network to ip_ext (specify all-nets instead if NetDefendOS is behind a NATing
device).
• For Authentication select the Pre-shared Key object defined in the first step.
• Enable the routing option Dynamically add route to the remote network when tunnel
established.
5. Define an PPTP/L2TP Server object (let's call this object l2tp_tunnel) with the following
parameters:
• Select the Microsoft Point-to-Point Encryption allowed. Since IPsec encryption is used
this can be set to be None only, otherwise double encryption will degrade throughput.
• Enable Proxy ARP on the int interface to which the internal network is connected.
• Make the interface a member of a specific routing table so that routes are automatically
added to that table. Normally the main table is selected.
• Add individual users to TrustedUsers. This should consist of at least a username and
password combination.
The Group string for a user can also be specified. This is explained in the same step in the
IPsec Roaming Clients section above.
7. To allow traffic through the L2TP tunnel the following rules should be defined in the IP rule
set:
235
9.2.5. L2TP Roaming Clients with Chapter 9. VPN
Certificates
Action Src Interface Src Network Dest Interface Dest Network Service
Allow l2tp_tunnel l2tp_pool any int_net All
NAT ipsec_tunnel l2tp_pool ext all-nets All
The second rule would be included to allow clients to surf the Internet via the ext interface on the
D-Link Firewall. The client will be allocated a private internal IP address which must be NATed if
connections are then made out to the public Internet via the D-Link Firewall.
8. Set up the client. Assuming Windows XP, the Create new connection option in Network
Connections should be selected to start the New Connection Wizard. The key information to
enter in this wizard is: the resolvable URL of the D-Link Firewall or alternatively its ip_ext IP
address.
Then choose Network > Properties. In the dialog that opens choose the L2TP Tunnel and
select Properties. In the new dialog that opens select the Networking tab and choose Force to
L2TP. Now go back to the L2TP Tunnel properties, select the Security tab and click on the
IPsec Settings button. Now enter the pre-shared key.
2. When setting up the IPsec Tunnel object, specify the certificates to use under Authentication.
This is done by:
3. If using the Windows XP L2TP client, the appropriate certificates need to be imported into
Windows before setting up the connection with the New Connection Wizard.
The step to set up user authentication is optional since this is additional security to certificates.
A major secondary disadvantage is not being able to NAT PPTP connections through a tunnel so
multiple clients can use a single connection to the D-Link Firewall. If NATing is tried then only the
first client that tries to connect will succeed.
• A pptp_pool IP object which is the range of internal IP addresses that will be handed out
from an internal network.
236
9.2.7. VPN Troubleshooting Chapter 9. VPN
• An int_net object which is the internal network from which the addresses come.
• An ip_int object which is the internal IP address of the interface connected to the internal
network. let's assume this interface is int.
• An ip_ext object which is the external public address which clients will connect to (let's
assume this is on the ext interface).
2. Define a PPTP/L2TP object (let's call it pptp_tunnel) with the following parameters:
• As in L2TP, enable the insertion of new routes automatically into the main routing table.
Action Src Interface Src Network Dest Interface Dest Network Service
Allow pptp_tunnel pptp_pool any int_net All
NAT pptp_tunnel pptp_pool ext all-nets All
As described for L2TP, the NAT rule lets the clients access the public Internet via the D-Link
Firewall.
5. Set up the client. For Windows XP, the procedure is exactly as described for L2TP above but
without entering the pre-shared key.
• Check that all pre-shared keys and usernames/passwords are correctly entered.
237
9.2.7. VPN Troubleshooting Chapter 9. VPN
• If certificates have been used, check that the correct certificates have been used and that they
haven't expired.
• Use ICMP Ping to confirm that the tunnel is working. With roaming clients this is best done by
Pinging the internal IP address of the local network interface on the D-Link Firewall from a
client (in LAN to LAN setups pinging could be done in any direction). If NetDefendOS is to
able to respond to a Ping then the following rule must exist in the IP rule set.
Action Src Interface Src Network Dest Interface Dest Network Service
Allow vpn_tunnel all-nets core all-nets ICMP
• Ensure that another IPsec Tunnel definition isn't preventing the correct definition being
reached. The tunnel list is scanned from top to bottom and a tunnel in a higher position with the
Remote Network set to all-nets and the Remote Gateway set to none could prevent the correct
tunnel being reached. The symptom of this problem is often an Incorrect Pre-shared Key
message.
• Try and avoid duplication of IP addresses between the remote network being accessed by a
client and the internal network to which a roaming client belongs.
If a roaming client becomes temporarily part of a network such as a Wi-Fi network at an airport,
the client will get an IP address from the Wi-Fi network's DHCP server. If that IP also belongs
to the network behind the D-Link Firewall accessible through a tunnel, then Windows will still
continue to assume that the IP address is to be found on the client's local network. Windows
therefore won't correctly route packets bound for the remote network through the tunnel but
instead route them to the local network.
The solution to this problem of local/remote IP address duplication is to create a new route in the
client's Windows routing table that explicitly routes the IP address to the tunnel.
• If roaming client user authentication is not asking the users for their username/password then
ensure that the following advanced settings are enabled:
These settings should be enabled by default and they ensure that user authentication traffic
between NetDefendOS and the client can bypass the IP rule set. If the appropriate setting is not
enabled then an explicit rule needs to be added to the IP rule set to allow the authentication
traffic to pass between roaming clients and NetDefendOS. This rule will have a destination
interface of core.
ipsecstat can be used to show that IPsec tunnels have correctly established. A representative
example of output is:
> ipsecstat
--- IPsec SAs:
Displaying one line per SA-bundle
238
9.2.7. VPN Troubleshooting Chapter 9. VPN
> ipsecstat -u -v
A common problem with setting up IPsec is a proposal list that is unacceptable to the device at the
other end of the tunnel. The ikesnoop command can show up problems with the proposal list by
showing the details of the negotiations that take place.
ikesnoop verbose
Once this command is issued, an ICMP ping can be then sent to the D-Link Firewall from the other
end of the tunnel. This will cause ikesnoop verbose to output details of the tunnel setup.
Incompatibilities in the proposal lists for IKE and/or IPsec can often cause problems which show up
in this output.
If there are multiple tunnels in a setup or mutiple clients on a single tunnel then the output from
ikesnoop verbose can be overwhelming. It is therefore better to specify that the output come from a
single tunnel by specifying the client's IP address:
This happens when a route is established in the main routing table which routes any traffic for
all-nets through the VPN tunnel. If the management interface is not reached by the VPN tunnel then
the administrator needs to create a specific route that routes management interface traffic leaving the
D-Link Firewall back to the management subnet.
When any VPN tunnel is defined, an all-nets route is automatically defined in the routing table so
the administrator should always set up a specific route for the management interface to be correctly
routed.
239
9.3. IPsec Chapter 9. VPN
9.3. IPsec
9.3.1. Overview
Internet Protocol Security (IPsec), is a set of protocols defined by the Internet Engineering Task
Force (IETF) to provide IP security at the network layer. An IPsec based VPN is made up by two
parts:
The first part, IKE, is the initial negotiation phase, where the two VPN endpoints agree on which
methods will be used to provide security for the underlying IP traffic. Furthermore, IKE is used to
manage connections, by defining a set of Security Associations, SAs, for each connection. SAs are
unidirectional, so there are usually at least two for each IPsec connection.
The second part is the actual IP data being transferred, using the encryption and authentication
methods agreed upon in the IKE negotiation. This can be accomplished in a number of ways; by
using IPsec protocols ESP, AH, or a combination of both.
Encrypting and authenticating data is fairly straightforward, the only things needed are encryption
and authentication algorithms, and the keys used with them. The Internet Key Exchange (IKE)
protocol, IKE, is used as a method of distributing these "session keys", as well as providing a way
for the VPN endpoints to agree on how the data should be protected.
IKE keeps track of connections by assigning a set of Security Associations, SAs, to each connection.
An SA describes all parameters associated with a particular connection, such as the IPsec protocol
used (ESP/AH/both) as well as the session keys used to encrypt/decrypt and/or authenticate/verify
the transmitted data. An SA is, by nature, unidirectional, thus the need for more than one SA per
connection. In most cases, where only one of ESP or AH is used, two SAs will be created for each
connection, one describing the incoming traffic, and the other the outgoing. In cases where ESP and
AH are used in conjunction, four SAs will be created.
240
9.3.2. Internet Key Exchange (IKE) Chapter 9. VPN
IKE Negotiation
The process of negotiating session parameters consists of a number of phases and modes. These are
described in detail in the below sections.
IKE Phase-1
• Negotiate how IKE should be protected
IKE Phase-2
• Negotiate how IPsec should be protected
• Derive some fresh keying material from the key exchange in phase-1, to
provide session keys to be used in the encryption and authentication of the
VPN data flow
Both the IKE and the IPsec connections have limited lifetimes, described both in terms of time
(seconds), and data (kilobytes). These lifetimes prevent a connection from being used too long,
which is desirable from a crypto-analysis perspective.
The IPsec lifetime must be shorter than the IKE lifetime. The difference between the two must be a
minimum of 5 minutes. This allows for the IPsec connection to be re-keyed simply by performing
another phase-2 negotiation. There is no need to do another phase-1 negotiation until the IKE
lifetime has expired.
IKE Proposals
An IKE proposal is a suggestion of how to protect data. The VPN device initiating an IPsec
connection, the initiator, will send a list of proposals, a proposal-list, suggesting different methods
of how to protect the connection.
The connection being negotiated can be either an IPsec connection protecting the data flow through
the VPN, or it can be an IKE connection, protecting the IKE negotiation itself.
The responding VPN device, upon receiving this proposal-list, will choose the most suitable
proposal according to its own security policy, and respond by specifying which one of the proposal
it has chosen.
If no acceptable proposal can be found, it will respond by saying that no proposal could be accepted,
and possibly provide a reason why.
The proposals contain all parameters needed, such as algorithms used to encrypt and authenticate
the data, and other parameters as described in section IKE Parameters.
An IKE negotiation is performed in two phases. The first phase, phase-1, is used to authenticate the
two VPN firewalls or VPN Clients to each other, by confirming that the remote device has a
matching Pre-Shared Key.
However, since we do not want to publish to much of the negotiation in plaintext, we first agree
upon a way of protecting the rest of the IKE negotiation. This is done, as described in the previous
section, by the initiator sending a proposal-list to the responder. When this has been done, and the
responder accepted one of the proposals, we try to authenticate the other end of the VPN to make
sure it is who we think it is, as well as proving to the remote device; that we are who we claim to be.
A technique known as a Diffie Hellman Key Exchange is used to intially agree a shared secret
between the two parties in the negotiation and to derive keys for encryption.
241
9.3.2. Internet Key Exchange (IKE) Chapter 9. VPN
Authentication can be accomplished through Pre-Shared Keys, certificates or public key encryption.
Pre-Shared Keys is the most common authentication method today. PSK and certificates are
supported by the NetDefendOS VPN module.
In phase two, another negotiation is performed, detailing the parameters for the IPsec connection.
In phase-2 we will also extract new keying material from the Diffie-Hellman key exchange in
phase-1, to provide session keys to use in protecting the VPN data flow.
If PFS, Perfect Forwarding Secrecy, is used, a new Diffie-Hellman exchange is performed for each
phase-2 negotiation. While this is slower, it makes sure that no keys are dependent on any other
previously used keys; no keys are extracted from the same initial keying material. This is to make
sure that, in the unlikely event that some key was compromised, no subsequent keys can be derived.
Once the phase-2 negotiation is finished, the VPN connection is established and ready for use.
IKE Parameters
When installing two D-Link Firewalls as VPN endpoints, this process is reduced to comparing fields
in two identical dialog boxes. However, it is not quite as easy when equipment from different
vendors is involved.
Endpoint Identification The Local ID is a piece of data representing the identity of the
VPN gateway. With Pre-Shared Keys this is a unique piece of
data uniquely identifying the tunnel endpoint.
Local and Remote These are the subnets or hosts between which IP traffic will
Networks/Hosts be protected by the VPN. In a LAN-to-LAN connection, these
will be the network addresses of the respective LANs.
Tunnel / Transport Mode IPsec can be used in two modes, tunnel or transport.
242
9.3.2. Internet Key Exchange (IKE) Chapter 9. VPN
configurations.
Main/Aggressive Mode The IKE negotiation has two modes of operation, main mode
and aggressive mode.
IPsec Protocols The IPsec protocols describe how the data will be processed.
The two protocols to choose from are AH, Authentication
Header, and ESP, Encapsulating Security Payload.
Note
D-Link Firewalls do not support AH.
IKE Encryption This specifies the encryption algorithm used in the IKE
negotiation, and depending on the algorithm, the size of the
encryption key used.
• AES
• Blowfish
• Twofish
243
9.3.2. Internet Key Exchange (IKE) Chapter 9. VPN
• Cast128
• 3DES
• DES
IKE Authentication This specifies the authentication algorithms used in the IKE
negotiation phase.
• SHA1
• MD5
IKE DH (Diffie-Hellman) Group This specifies the Diffie-Hellman group to use when doing
key exchanges in IKE.
• DH group 1 (768-bit)
• DH group 2 (1024-bit)
• DH group 5 (1536-bit)
PFS can be used in two modes, the first is PFS on keys, where
a new key exchange will be performed in every phase-2
negotiation. The other type is PFS on identities, where the
identities are also protected, by deleting the phase-1 SA every
time a phase-2 negotiation has been finished, making sure no
more than one phase-2 negotiation is encrypted using the
same key.
244
9.3.3. IKE Authentication Chapter 9. VPN
PFS Group This specifies the PFS group to use with PFS.
• 1 modp 768-bit
• 2 modp 1024-bit
• 5 modp 1536-bit
IPsec DH Group This is a Diffie-Hellman group much like the one for IKE.
However, this one is used solely for PFS.
• AES
• Blowfish
• Twofish
• Cast128
• 3DES
• DES
• SHA1
• MD5
The "simplest" way of configuring a VPN is by using a method called "manual keying". This is a
245
9.3.3. IKE Authentication Chapter 9. VPN
method where IKE is not used at all; the encryption and authentication keys as well as some other
parameters are directly configured on both sides of the VPN tunnel.
Note
D-Link Firewalls do not support Manual Keying.
It is an old method, which was used before IKE came into use, and is thus lacking all the
functionality of IKE. This method therefore has a number of limitations, such as having to use the
same encryption/authentication key always, no anti-replay services, and it is not very flexible. There
is also no way of assuring that the remote host/firewall really is the one it says it is.
This type of connection is also vulnerable for something called "replay attacks", meaning a
malicious entity which has access to the encrypted traffic can record some packets, store them, and
send them to its destination at a later time. The destination VPN endpoint will have no way of
telling if this packet is a "replayed" packet or not. Using IKE eliminates this vulnerability.
PSK
Using a Pre-shared Key (PSK) is a method where the endpoints of the VPN "share" a secret key.
This is a service provided by IKE, and thus has all the advantages that come with it, making it far
more flexible than manual keying.
PSK Advantages
Pre-Shared Keying has a lot of advantages over manual keying. These include endpoint
authentication, which is what the PSKs are really for. It also includes all the benefits of using IKE.
Instead of using a fixed set of encryption keys, session keys will be used for a limited period of
time, where after a new set of session keys are used.
PSK Disadvantages
One thing that has to be considered when using Pre-Shared Keys is key distribution. How are the
Pre-Shared Keys distributed to remote VPN clients and firewalls? This is a major issue, since the
security of a PSK system is based on the PSKs being secret. Should one PSK be compromised, the
configuration will need to be changed to use a new PSK.
Certificates
Each VPN firewall has its own certificate, and one or more trusted root certificates.
• That each endpoint has the private key corresponding to the public key found in its certificate,
and that nobody else has access to the private key.
• That the certificate has been signed by someone that the remote gateway trusts.
Certificate Advantages
Added flexibility. Many VPN clients, for instance, can be managed without having the same
pre-shared key configured on all of them, which is often the case when using pre-shared keys and
246
9.3.4. IPsec Protocols (ESP/AH) Chapter 9. VPN
roaming clients. Instead, should a client be compromised, the client's certificate can simply be
revoked. No need to reconfigure every client.
Certificate Disadvantages
Added complexity. Certificate-based authentication may be used as part of a larger public key
infrastructure, making all VPN clients and firewalls dependent on third parties. In other words, there
are more things that have to be configured, and there are more things that can go wrong.
There are two protocols associated with IPsec, AH and ESP. These are covered in the sections
below.
AH (Authentication Header)
AH uses a cryptographic hash function to produce a MAC from the data in the IP packet. This MAC
is then transmitted with the packet, allowing the remote gateway to verify the integrity of the
original IP packet, making sure the data has not been tampered with on its way through the Internet.
Apart from the IP packet data, AH also authenticates parts of the IP header.
The AH protocol inserts an AH header after the original IP header, and in tunnel mode, the AH
header is inserted after the outer header, but before the original, inner, IP header.
The ESP protocol inserts an ESP header after the original IP header, in tunnel mode, the ESP header
is inserted after the outer header, but before the original, inner, IP header.
All data after the ESP header is encrypted and/or authenticated. The difference from AH is that ESP
also provides encryption of the IP packet. The authentication phase also differs in that ESP only
authenticates the data after the ESP header; thus the outer IP header is left unprotected.
The ESP protocol is used for both encryption and authentication of the IP packet. It can also be used
to do either encryption only, or authentication only.
247
9.3.5. NAT Traversal Chapter 9. VPN
• Additions to IKE that lets IPsec peers tell each other that they support NAT traversal, and the
specific versions supported. NetDefendOS supports the RFC3947 standard for NAT-Traversal
with IKE.
• Changes to the ESP encapsulation. If NAT traversal is used, ESP is encapsulated in UDP, which
allows for more flexible NATing.
Below is a more detailed description of the changes made to the IKE and IPsec protocols.
NAT traversal is only used if both ends has support for it. For this purpose, NAT traversal aware
VPNs send out a special "vendor ID", telling the other end that it understand NAT traversal, and
which specific versions of the draft it supports.
NAT detection: Both IPsec peers send hashes of their own IP addresses along with the source UDP
port used in the IKE negotiations. This information is used to see whether the IP address and source
port each peer uses is the same as what the other peer sees. If the source address and port have not
changed, then the traffic has not been NATed along the way, and NAT traversal is not necessary. If
the source address and/or port has changed, then the traffic has been NATed, and NAT traversal is
used.
Once the IPsec peers have decided that NAT traversal is necessary, the IKE negotiation is moved
away from UDP port 500 to port 4500. This is necessary since certain NAT devices treat UDP
packet on port 500 differently from other UDP packets in an effort to work around the NAT
problems with IKE. The problem is that this special handling of IKE packets may in fact break the
IKE negotiations,which is why the UDP port used by IKE has changed.
Another problem NAT traversal resolves is that the ESP protocol is an IP protocol. There is no port
information like in TCP and UDP, which makes it impossible to have more than one NATed client
connected to the same remote gateway and the same time. Because of this, ESP packets are
encapsulated in UDP. The ESP-UDP traffic is sent on port 4500, the same port as IKE when NAT
traversal is used. Once the port has been changed all following IKE communications are done over
port 4500. Keepalive packets are also being sent periodically to keep the NAT mapping alive.
Most NAT traversal functionality is completely automatic and in the initiating firewall no special
248
9.3.6. Proposal Lists Chapter 9. VPN
configuration is needed. However, for responding firewalls two points should be noted:
• On responding firewalls, the Remote Gateway field is used as a filter on the source IP of
received IKE packets. This should be set to allow the NATed IP address of the initiator.
• When individual pre-shared keys are used with multiple tunnels connecting to one remote
firewall which are then NATed out through the same address, it is important to make sure the
Local ID is unique for every tunnel. The Local ID can be one of
• Auto - The local ID is taken as the IP address of the outgoing interface. This is the
recommended setting unless, in an unlikely event, the two firewalls have the same external
IP address.
There are two types of proposals, IKE proposals and IPsec proposals. IKE proposals are used during
IKE Phase-1 (IKE Security Negotiation), while IPsec proposals are using during IKE Phase-2 (IPsec
Security Negotiation).
A Proposal List is used to group several proposals. During the negotiation process, the proposals in
the proposal list are offered to the remote VPN firewall one after another until a matching proposal
is found. Several proposal lists can be defined in NetDefendOS for different VPN scenarios. Two
IKE proposal lists and two IPsec proposal lists are defined by default in NetDefendOS.
The ike-roamingclients and esp-tn-roamingclients proposal lists are suitable for VPN tunnels that
are used for roaming VPN clients. These proposal lists are compatible with the default proposal lists
in the D-Link VPN Client.
As the name implies, the ike-lantolan and esp-tn-lantolan are suitable for LAN-to-LAN VPN
solutions. These proposal lists are trimmed to include only AES and 3DES based proposals.
This example shows how to create and use an IPsec Proposal List for use in the VPN tunnel. It will propose 3DES
and DES as encryption algorithms. The hash function SHA1 and MD5 will both be used in order to check if the
data packet is altered while being transmitted. Note that this example does not illustrate how to add the specific
IPsec tunnel object. It will also be used in a later example.
CLI
First create a list of IPsec Algorithms:
Web Interface
First create a list of IPsec Algorithms:
249
9.3.7. Pre-shared Keys Chapter 9. VPN
1. Go to Objects > VPN Objects > IKE Algorithms > Add > IPsec Algorithms
• DES
• 3DES
• SHA1
• MD5
4. Click OK
4. Click OK
Pre-shared Keys can be generated automatically through the WebUI but they can also be generated
through the CLI using the command pskgen (this command is fully documented in the CLI
Reference Guide).
This example shows how to create a Pre-shared Key and apply it to a VPN tunnel. Since regular words and
phrases are vulnerable to dictionary attacks, they should not be used as secrets. Here the pre-shared key is a
randomly generated hexadecimal key. Note that this example does not illustrate how to add the specific IPsec
tunnel object.
CLI
First create a Pre-shared Key. To generate the key automatically with a 64 bit (the default) key, use:
To have a longer, more secure 512 bit key the command would be:
Web Interface
250
9.3.8. Identification Lists Chapter 9. VPN
3. Choose Hexadecimal Key and click Generate Random Key to generate a key to the Passphrase textbox.
4. Click OK
3. Under the Authentication tab, choose Pre-shared Key and select MyPSK
4. Click OK
Consider the scenario of travelling employees being given access to the internal corporate networks
using VPN clients. The organization administers their own Certificate Authority, and certificates
have been issued to the employees. Different groups of employees are likely to have access to
different parts of the internal networks. For instance, members of the sales force need access to
servers running the order system, while technical engineers need access to technical databases.
Since the IP addresses of the travelling employees VPN clients cannot be known beforehand, the
incoming VPN connections from the clients cannot be differentiated. This means that the firewall is
unable to control the access to various parts of the internal networks.
The concept of Identification Lists presents a solution to this problem. An identification list contains
one or more identities (IDs), where each identity corresponds to the subject field in an X.509
certificate. Identification lists can thus be used to regulate what X.509 certificates that are given
access to what IPsec tunnels.
This example shows how to create and use an Identification List for use in the VPN tunnel. This Identification List
will contain one ID with the type DN, distinguished name, as the primary identifier. Note that this example does
not illustrate how to add the specific IPsec tunnel object.
CLI
First create an Identification List:
251
9.3.8. Identification Lists Chapter 9. VPN
gw-world:/MyIDList> cc
Web Interface
First create an Identification List:
1. Go to Objects > VPN Objects > ID List > Add > ID List
3. Click OK
5. Now enter:
• Organization Name:D-Link
• Country: Sweden
6. Click OK
4. Select the appropriate certificate in the Root Certificate(s) and Gateway Certificate controls.
6. Click OK
252
9.4. IPsec Tunnels Chapter 9. VPN
When another D-Link Firewall or D-Link VPN Client (or any IPsec compliant product) tries to
establish a IPsec VPN tunnel to the D-Link Firewall, the configured IPsec Tunnels are evaluated. If
a matching IPsec Tunnel definition is found, the IKE and IPsec negotiations then take place,
resulting in a IPsec VPN tunnel being established.
Note that an established IPsec tunnel does not automatically mean that all traffic from that IPsec
tunnel is trusted. On the contrary, network traffic that has been decrypted will be transferred to the
rule set for further evaluation. The source interface of the decrypted network traffic will be the name
of the associated IPsec Tunnel. Furthermore, a Route or an Access rule, in the case of a roaming
client, has to be defined to have the NetDefendOS accept certain source IP addresses from the IPsec
tunnel.
For network traffic going in the opposite direction, that is, going into a IPsec tunnel, a reverse
process takes place. First, the unencrypted traffic is evaluated by the rule set. If a rule and route
matches, NetDefendOS tries to find an established IPsec tunnel that matches the criteria. If not
found, NetDefendOS will try to establish a tunnel to the remote firewall specified by the matching
IPsec Tunnel definition.
Note
IKE and ESP/AH traffic are sent to the IPsec engine before the rule set is consulted.
Encrypted traffic to the firewall therefore does not need to be allowed in the rule set.
This behaviour can be changed in the IPsec Advanced Settings section.
Secure communication is achieved through the use of IPsec tunneling, with the tunnel extending
from the VPN gateway at one location to the VPN gateway at another location. The D-Link Firewall
is therefore the implementor of the VPN, while at the same time applying normal security
surveillance of traffic passing through the tunnel. This section deals specifically with setting up Lan
to Lan tunnels created with a Pre-shared Key (PSK).
A number of steps are required to set up LAN to LAN tunnels with PSK:
253
9.4.3. Roaming Clients Chapter 9. VPN
computer from different locations is a typical example of a roaming client. Apart from the need for
secure VPN access, the other major issue with roaming clients is that the mobile user's IP address is
often not known beforehand. To handle the unknown IP address the NetDefendOS can dynamically
add routes to the routing table as tunnels are established.
If the IP address of the client is not known before hand then the D-Link Firewall needs to create a
route in its routing table dynamically as each client connects. In the example below this is the case
and the IPsec tunnel is configured to dynamically add routes.
If clients are to be allowed to roam in from everywhere, irrespective of their IP address, then the
Remote Network needs to be set to all-nets (IP address: 0.0.0.0/0) which will allow all existing
IPv4-addresses to connect through the tunnel.
When configuring VPN tunnels for roaming clients it is usually not necessary to add to or modify
the proposal lists that are pre-configured in NetDefendOS.
Example 9.4. Setting up a PSK based VPN tunnel for roaming clients
This example describes how to configure an IPsec tunnel at the head office D-Link Firewall for roaming clients
that connect to the office to gain remote access. The head office network uses the 10.0.1.0/24 network span with
external firewall IP wan_ip.
Web Interface
2. Now enter:
• Name: Enter a name for the pre-shared key, SecretKey for instance
3. Click OK
2. Now enter:
• Name: RoamingIPsecTunnel
• Local Network: 10.0.1.0/24 (This is the local network that the roaming users will connect to)
254
9.4.3. Roaming Clients Chapter 9. VPN
• Enable the option: Dynamically add route to the remote network when a tunnel is established.
6. Click OK
C. Finally configure the IP rule set to allow traffic inside the tunnel.
Example 9.5. Setting up a Self-signed Certificate based VPN tunnel for roaming clients
This example describes how to configure an IPsec tunnel at the head office D-Link Firewall for roaming clients
that connect to the office to gain remote access. The head office network uses the 10.0.1.0/24 network span with
external firewall IP wan_ip.
Web Interface
The step to actually create self-signed certificates is performed outside the WebUI using a suitable software
product. The certificate should be in the PEM (Privacy Enhanced Mail) file format.
4. Click OK
1. Go to Objects > VPN Objects > ID List > Add > ID List
3. Click OK
4. Go to Objects > VPN Objects > ID List > Sales > Add > ID
7. In the Email address field, enter the email address selected when you created the certificate on the client
8. Create a new ID for every client that you want to grant access rights according to the instructions above
2. Now enter:
• Name: RoamingIPsecTunnel
• Local Network: 10.0.1.0/24 (This is the local network that the roaming users will connect to)
255
9.4.3. Roaming Clients Chapter 9. VPN
• Root Certificate(s): Select all your client certificates and add them to the Selected list
• Identification List: Select your ID List that you want to associate with your VPN Tunnel. In our case that
will be sales
• Enable the option: Dynamically add route to the remote network when a tunnel is established.
6. Click OK
E. Finally configure the IP rule set to allow traffic inside the tunnel.
It is the responsibility of the administrator to aquire the appropriate certificate from an issuing
authority for client tunnels. With some systems, such as Windows 2000 Server, there is built-in
access to a CA server (in Windows 2000 Server this is found in Certificate Services). For more
information on CA server issued certificates see Section 3.7, “X.509 Certificates”.
Example 9.6. Setting up a CA Server issued Certificate based VPN tunnel for roaming
clients
This example describes how to configure an IPsec tunnel at the head office D-Link Firewall for roaming clients
that connect to the office to gain remote access. The head office network uses the 10.0.1.0/24 network span with
external firewall IP wan_ip.
Web Interface
4. Click OK
1. Go to Objects > VPN Objects > ID List > Add > ID List
256
9.4.3. Roaming Clients Chapter 9. VPN
3. Click OK
4. Go to Objects > VPN Objects > ID List > Sales > Add > ID
7. In the Email address field, enter the email address selected when you created the certificate on the client
8. Create a new ID for every client that you want to grant access rights according to the instructions above
2. Now enter:
• Name: RoamingIPsecTunnel
• Local Network: 10.0.1.0/24 (This is the local network that the roaming users will connect to)
• Root Certificate(s): Select your CA server root certificate imported earlier and add it to the Selected list
• Identification List: Select your ID List that you want to associate with your VPN Tunnel. In our case that
will be sales
• Enable the option: Dynamically add route to the remote network when a tunnel is established
6. Click OK
D. Finally configure the IP rule set to allow traffic inside the tunnel.
An IP pool is a cache of IP addresses collected from DHCP servers and leases on these addresses are
automatically renewed when the lease time is about to expire. IP Pools also manage additional
information such as DNS and WINS/NBNS, just as an ordinary DHCP server would. (For detailed
information on pools see Section 5.5, “IP Pools”.)
257
9.4.3. Roaming Clients Chapter 9. VPN
Currently only one Config Mode object can be defined in NetDefendOS and this is referred to as the
Config Mode Pool object. The key parameters associated with it are as follows:
Use Pre-defined IP Pool Object The IP Pool object that provides the IP addresses.
DNS The IP address of the DNS used for URL resolution (already
provided by an IP Pool).
DHCP Instructs the host to send any internal DHCP requests to this
address.
In this example the Config Mode Pool object is enabled by associating with it an already configured IP Pool object
called ip_pool1
Web Interface
2. The Config Mode Pool object properties web page now appears
5. Click OK
After defining the Config Mode object, the only remaining action is to enable Config Mode to be
used with the IPsec Tunnel.
Assuming a predefined tunnel called vpn_tunnel1 this example shows how to enable Config Mode for that tunnel.
Web Interface
• Click OK
IP Validation
NetDefendOS always checks if the source IP address of each packet inside an IPsec tunnel is the
same as the IP address assigned to the IPsec client with IKE Config Mode. If a mismatch is detected
the packet is always dropped and a log message generated with a severity level of Warning. This
258
9.4.4. Fetching CRLs from an alternate Chapter 9. VPN
LDAP server
Optionally, the affected SA can be automatically deleted if validation fails by enabling the advanced
setting IPsecDeleteSAOnIPValidationFailure. The default value for this setting is Disabled.
However, in some scenarios, this information is missing, or the administrator wishes to use another
LDAP server. The LDAP configuration section can then be used to manually specify alternate
LDAP servers.
CLI
Web Interface
1. Go to Objects > VPN Objects > LDAP > Add > LDAP Server
2. Now enter:
• IP Address: 192.168.101.146
• Username: myusername
• Password: mypassword
• Port: 389
3. Click OK
259
9.5. PPTP/L2TP Chapter 9. VPN
9.5. PPTP/L2TP
The access by a client using a modem link over dial-up public switched networks, possibly with an
unpredictable IP address, to protected networks via a VPN poses particular problems. Both the
PPTP and L2TP protocols provide two different means of achieving VPN access from remote
clients.
9.5.1. PPTP
Overview
Point to Point Tunneling Protocol (PPTP) is designed by the PPTP Forum, a consortium of
companies that includes Microsoft. It is an OSI layer 2 "data-link" protocol (see Appendix D, The
OSI Framework) and is an extension of the older Point to Point Protocol (PPP), used for dial-up
Internet access. It was one of the first protocols designed to offer VPN access to remote servers via
dial-up networks and is still widely used.
Implementation
PPTP can be used in the VPN context to tunnel different protocols across the Internet. Tunneling is
achieved by encapsulating PPP packets in IP datagrams using Generic Routing Encapsulation (GRE
- IP protocol 47). The client first establishes a connection to an ISP in the normal way using the PPP
protocol and then establishes a TCP/IP connection across the Internet to the D-Link Firewall, which
acts as the PPTP server (TCP port 1723 is used). The ISP is not aware of the VPN since the tunnel
extends from the PPTP server to the client. The PPTP standard does not define how data is
encrypted. Encryption is usually achieved using the Microsoft Point-to-Point Encryption (MPPE)
standard.
Deployment
PPTP offers a convenient solution to client access that is simple to deploy. PPTP doesn't require the
certificate infrastructure found in L2TP but instead relies on a username/password sequence to
establish trust between client and server. The level of security offered by a non-certificate based
solution is arguably one of PPTP's drawbacks. PPTP also presents some scalability issues with some
PPTP servers restricting the number of simultaneous PPTP clients. Since PPTP doesn't use IPsec,
PPTP connections can be NATed and NAT traversal is not required. PPTP has been bundled by
Microsoft in its operating systems since Windows95 and therefore has a large number of clients
with the software already installed.
Troubleshooting PPTP
A common problem with setting up PPTP is that a router and/or switch in a network is blocking
TCP port 1723 and/or IP protocol 47 before the PPTP connection can be made to the D-Link
Firewall. Examining the log can indicate if this problem occurred, with a log message of the
following form appearing:
This example shows how to setup a PPTP Network Server. The example assumes that you have already created
certain address objects in the Address Book.
You will have to specify the IP address of the PPTP server interface, an outer IP address (that the PPTP server
should listen to) and an IP pool that the PPTP server will use to give out IP addresses to the clients from.
CLI
260
9.5.2. L2TP Chapter 9. VPN
Web Interface
3. Now enter:
4. Under the PPP Parameters tab, select pptp_Pool in the IP Pool control
5. Under the Add Route tab, select all_nets from Allowed Networks
6. Click OK
Use User Authentication Rules is enabled as default. To be able to authenticate the users using the PPTP
tunnel you also need to configure authentication rules, which will not be covered in this example.
9.5.2. L2TP
Layer 2 Tunneling protocol (L2TP) is an IETF open standard that overcomes many of the problems
of PPTP. Its design is a combination of Layer 2 Forwarding (L2F) protocol and PPTP, making use
of the best features of both. Since the L2TP standard does not implement encryption , it is usually
implemented with an IETF standard known as L2TP/IPsec, in which L2TP packets are encapsulated
by IPsec. The client communicates with a Local Access Concentrator (LAC) and the LAC
communicates across the Internet with a L2TP Network Server (LNS). The D-Link Firewall acts as
the LNS. The LAC is, in effect, tunneling data, such as a PPP session, using IPsec to the LNS across
the Internet. In most cases the client will itself act as the LAC.
L2TP is certificate based and therefore is simpler to administer with a large number of clients and
arguably offers better security than PPTP. Unlike PPTP, it is possible to set up multiple virtual
networks across a single tunnel. Being IPsec based, L2TP requires NAT traversal (NAT-T) to be
implemented on the LNS side of the tunnel.
This example shows how to setup a L2TP Network Server. The example presumes that you have created some
address objects in the Address Book. You will have to specify the IP address of the L2TP server interface, an
outer IP address (that the L2TP server should listen to) and an IP pool that the L2TP server will use to give out IP
addresses to the clients from. The interface that the L2TP server will accept connections on is a virtual IPsec
tunnel, not illustrated in this example.
CLI
Web Interface
261
9.5.2. L2TP Chapter 9. VPN
3. Now enter:
4. Under the PPP Parameters tab, select L2TP_Pool in the IP Pool control
5. Under the Add Route tab, select all_nets in the Allowed Networks control
6. Click OK
Use User Authentication Rules is enabled as default. To be able to authenticate the users using the PPTP
tunnel you also need to configure authentication rules, which is not covered in this example.
This example shows how to setup a fully working L2TP Tunnel and will cover many parts of basic VPN
configuration. Before starting, you need to configure some address objects, for example the network that is going
to be assigned to the L2TP clients. Proposal lists and PSK are needed as well. Here we will use the objects
created in previous examples.
To be able to authenticate the users using the L2TP tunnel a local user database will be used.
CLI
Web Interface
1. Go to User Authentication > Local User Databases > Add > Local User Database
3. Go to User Authentication > Local User Databases > UserDB > Add > User
4. Now enter:
• Username: testuser
• Password: mypassword
5. Click OK
Now we will setup the IPsec Tunnel, which will later be used in the L2TP section. As we are going to use L2TP,
the Local Network is the same IP the L2TP tunnel will connect to, wan_ip. Furthermore, the IPsec tunnel needs to
be configured to dynamically add routes to the remote network when the tunnel is established.
CLI
262
9.5.2. L2TP Chapter 9. VPN
Web Interface
3. Now enter:
9. Click OK
Now it is time to setup the L2TP Server. The inner IP address should be a part of the network which the clients
are assigned IP addresses from, in this lan_ip. The outer interface filter is the interface that the L2TP server will
accept connections on, this will be the earlier created l2tp_ipsec. Also a ProxyARP needs to be configured for the
IP's used by the L2TP Clients.
CLI
Web Interface
3. Now enter:
4. Under the PPP Parameters tab, check the Use User Authentication Rules control
6. Under the Add Route tab, select all-nets in the Allowed Networks control.
263
9.5.2. L2TP Chapter 9. VPN
8. Click OK
In order to authenticate the users using the L2TP tunnel, a user authentication rule needs to be configured.
CLI
Web Interface
1. Go to User Authentication > User Authentication Rules > Add > UserAuthRule
3. Now enter:
• Agent: PPP
• Interface: l2tp_tunnel
4. Under the Authentication Options tab enter UserDB as the Local User DB
5. Click OK
When the other parts are done, all that is left is the rules. To let traffic through from the tunnel, two IP rules should
be added.
CLI
Web Interface
3. Now enter:
• Action: Allow
• Service: all_services
264
9.5.2. L2TP Chapter 9. VPN
4. Click OK
7. Now enter:
• Action: NAT
• Service: all_services
8. Click OK
265
9.5.2. L2TP Chapter 9. VPN
266