Using IPSec (IP Security Protocol)
Table of contents
13.1 - What is IPSec 13.2 -? That's nice, but why do I want to use IPSec 13.3 -? What are the protocols behind IPSec 13.4 -? On the wire format 13.5 - Configuring IPSec 13.6 - How do I setup IPSec with manual keying? 13.7 -? How do I setup photurisd 13.8 - How do I setup isakmpd 13.9 -? How do I use isakmpd with X.509 certificates 13.10 -? What IKE clients are compatible with isakmpd 13.11 -? Troubleshooting IPSec / VPN 13.12 - Related Documentation
Portions of this Document WERE Taken from:
IPsec (4) VPN (8) ipsec for dummies by julian elischer isakmp HOWTO by Patrick Ethier X.509V3 Certificate with isakmpd by jörgen granstam
13.1 - What is ipsec?
IPSec is a set of extensions to the IP protocol family. It provides cryptographic security services. These services allow for authentication, integrity, access control, and confidentiality. IPSec provides similar services as SSL, but at the network layer, in a way that is completely transparent to your applications, and much more powerful. We say this because your applications do not have to have any knowledge of IPSec to be able to use it. You can use any IP protocol over IPSec. You can create encrypted tunnels (VPNs) , or just do encryption between computers. Since you have so much options, IPsec IS Rather Complex (MUCH More So the SSL!)
Before you start using IPSec, we strongly recommend that you check out the "recommended reading" of part 6 of the FAQ. In particular, if you do not already understand it, the Understanding IP Addressing document is highly recommended.
In a logical sense, IPsec Works in Any of these Three Ways:
Host-to-Host Host-to-Network Network-to-Network In every scenario that involves a network, we mean to imply router. As in, Host-to-Router (and this router controls and encrypts traffic for a particularNetwork.)
As you can see, IPSec can be used to tunnel traffic for VPN connections. However, its utility reaches beyond VPNs. With a central Internet Key Exchange registry, every machine on the internet could talk to another one and employ powerful encryption and authentication!
13.2 - That's nice, but why do I want to use ipsec?
The internet protocol, IP, aka IPv4, does not inherently provide any protection to your transferred data. It does not even guarantee that the sender is who he says he is. IPSec tries to remedy this. These services are considered distinct, but the IPSec Supports Them in a Uniform Manner.
ConfidentialityMake Sure It is hard for anyone but the receiver to understand what data has been communicated. You do not want anyone to see Your Passwords WHEN Logging Into a Remote Machine over the Internet.
IntegrityGuarantee that the data does not get changed on the way. If you are on a line carrying invoicing data you probably want to know that the amounts and account numbers are correct and not altered while in-transit.
AuthenticitySign Your Data So That Others Can See It. It. It. It .. .. cleanly nice to know. Documents.
Replay protectionWe need ways to ensure a transaction can only be carried out once unless we are authorized to repeat it. Ie it should not be possible for someone to record a transaction, and then replaying it verbatim, in order to get an effect of multiple transactions being received by the peer. Consider the attacker has got to know what the traffic is all about by other means than cracking the encryption, and that the traffic causes events favourable for him, like depositing money into his account. We need to make sure he Cannot Just Replay That Traffic Later.warning: As Per The Standards Specification, Replay Protection Is Not Performed When Using Manual-Keyed IPSec (EG, WHEN Using IPsecadm (8)).
13.3 - What Are The Protocols Behind IPSec?
IPSec provides confidentiality, integrity, authenticity, and replay protection through two new protocols. These protocols are called AH, Authentication header, and ESP, Encapsulated security payload.
AH provides authentication, integrity, and replay protection (but not confidentiality). Its main difference with ESP is that AH also secures parts of the IP header of the packet (like the source / destination addresses).
ESP can provide authentication, integrity, replay protection, and confidentiality of the data (it secures everything in the packet that follows the header). Replay protection requires authentication and integrity (these two go always together). Confidentiality (encryption) can be used with OR WITHOUT Authentication / Integrity.
13.4 - On The Wire Format
The Authentication Header (AH) comes after the basic IP header and contains cryptographic hashes of the data and identification information. The hashes can also cover the invariant parts of the IP header itself. There are several different RFCs giving a choice of actual algorithms to use in the AH, however they all must follow the guidelines specified in RFC2402.The Encapsulating Security payload (ESP) header, allows for rewriting of the payload in encrypted form. The ESP header does not consider the fields of the IP header before it and therefore Makes No Guarantees About Anything Except The Payload. The Various Types of ESP Applicable Must Follow RFC2406.An ESP Header Can Also Provide Authentication for the payload, (But not the outr).
An Orthogonal (MOSTLY) DIVISION OF IPSec Functionality Is Applied Depending On WHETHER THE END DOING The IPSec Encapsulation Is The Original Source of The Data OR A Gateway:
Transport mode is used by a host that is generating the packets. In transport mode, the security headers are added before the transport layer (eg. TCP, UDP) headers, before the IP header is prepended to the packet. In other words an AH added to the packet will cover the hashing of the TCP header and some fields of the end-to-end IP header, and an ESP header will cover the encryption of the TCP header and the data, but not the end-to-end IP header. tunnel mode is used when the end-to-end IP header is already attached to the packet, and one of the ends of the secure connection is only a gateway. In this mode, the AH and ESP headers are used to cover the entire packet including the end-to-end header, and a new IP header is prepended to the packet that covers just the hop to the other end of the secure connection (though that may of course be several IP hops away).
IPSec secured links are defined in terms of Security Associations (SAs). Each SA is defined for a single unidirectional flow of data, and usually (ignoring multicast) from one single point to another, covering traffic distinguishable by some unique selector. All traffic flowing over a single SA is treated the same. some traffic may be subject to several SAs, each of which applies some transform. Groups of SAs are called an SA Bundle. Incoming packets can be assigned to a particular SA by the three defining fields, ( Destination IP address, Security Parameter Index, security protocol). SPI can be considered a cookie that is handed out by the receiver of the SA when the parameters of the connection are negotiated. The security protocol must be either AH or ESP. Since the IP address of the receiver is part of the triple, this is a guaranteed unique value. They can be found from the outer IP header and the first security header (which contains the SPI and the security protocol) .An example o f A Tunnel Mode Ah Packet IS:
Iphdrahiphdr2tcphdrdata
An Example of a Transport Mode AH Packet IS:
Iphdrahtcphdrdata
Because An ESP Header Cannot Authenticate The Outer IP Header, IT IS Useful To Combine An Ah and An Esp Header To Get The Following:
Iphdrahesptcphdrdata
This is Called Transport Adjacency. The Tunnely Version Would Look Like:
Iphdrahespiphdr2tcphdrdata
However it is not specifically mentioned in the RFC. As with Transport adjacency, this would authenticate the entire packet except a few headers in the IP header and also encrypt the payload (seen in italics). When an AH and an ESP header are directly applied Together Like this, The Order of the Headers Should Be As Shown. It is Possible In Tunnel Mode, To Do Arbitrary Recursive Encapsulation So That Order Is Not Specified.13.5 - Configuring IPSec
How the ipsec systems and geteways are configured is to some extent left to the designer, however the RFC HAS Some Strong Recommendations As To HOW MIN Should Be Implement, So as To Minimize Confusion.
There are two administrative entities that control what happens to a packet. One is the Security Association Database (SAD, referred to as TDB or TDB table throughout OpenBSD's IPSec source code) and the other is the Security Policy Database (SPD).
They are similar in that given a number of selectors that describe some traffic, they will deliver an entry that describes the processing needed However, the SPD is two steps removed from the actual processing:. The SPD is used for outgoing packets, to decide what SAD entries should be used, and the SAD entries in turn describe the actual process and the parameters for it. The SPD entries specify the existing SAD entries to use (if it's a bundle there can be more than 1), but if there is not Already a suitable one, it is buy to create new one, the fields of the sa being created can be taken each packet what initiated the creation.
Outgoing packets go from the SPD entry to the specific SA, to get encoding parameters. Incoming packets get to the correct SA directly using the SPI / DestIP / Proto triple, and from there get to the SPD entry.The SPD can also specify what traffic should bypass IPSec and what should be dropped, so it must also be consulted for incoming non-IPSec traffic. SPD entries must be explicitly ordered as several might match a particular packet, and the processing must be reproducible.
The SPD can be thought of as similar to a packet filter where the actions decided upon are the activation of SA processes. Selectors can include src and dest address, port numbers if relevant, application and user IDs if available (only on host based transport SAs ), Hostnames, Security Sensitivity Levels, Protocols, ETC.
A SAD Entry Would INCLUDE:
Dest IP address IPSec proto (AH or ESP) SPI (cookie) Sequence counter Seq O / F flag Anti-replay window info AH type and info ESP type and info Lifetime info Tunnel / transport mode flags Path MTU info
A SPD Entry Would Contain:
Pointer TO ACTIVE SAS Selector Fields
Each SA can define one ESP header and one AH header An IPSec session must have one or the other or both, but can not be defined with neither -. Otherwise there would be no headers to specify the SPI to look up the SA The RFC doesn. 'T Say What Would Happen if The Ah and ESP Headers Disagree About The SPI Value. ONE Would PRESUME This Would IMPLY MULTIPLE SAS IN A BUNDLE.
The SPD in OpenBSD is managed through the ipsecadm flow command. (You would only make changes to it if you were using manual keying.) SAD entries can be set manually with ipsecadm (8), however the IETF has also defined automatic mechanisms for initialization of sessions and such things as key exchange OpenBSD implements both Photuris (RFC2522, and RFC2523) and ISAKMP automatic key exchange (RFC2407, RFC2408, and RFC2409) in the photurisd (8) and isakmpd (8) daemons.13.6 -. How do I Setup ipsec with manual key?
Manual keying is the easiest way to get started with IPSec. You can setup encryption between networks, to create VPNs using this method. After you have read this section, you may want to investigate using /usr/share/ipsec/rc.vpn to Set this up for you automatically.
First, You NEED TO TURN ON IP AH AND IP ESP Options in the openbsd kernel (if you are online) in the openbsd kernel (if you are only sale esp In Fact, There May Even Be Security Concerns Related To Enabling Ah if you are not useful it.
There is a nice sysctl to enable these protocols.
# sysctl -w net.inet.esp.enable = 1Net.Ineet.esp.enable: 0 -> 1 # sysctl -w net.inet.ah.enable = 1Net.Inet.ah.enable: 0 -> 1
You Can Edit
/etc/sysctl.conf to turn these on at boot time. You need to remove the # mark from in front of net.inet.esp.enable and / or net.inet.ah.enable (Depending On Which You Plan To Use ) and make Sure the isy area set to 1.
You also need to generate your manual keys. Since the security of the VPN is based on these keys being unguessable, it is very important that the keys be chosen using a strong random source. One practical method of generating them is by using the random ( 4) Device. To Produce 160 Bits of Randomness, for Example, Do: # dd if = / dev / urandom BS = 1024 count = 1 | SHA1
.................
Cipher Key Length
DES 56 BITS
3DES 168 bits
BLF Variable (40-160, 160 bits recommented)
Cast Variable (40-128, 128 bits recommented)
Skipjack 80 Bits
Now, you need to setup SAs, or Security Associations. A Security Association is a combination of your IP addresses, an SPI, and your security protocol (AH and / or ESP). The IP addresses are both your own and that of your destination ............. ..
These examples only use ESP to encrypt your traffic. ESP includes authentication of the contained encrypted data, but does not authenticate the surrounding IP header, as AH would. This "limited authentication" is nevertheless quite sufficient in most cases, especially for ESP in a Tunnel environment.
# ipsecadm new ESP -SPI SPI_OUT -SRC MY_EXTERNAL_IP -DST peer_external_ip -forcetunnel -enc BLF -AUTH SHA1_KEY ENC_KEY -AUTHKEY Auth_key
Let's Put this Into Practice with Two Routers, 192.168.5.1 and 192.168.25.9.
ON Host 192.168.5.1:
# Ipsecadm new esp -spi 1000 -src 192.168.5.1 -dst 192.168.25.9 -forcetunnel -enc blf -auth sha1 -key 7762d8707255d974168cbb1d274f8bed4cbd3364 -authkey 6a20367e21c66e5a40739db293cf2ef2a4e6659f # ipsecadm new esp -spi 1001 -dst 192.168.5.1 -src 192.168.25.9 -forcetunnel -enc BLF -AUTH SHA1 -KEY 7762D8707255D9762D8707255D974168CBBB1D274F8BED4CBD3364 -AUTHKEY 6A20367E21C66E5A40739DB293CF2EF2A4E6659FON HOST 192.168.25.9:
# Ipsecadm new esp -spi 1001 -src 192.168.25.9 -dst 192.168.5.1 -forcetunnel -enc blf -auth sha1 -key 7762d8707255d974168cbb1d274f8bed4cbd3364 -authkey 6a20367e21c66e5a40739db293cf2ef2a4e6659f # ipsecadm new esp -spi 1000 -dst 192.168.25.9 -src 192.168.5.1 -forcetunnel --enc BLF -AUTH SHA1 -KEY 7762D8707255D974168CBB1D274F8BED4CBD3364 -AUTHKEY 6A20367E21C66E5A40739DB293CF2EF2A4E6659F
Notice That The Spis Are Different. See on The Wire Format for a Complete Description of What The SPI is and where it is used.
Now That You have your security associations in place, SET UP YOUR FLOWS.
ON 192.168.5.1:
So, Right Here, Two Flows Will Be Created, One The Local Source Address, Which Covers All Packets Originating from The Local Host To The Destination, As Well As a Flow from The Destination Back to The Local Host.
# ipsecadm flow -proto ESP-DST 192.168.25.9 - Spi 1000 -Addr 192.168.5.1 255.255.255.255.255.255.255
On 192.168.25.9:
# ipsecadm flow -proto esp -dst 192.168.5.1 -spi 1001 -Addr 192.168.25.9 255.255.255.9592.168.5.1 255.255.255.255
If you want less overhead on your Host-to-Host VPNs, creating the SPI without -forcetunnel will let you use transport mode (whereas, -forcetunnel makes sure all of the IP packet, including the IP header, are encapsulated by SPI). If either the source or destination is a network, you will have to use tunnel mode. Creating an SA to and / or from a network will automatically ensure tunnel mode SPIs are being created.This is a simple way to start using IPSec.
You can use ipsec to tunnel private ip adres Spaces over the internet. Here is a good example ... we want to tunnel 192.168.99.0/24, WHICH IS BEHIND 208.1.1.1, to 208.1.2.0/24 and 208.1.5.0/ 24 Which Are Behind 208.2.2.2. The RC.VPN Script.
As you can see, WHEN you are using manual keying with ipsec, you have to specify EXACTLY What You Want Done. It won't guess for you. Look at these Examples ...
ON 208.1.1.1 :First, SET UP The Security Associations (SAS):
(This set of the spis, encryption methods, and keys)
# Ipsecadm new esp -src 208.1.1.1 -dst 208.2.2.2 -forcetunnel -spi 1001 -enc blf -auth sha1 -key 7762d8707255d974168cbb1d274f8bed4cbd3364 -authkey 67e21c66e5a40739db293cf2ef2a4e6659f # ipsecadm new esp -src 208.2.2.2 -dst 208.1.1.1 -forcetunnel -spi 1000 -ENC BLF -AUTH SHA1 -KEY 7762D8707255D974168CBB1D274F8BED4CBD3364 -AUTHKEY 67E21C66E5A40739DB293CF2EF2A4E6659F
Next, Setup a flow from 208.1.1.1 to 208.2.2.2
# ipsecadm flow -proto ESP-DST 208.2.2.2 --SPI 1001 -Addr 208.1.1.1 255.255.255.255 208.2.2.2 255.255.255.255
NEXT, SETUP A FLOW FROM 208.1.2.0/24, Which is Behind 208.2.2.2, to 192.168.99.0/24
# ipsecadm flow -proto ESP-DST 208.2.2.2 --SPI 1001 -Addr 192.168.99.0 255.255.255.0 208.1.2.0 255.255.255.0
NEXT, SETUP A FLOW FROM 208.1.5.0/24, Which is Behind 208.2.2.2, to 192.168.99.0.24# ipsecadm flow -Proto ESP-DST 208.2.2.2 --SPI 1001 -Addr 192.168.99.0 255.255.255.0 208.1.5.0 255.255.255.0
Now, Setup a Flow from 208.1.2.0/24, Which is Behind 208.2.2.2 to the router 208.1.1.1.
# ipsecadm flow -Proto ESP-DST 208.2.2.2 --SPI 1001 -Addr 208.1.1.1 255.255.255.255 208.1.2.0 255.255.255.0
OK, Setup A Flow from 208.1.5.0/24, Which is Behind 208.2.2.2, To The Router 208.1.1.1
# ipsecadm flow -Proto ESP-DST 208.2.2.2 --SPI 1001 - ADDR 208.1.1.1 255.255.255.255 208.1.5.0 255.255.255.0
Finally, Setup A Flow from the router 208.2.2.2 to 192.168.99.0/24
# ipsecadm flow -Proto ESP-DST 208.2.2.2 --SPI 1001 -Addr 192.168.99.0 255.255.255.0 208.2.2.2 255.255.255.255
On 208.2.2.2:4ame as Before, We setup the SAS ...
# Ipsecadm new esp -src 208.2.2.2 -dst 208.1.1.1 -forcetunnel -spi 1000 -enc blf -auth sha1 -key 7762d8707255d974168cbb1d274f8bed4cbd3364 -authkey 67e21c66e5a40739db293cf2ef2a4e6659f # ipsecadm new esp -src 208.1.1.1 -dst 208.2.2.2 -forcetunnel -spi 1001 -ENC BLF -AUTH SHA1 -KEY 7762D8707255D974168CBB1D274F8BED4CBD3364 -AUTHKEY 67E21C66E5A40739DB293CF2EF2A4E6659F
Now, this is the reverse Side ... Setup a flow from the router 208.2.2.2 to 208.1.1.1
# ipsecadm flow -proto esp -dst 208.1.1.1 --spi 1000 -Addr 208.2.2.2 255.255.255.255.255.255.255.255.255
Setup a flow from the network 192.168.99.0/24, Which is Behind 208.1.1.1, to 208.1.2.0/24
# ipsecadm flow -proto esp -dst 208.1.1.1 --spi 1000 -Addr 208.1.2.0 255.255.255.0 192.168.99.0 255.255.255.0
Setup a flow from the network 192.168.99.0/24, Which is behind 208.1.1.1, to 208.1.5.0/24
# ipsecadm flow -proto ESP-DST 208.1.1.1 - Spi 1000 -Addr 208.1.5.0 255.99.0 255.0 192.168.99.0 255.0 192.168.99.0 255.095.255.0NOW, SETUP A FLOW from 192.169.99.0/24, Which is Behind 208.1.1.1, to the router 208.2.2.2
# ipsecadm flow -proto ESP-DST 208.1.1.1 --Spi 1000 -Addr 208.2.2.2 255.255.255.255 19255.99.0 255.255.255.0
We're Almost Done ... Two flows left to get 208.1.2.2.24 from the router 208.2.2.2 to the router 208.1.1.1.
# Ipsecadm flow -proto esp -dst 208.1.1.1 -spi 1000 -addr 208.1.2.0 255.255.255.0 208.2.2.2 255.255.255.255 -ingress # ipsecadm flow -proto esp -dst 208.1.1.1 -spi 1000 -addr 208.1.5.0 255.255 .255.0 208.2.2.2 255.255.255.255 -ingress
If you have been using ipsecadm, and you want to get rid of anything, you'Ve Done, and start from scratch, do
# ipsecadm flush
This Will Flush All IPsec Info (Spis, Flows, Routing Entries "from your system.
13.7 - How do I setup phoTurisd?
........................ ..
To setup Your PhoTurisd, First Edit /etc/photuris/secrets.conf on each host with photurisd.
BSD # cat /etc/photuris/secrets.conf
# ACCEPTED Keywords Are:
# Identity Local "ID" "Secret"
# odentity pair local "receivedid" "MyID" "Secret"
# Identity Remote "ID" "Secret"
# Identity Lookup "Tag" Username
# Simple
Identity Local "Default" "this kind be changed."
Identity Remote "Default" "this kind be changed."
Change "This should be changed." To a key of your choice on the local config, and another key of your choice on the remote config. (Use the same config on your remote box but swap "local" and "remote" so that IT SEES ITSELF As The Local Key.) Note That The Keys Will Be Replaced In A Future Version of Photurisd That Will Carry Out Its Initial Key Exchange with public keys.make suward.inet.ah.enable is set to 1.
BSD # sysctl -w net.inet.ah.enable = 1
Net.inet.ah.enable: 0 -> 1
And Run StartKey.
BSD # startKey Dst = Remote.host
NOW, Run Tcpdump to Verify That Your Packets Are Being Encrypted with ah. (Run A Ping In Another Window Or Session To Generate Traffic)
BSD # tcpdump proto ah
You can also try using tcpdump by the Host Address if you am't getting anything.
BSD # tcpdump Host Remote.host
You can make photos in /etc/photuris/photuris.Startup
13.8 - How do I setup isakmpd?
If you are thinking about VPNs or other traditional applications of IPSec, you probably are going to use ISAKMP. Some commercial implementations of IPSec do not provide any manual keying ability, instead they require you to use some form of ISAKMP.
13.8.1 - What is isakmpd ISAKMP (sometimes referred to as IKE, or Internet Key Exchange) is the key exchange mechanism for the VPN It meets security concerns using the methods mentioned in RFC 2407, RFC 2408 and RFC 2409. ISAKMP manages?. The Exchange of Cryptographic Keys That You Would Normally Have to Manage with
Ipsecadm (8). It Employs a Two-Phase Process for Establishing The IPsec Parameters Between Two IPsec Nodes.
Phase 1 - The two ISAKMP peers establish a secure, authenticated channel upon which to communicate between two daemons This establishes a Security Association (SA) between both hosts Main Mode and Aggressive Mode are the methods used to establish this channel Main Mode sends... the various authentication information in a certain sequence, providing identity protection. Aggressive Mode does not provide identity protection because all of the authentication information is sent at the same time. Aggressive mode should only be used in such cases where network bandwidth is of concern.Phase 2 - Security Associations are negotiated on behalf of IPSec Phase 2 is establishes tunnels or endpoint SAs between IPSec hosts Quick Mode is used in Phase 2 because there is not need to repeat a full authentication because Phase 1 has already established the SAs...
In brief, Phase 1 is used to get a secure channel in which to do the (quicker) phase 2 setups. There can be multiple phase 2 setups within the same phase 1 channel. Phase 2 is used to setup the actual tunnels. In Phase 1, your IPSec nodes establish a connection where they exchange authentication (Either a X509 certificate or a pre-shared secret). This allows each end to make sure the other end is authenticated. Phase 2 is an exchange of keys to determine how the data Between the two.
13.8.2 - How do I get started with isakmpd?
.. By default, OpenBSD comes with the proper binaries for ISAKMP and the IPSec stack Unfortunately, the same can not be said for the sample files To retrieve them, you need to grab: / usr / src / sbin / isakmpd / samples / VPN- East.conf and / usr / src / sbin / isakmpd / samples / policy from the source tree. You Can Either Use Your CD (if You Have ONE), CVSWeb, or The Command Line CVS Client. (CVSWeb Has VPN-EAST. conf and policy readily available). For the purposes of this example, copy policy to /etc/isakmpd/isakmpd.policy. Copy VPN-east.conf to /etc/isakmpd/isakmpd.conf. Here we attempt to show you how to setup a VPN (tunnel). If you want to use isakmpd between single hosts, there are other configuration files in the samples directory. The manual pages have detailed information .. Do not forget isakmpd.conf (5) and isakmpd.policy ( 5) .your first step is to turn e 帖 13.6 Tells You How to do this Both for run-time and boot. Next, you need to edit /etc/isakmpd.policy. This file tells isakmp who can access IPSec. In this scenario, the policy file states that anybody who sends data using Encapsulate Security Payload (ESP), and has authenticated with the passphrase mekmitasdigoat (or whatever passphrase you determine), is allowed to communicate with isakmpd. You can modify this file to let ISAKMP know that we only want to allow data signed with certain digital certificates or using a certain encryption transform. You could also allow anybody to access IPSec. This is only recommended for testing. to do this, edit your policy file To Contain Only The Following Lines:
Keynote-Version: 2
Authorizer: "Policy"
The Same Policy File Contains Two Lines That Start with The $ Character. You NEED TO REMOVE THESE LINES BEFORE Using It, They Are ONLY FOR CVS.A More Useful Policy File for this Example Looks Like this:
Keynote-Version: 2
Comment: This Policy Accepts ESP Sas from a Remote That Uses The Right Password
Authorizer: "Policy"
Licensees: "Passphrase: MekmitasDigoat"
Conditions: App_Domain == "IPSec Policy" &&
ESP_PRESENT == "YES" -> "True";
Implementing this Will Give You a Basic VPN (Tunnel) Using ESP ONLY. ON HOST A, Edit /etc/isakmpd/isakmpd.conf. The 249.2.2.2 Sample IP Address Should Be Replaced with The External IP Address of Host A.
[General]
Retransmits = 5
Exchange-max-time = 120
Listen-on = 249.2.2.2
Do Similar for isakmpd.conf on Host B. 249.3.3.3 Represents The External IP Address for Host B.
[General]
Retransmits = 5
Exchange-max-time = 120
Listen-on = 249.3.3.3
This is where you can setup the variables that will affect the main behavior of isakmpd. It is okay to use the defaults here. The Listen-on = value specifies the IP that isakmpd should listen on. Only the Internet IP of your gateway is necessary ............!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!
Next, ON Host A, Edit isakmpd.conf again.
[Phase 1]
249.3.3.3 = Hostb
ON Host B:
[Phase 1]
249.2.2.2 = Hosta
This section describes the IP addresses to accept in order to negotiate the phase 1 connection. Its value points to the section below (Remember that phase 1 simply authenticates the remote peer to make sure they are who they say they are). You can list multiple Peers with additional lines in the format of ip_address =
[Phase 2]
Connections = Hosta-Hostb
ON Host B:
[Phase 2]
Connections = Hostb-Hosta
This Describes Phase 2 of The Connection. This is The Phase That Determines What Protocols The Two Peers Will Use To Communicate.
The Connections = tag refers to the section below. It initiates the requirements or the accepted methods to set up Phase 2. This also tells ISAKMPD which connections to initiate once started. Note that you can have multiple sections as illustrated below if you are to connect With multiple peer hosts.
If you do not have the IP address of the remote host, you can specify a Default = that points to a section describing a generic entry that will be referenced by any incoming IP that is not listed in the Connections = tag.
ON Host A:
[Hostb]
PHASE = 1
Transport = UDP
Local-address = 249.2.2.2
Address = 249.3.3.3
Configuration = Default-main-mode
Authentication = mekmitasdigoat
# Flags =
ON Host B:
[Hosta]
PHASE = 1
Transport = UDP
Local-address = 249.3.3.3
Address = 249.2.2.2
Configuration = Default-main-mode
Authentication = mekmitasdigoat
# Flags =
These represent the sections referred to by the Phase 1 section above. They each describe the requirements that the peer gateway must fulfill in order to proceed to Phase 2. There are many other options here but the ones mentioned above are the minimum requirements.
Phase = 1 is required because the ISAKMPD code uses the same procedures to process Phase 1 and Phase 2. It must be 1 or nothing will work. Transport = gives you different possibilities for different peers. It's suggested that udp be used here so we ' ll leave it at that. Please note that some peers may be behind a firewall that does not let UDP traffic through. Obviously, this needs to be determined before setup. Local-address is the destination address that the incoming packets point to. In some cases, you can be listening on different Interfaces for Phase 1 connections. In this example, there is only 1 interface listening, therefore this is the IP of the listening interface on this peer. address = is the address that points to the source IP of the incoming packets. This usually points to the peer gateway. This needs further explanation, because the source IP address of the peer may be unknown! Configuration = points to the section below. You can specify multiple sections like this. We use th e default one specified by the sample file. Authentication = is the pre-shared secret to be used for this particular peer. It is more or less a passphrase that each peer uses. This passphrase gets passed to policy to verify whether this peer is allowed to use IPSEC with this host. If you change this phrase, you must also change it in the policy file because the sample file provides for this passphrase. If you decided to go with a minimum policy file then you can specify whatever you want here. Flags = is not currently being used. The RFCs leave room for extra options to be specified for phase 1. There are other tags here that will allow for other options to be set. Refer to isakmpd.conf (5) for descriptions.
ON Host A: [Hosta-Hostb]
Phase = 2
Isakmp-peer = hostb
Configuration = Default-Quick-Mode
Local-id = Net-a
Remote-id = Net-B
ON Host B:
[Hostb-Hosta]
Phase = 2
Isakmp-peer = Hosta
Configuration = Default-Quick-Mode
Local-id = Net-B
Remote-id = Net-a
................. ..
Phase = 2 is required because ISAKMPD code uses the same functions to authenticate Phase 1 and Phase 2. This is required for the VPN to work. ISAKMPD-Peer = is the name of Host section above. This means that we are talking to that particular peer to establish a Phase 2 connection. This is provided because you can have multiple sections to describe isakmp peers and connections. Configuration = refers to the section below that describes the standards by which this host and the particular peer for this connection must abide. Local -ID = refers to an IPSec-ID section below that describes our Private Network to the peer gateway. This is the portion that is passed so that the other gateway can set up the proper routing table that will transfer data over the VPN to our network . Remote-ID = refers to an IPSec-ID section below that describes what is supposed to be the remote Private Network to our host. This portion is interpreted to set up the proper routing tables that will transfer data from our Pr Ivate Network over the vpn to the remote private network. The Remote Private network. The Remote Private NetWork. The Remote, Tag That IS Supported Here Called Flags =. If You Require this tag, read isakmpd.conf (5).
This is the IPSec-ID section. These entries need to exist in the isakmpd.conf files for both Host A and Host B. This example will setup 192.168.1.0/255.255.255.0 for Host A (which was connected to Net-A above ) and 192.168.20.0/255.255.255.0 for host b (net-b Above). [Net-a]
ID-TYPE = IPv4_addr_subnet
NetWork = 192.168.1.0
Netmask = 255.255.255.0
[NET-B]
ID-TYPE = IPv4_addr_subnet
NetWork = 192.168.20.0
Netmask = 255.255.255.0
These two sections are in the conf file of each host. They are the sections referenced by the Local-ID and Remote-ID identifiers. They describe the routes that should be set up to allow traffic from one private network to another. ID-type = Can BE IPv4_addr_subnet or ipv4_addr (RFC2708 Mentions More Possible Values. Currently Only IPv4 IS Supported in The Openbsd IMPEENBSD-CURRENT.)
Now, On Both Hosts, The Sample File Should Read:
[Default-main-mode]
DOI = IPSec
Exchange_type = ID_PROT
Transforms = 3DES-SHA
THIS Section Describes The Requirements for the Encryption Methods of Phase 1 Connections. The name reflect
CONFIGURATION = Variable. As we can see here, we are stating our domain of interthing is ipsec.
Exchange_type variable is set to
ID_PROT for Phase 1, Which Identifies The Protocols to Be Covered by this Authentication.
Transforms = is the transform required (or assigned) for this exchange. In this case, this points to the section below in the configuration file that says we are receiving a packet encrypted with 3DES and a checksum verifiable with SHA. There are a bunch of Different Transforms Defined Inside the Sample
VPN-east.conf. These are provided because 3DES and SHA are not always supported across different platforms. For OpenBSD there should be no reason to change this for a basic setup. Feel free to create multiples of this section and change the transform. The Only Requirement is this you change the configuration = variable. [default-quick-mode]
DOI = IPSec
Exchange_type = quick_mode
Suites = QM-ESP-3DES-SHA-PFS-SUITE, QM-ESP-DES-MD5-PFS-Suite
This section describes the requirements for the encryption of the data to be sent through the VPN and is referred to by Configuration above. Note the difference between this section and the Phase 1 equivalent just above is that the EXCHANGE_TYPE is QUICK_MODE. This is always the case for Phase 2. Suites = points to a IPSec Suite section describing the different encryption schemes available between the two hosts. There is much more to be said about ISAKMP and IPSec. By using the above basic descriptions you should be able to create a simple but Solid VPN That Cares and feeds itself. this is the bare minimum isakmpd.conf for Both hosts here.
13.8.3 - Starting Isakmpdyou May wish to use
# isakmpd -d -da = 99
the first time you decide to run this daemon. The daemon will not be running in daemon mode but as a regular process. It will log everything to your terminal. To stop isakmpd and flush the routes, you need to kill the isakmpd process on each Node, And Run IPsecadm Flush.
13.9 - How do I use isakmpd with x.509 certificates?
Setting up isakmpd to use certificates instead of pre-shared keys is not really that much harder in a big network with many untrusted peers than it would be with a small network. It may actually simplify configuration, and more importantly, key management.Generating certificates .There is a good description of how to generate keys and certificates in the
README.PKI file in the isakmpd source directory. You need to have a CA key, a corresponding CA X.509 certificate, one private key for each computer on the network that will use isakmpd and one X.509 certificate for each such key.
The X.509 certificates need to have a Subject Alternative Name (SubjectAltName) extension describing the certificate holder. How to set a SubjectAltName extension using certpatch for a certificate is also described in README.PKI for the case of setting an IP address as the SubjectAltName AN IP Address Here Is Also The Default Behaviour for isakmpd.
Certpatch also support using either a FQDN (Fully Qualified Domain Name) or a UFQDN (User FQDN). An example of an FQDN might be www.openbsd.org, an example of an UFQDN would be an email address. Something like Jorgen.Granstam @ abc.se for esample.
In this howto document I am going to use FQDNs as SubjectAltNames. Using IP addresses would be a bit easier since that is the default behaviour of isakmpd but it is not much of a difference as we soon will see.
To INSERT An Fqdn SubjectAltname Into a Certificate ONE Would Do Something Like this:
$ / usr / sbin / certpatch -t fqdn -i home.mysite.se -k ca.key originalcert.crt newcert.crt
Here the ca.key is the private key of the CA, thus this can only be done by whoever has access to the CA private key. The (fictional) home.mysite.se is the FQDN to be inserted into the certificate. The originalcert .crt and newcert.crt filenames may be the same name in which case the original file will be overwritten by the new modified certificate.Put the keys and certificates in the directories as described at the end of README.PKI. The CA key (ca .key) Should Be Kept in Some Safe Place If The Keys Are Really To Be Seriously Used.
Configuration of isakmpdlets now Look at the /etc/isakmpd/isakmpd.conf configuration file. It is originally taken from the example file in
isakmpd.conf (5) but have been heavily modified. I will also use a much shorter file here than the example file in the man-page, I have removed from that file most parts that are not needed in this setup. In part to simplify the understanding of this setup. I have also added some commenting (some comments are left as in the isakmpd.conf (5)) and changed some names. None of the domain names used here exists as far as I know.
Actually since everyone who reads this already have a working configuration for the preshared keys case (see previous section) there will not be many surprises in this file. I will not explain this in every detail, check isakmpd.conf (5) for Descriptions of the parts I don't comment.
Let's assume our setup looks something like this
One.mysite.se ONE.WORKSITE.SE
192.168.1.2 - 10.0.0.1 ==== / ====== 10.0.0.2 - 192.168.2.2
GW.MYSITE.SE GW.WORKSITE.SE |
- 192.168.1.1 192.168.2.1 ---
Two.mysite.se | | TWO.WORKSITE.SE192.168.1.3 - - 192.168.2.3
That is, two networks that should be connected using an IPSec tunnel over an otherwise insecure network. Ignore the fact that I am using IP addresses reserved for private Internets here (RFC1918), I have to use something. I will not explain how to Use isakmpd in Combination with Nat or Similar (Because I Haven't Tried That Myself).
Now, Let's Look At the Configuration File. This is the file for the security gateway gw.mysite.se:
#************************************************************ *****************
# ************ START of the gw.mysite.se isakmpd.conf ************
#************************************************************ *****************
# A configuration syrple for the isakmpd isakmp / oakley (aka Ike) Daemon.
[General]
Policy-file = / etc / isakmpd / policy
Retransmits = 5
Exchange-max-time = 120
Listen-ON = 10.0.0.1
# The name work-gw here is buy just as a section name and a tag fort
# @ use in this configuration file below and new not actually be the
# real hostname or domain name of the peer (but it could be). The ip
# Address however Needs to be correct. Phase 1, As you might already
# know, is to negotiate an isakmp security association (sa). There
# SHOULD of Course Be One ip and name for each peer we want to
# Communicate with.
[Phase 1]
10.0.0.2 = WORK-GW
# Now Phase 2 Is Negotiarating IPsec Sas. AS in Phase 1, The Name Here
# is a section name to be used latterial, it can becomma
# Separated List of section names here. thus if Traffic from Many
# NetWorks (or Individual Hosts) Should Be Forwarded Through this # tunnel, more section Names Would Be Added (And Of Course Corresponding
# New sections further down.
[Phase 2]
Connections = WORK-GW-MY-GW
# Now, Here Area Some Parameters for the isakmp sa negotiations. Almost
# Self Documenting. The section is from [Phase 1] Above. The MOST
# Tag might be the id tag. The ID tag is set to the name
# of the section where the identity information about this host That. INFORMATION
# Will Be Presented to Connecting Peers, Can Be Found. if the ID tag
# Is Not Available, Isakmpd Will Assume That IT Will Identify Itself
# Using the ip address. You might also NOTICE That there is no lucker
# Any Authentication Tag Here in this configuration. The Authentication.
# Data is currently useless only in the preshared key copy.
[Work-gw]
PHASE = 1
Transport = UDP
Local-address = 10.0.0.1 # local address
Address = 10.0.0.2 # Peer Address
ID = my-id
Configuration = Default-main-mode
# This is the identity data. ID-TYPE MAY Also BE IPv4_addr (The
# default, ipv4_addr_subnet or ufqdn. The name tag is buy
# Fqdn and ufqdn, for ipv4_addr an address tag would be used instead.
# For ipv4_addr_subnet a network and a netmask tag would be used.
[my-id]
ID-TYPE = FQDN
Name = gw.mysite.se.se
# This is the section for the ipsec connection. The section name is
# from the list in the [Phase 2] section above. The isakmp-peer IS,
# of course, The Tag of Our Peer from Section [Phase 1] Above. The
# Local-id and remote-id tags shouth # packages Should Be forwarded over The ipsec tunnel to the remote
# NetWork.
[WORK-GW-MY-GW]
Phase = 2
Isakmp-peer = Work-GW
Configuration = Default-Quick-Mode
Local-id = net-west
Remote-id = Net-East
# Any packet Originating from a computer on the network described
# here ...
[Net-West]
ID-TYPE = IPv4_addr_subnet
NetWork = 192.168.1.0
Netmask = 255.255.255.0
# ... and with a destination matching the network described here,
# Will Be Encrypted and Forwarded Over the ipsec tunnel to the remote
# system.
[Net-East]
ID-TYPE = IPv4_addr_subnet
NetWork = 192.168.2.0
Netmask = 255.255.255.0
# Main Mode Descriptions
# Here is the data for main mode. Using des here for real purposes
# is not Very Smart Since Des No Longer Considered A Secure
# Encryption Algorithm. 3des is generally considered to have much beette
# Security Since It Has ENOUGH BITS in The Key To Be Considered Secure.
# Transforms is a list of tags describing main mode transforms. In
# this example we have only one.
[Default-main-mode]
DOI = IPSec
Exchange_type = ID_PROT
Transforms = 3DES-MD5
# Certificate Stored in PEM Format
# This is important when useing certificates. The Ca Certificate SHOULD
# be in the CA-Directory (But Not The CA Private Key Of Course).
# THE CERT-DIRECTORY SHOULD HAVE AT Least The Certificate for the
# local host but other certificates are also aLLOWED. The Private Key
# Should Be The Private Key of The Local Host. [X509-Certificate]]
CA-DIRECTORY = / etc / isakmpd / ca /
Cert-Directory = / etc / isakmpd / certs /
Private-key = /etc/isakmpd/private/local.Key
# Main Mode Transforms
#######################################
# Here Is Our Main Mode Transform. The Important Thing Here IS To Use
# Rsa_sig as authentication method when using certificates. It is the
# Only Method Supported When Using Certificate So Far. Commercial
# Entities in the US Will thus Have to wait uncle September 2000 To
# Use this due to the RSA Patent. Luckily, I am NOT LIVING IN THE.
# Also important is the group_description tag. It must match the
# Group_description Tag in The Quick Mode Transforms Further Down.
# The life tag here could possibly be modified. The Life_60_secs might
# Be Shorter Than Necessary for Normal USE.
[3DES-MD5]
Encryption_algorithm = 3DES_CBC
Hash_algorithm = md5
Authentication_method = rsa_sig
Group_description = modp_1024
LIFE = Life_60_secs, Life_1000_KB
# Quick Mode Description
################################
[Default-Quick-Mode]
DOI = IPSec
Exchange_type = quick_mode
Suites = QM-ESP-3DES-MD5-PFS-Suite
# Quick Mode Protection Suites
#############################################
# 3des
[QM-ESP-3DES-MD5-PFS-Suite]
Protocols = QM-ESP-3DES-MD5-PFS
# 3des
[QM-ESP-3DES-MD5-PFS]
Protocol_id = ipsec_esp
Transforms = QM-ESP-3DES-MD5-PFS-XF
# Quick Mode Transforms
# Don't forget. The group_description Must match the group_description
# in main mode Above. for forwarding packets Between TWO NetWorks (OR
# from a host to a network WE Use Tunnel Mode. Between Two Hosts We # May Also Use Transport Mode Instead.
[QM-ESP-3DES-MD5-PFS-XF]
Transform_id = 3DES
ENCAPSULATION_MODE = Tunnel
Authentication_algorithm = HMAC_MD5
Group_description = modp_1024
Life = life_60_secs
# As we know from the isakmpd.config manpage the life_duration here IS
# an offer value (60), a minimum acceptable value (45) And a maximum
# acceptable value. The isakmpd.conf Example Has this set to TO
# 600, 450/720 INSTEAD. That Might Be a better value for Normal USE.
[LIFE_60_SECS]
Life_type = seconds
Life_duration = 60, 45: 72
[LIFE_1000_KB]
Life_type = kilobytes
Life_duration = 1000, 768: 1536
#************************************************************ *****************
# *** * end of the gw.mysite.se isakmpd.conf ****************
#************************************************************ *****************
So far the configuration for the local system. The remote system is configured just the same way only opposite. Thus only the first part of the isakmpd.conf file differs. Let's just look at that first part of the isakmpd.conf file for the security Gateway gw.worksite.se:
#************************************************************ *****************
# ************* START of the gw.worksite.se isakmpd.conf **********
#************************************************************ *****************
[General]
Policy-file = / etc / isakmpd / policy
Retransmits = 5
Exchange-max-time = 120
Listen-ON = 10.0.0.2
[Phase 1]
10.0.0.1 = MY-GW
[Phase 2]
Connections = WORK-GW-MY-GW
[my-gw] Phase = 1
Transport = UDP
Local-address = 10.0.0.2 # local address
Address = 10.0.0.1 # Peer Address
ID = Work-ID
Configuration = Default-main-mode
[Work-ID]
ID-TYPE = FQDN
Name = gw.worksite.se.se
[WORK-GW-MY-GW]
Phase = 2
Isakmp-peer = my-gw
Configuration = Default-Quick-Mode
Local-id = Net-East
Remote-id = Net-West
#************************************************************ *****************
# ************ ... to becomued ******************** *
#************************************************************ *****************
Now That Wasn't So Hard, Just A Bit Boring to Read Perhaps. A Slightly More Interesting Part Next.
THE Policy File Might Be Slightly Confusing for Anyone Who Has Not Used It Before, Especially IFORE, ESPECIALLY IFORE, ESPECIALLY IFORE, ESPECIALLY IFORE
ISAKMPD.POLICY (5) IS Not Really That Bad. IT Might Perhaps Be a Little Bit Unclear in Some Parts But Generally It's Good.
The SimpleSt Possible Working Policy File Would Contain Just A Single Line:
Authorizer: "Policy"
This basically means that that there is no policy limitations on who would be allowed to connect. Thus not a very secure setup. The authorizer tag here means the one who has the authorization to decide the policy. The special authorizer "POLICY" has the ultimate And Unlimited Authority On Policy. Any Other Authorizer Must First Be Authorized by "Policy" to have any authority here.
There can also be a set of conditions for what is allowed. The following policy thus would mean that only someone using the ESP protocol with some real encryption would be authorized (oh well, someone using DES would also be authorized here although DES could almost be considered snakeoil today, it is left as an exercise for the reader to change this policy into not allowing DES either) Note that anyone who does encrypts with ESP would still be allowed.authorizer:. "POLICY"
Conditions: App_Domain == "IPSec Policy" &&
ESP_PRESENT == "YES" &&
ESP_ENC_ALG! = "NULL" -> "true";
It is also possible to "sublicense" authority to someone else (might be one or more entities) The simple case would be the preshared key case In that case, anyone who knows the preshared passphrase is authorized Thus...:
Authorizer: "Policy"
Licensees: "Passphrase: Something Really Secret"
Conditions: App_Domain == "IPSec Policy" &&
ESP_PRESENT == "YES" &&
ESP_ENC_ALG! = "NULL" -> "true";
................. ..
Nothing difficult so far. Now to the interesting stuff. First there can be many licensees, although all must be authorized by "POLICY". Further, authorized licensees can sublicense to other licensees. A licensee can be just a string in case it is further Described in The Policy File:
Authorizer: "Policy"
Licensees: "Subpolicyah" || "Subpolicyesp"
Conditions: app_domain == "ipsec policy" -> "true"; Authorizer: "Subpolicyesp"
Licensees: "Passphrase: Something More Secret"
Conditions: ESP_PRESENT == "YES" -> "True";
Authorizer: "Subpolicyah"
Licensees: "Passphrase: Something Really Secret"
Conditions: ah_present == "YES" -> "true";
And now to what everyone has been waiting for. Policy can also be sublicensed or delegated to a key. In this case it is usually a X.509 certificate. The simple use of certificates would be to use them like the passphrases. Just insert individual Users certificates in the policy file:
Keynote-Version: 2
Comment: this is an esample of a policy delegating to a key.
Authorizer: "Policy"
licensees: "x509-base64: MIIBsTCCARoCAQAwDQYJKoZIhvcNAQEEBQAwITELMAkGA1UEBhMCc2UxEjAQBgNV BAMTCUlLRUxBQiBDQTAeFw0wMDAxMjgxNzQyMTZaFw0wMTAxMjcxNzQyMTZaMCEx CzA This is would be a user certificate AQEB BQA IUuz eOW8P5UGJUH2JVkiA2CTDryFf0CHYwd2P003dtVYw5RvET7XLMpRZiCcWtBdxneW ct 016zUBP / cQMMl KownxAUq9ezA8GvTyUWC97SOMOgoVj / QR3FHmEjpUi3AgMB AAEwDQYJKoZIhvcNAQEEBQADgYEALGShaAxHvGncev0iFnKrJI4x5T4vlaMP1ad iWLV5q9H3wickVGN0NPerq0YLwx / VA9WaecYN8V ALtNKYPuDiT11zwvE8GQeaai NuzgmQ9hh3GifEgN9VEiC3j4kTytonKr0Q vTLM7xYzheOxvrtUErRwZ9Xs1KzHe yiXHSU8 ="
Conditions: App_Domain == "IPSec Policy" &&
ESP_PRESENT == "YES" &&
ESP_ENC_ALG! = "NULL" -> "true";
Now, this is obviously a stupid idea if there are a lot of users. The certificates that isakmpd reads from the CA- and Certificate directories, and the certificates received from the peer is converted into pseudo credentials. Such certificates converted into pseudo credentials essentially would look something like: authorizer: "x509-base64: MIIBsTCCARoCAQAwDQYJKoZIhvcNAQEEBQAwITELMAkGA1UEBhMCc2UxEjAQBgI2 CzA This is would be the public key / certificate of the AQEB BQA signer of the user certificate (ie the CA certificate) IUuz eOW8P5UGJUH2JVkiA2CTDryFf0CHYwd2P003dtVYw5RvET7XLMpRZiCcWtBdxneW ct 016zUBP / cQMMl KownxAUq9ezA8GvTyUWC97SOMOgoVj / QR3FHmEjpUi3AgMB AAEwDQYJKoZIhvcNAQEEBQADgYEALGShaAxHvGncev0iFnKrJI4x5T4vlaMP1ad iWLV5q9H3wickVGN0NPerq0YLwx / Va9waecyn8v altnkypudit11zwve8gqeaai nuzgmq9hh3gifegn9veic3j4ktytonkr0Q vtlm7xyzheoxvrtuerrwz9xs1kzhe yixhsu8 = "
licensees: "x509-base64: MIIBsTCCARoCAQAwDQYJKoZIhvcNAQEEBQAwITELMAkGA1UEBhMCc2UxEjAQBgNV BAMTCUlLRUxBQiBDQTAeFw0wMDAxMjgxNzQyMTZaFw0wMTAxMjcxNzQyMTZaMCEx CzA This is would be the key of the subject of the AQEB BQA certificate IUuz eOW8P5UGJUH2JVkiA2CTDryFf0CHYwd2P003dtVYw5RvET7XLMpRZiCcWtBdxneW ct 016zUBP / cQMMl KownxAUq9ezA8GvTyUWC97SOMOgoVj / QR3FHmEjpUi3AgMB AAEwDQYJKoZIhvcNAQEEBQADgYEALGShaAxHvGncev0iFnKrJI4x5T4vlaMP1ad iWLV5q9H3wickVGN0NPerq0YLwx / VA9WaecYN8V ALtNKYPuDiT11zwvE8GQeaai NuzgmQ9hh3GifEgN9VEiC3j4kTytonKr0Q vTLM7xYzheOxvrtUErRwZ9Xs1KzHe yiXHSU8 ="
conditions: app_domain == "IPsec policy" -> "true"; Now note that certificates internally these are not authorized by "POLICY" and thus will not have any effect without a policy authorizing them somehow Further, this showed what happens to. . The above credential is thus not seen in the policy file. However, it is possible to sublicense to such credentials. Remember sublicensing above. It is thus possible to license all certificates that are signed by a certain CA by putting the CA certificate as a Licensee to "Policy":
Keynote-Version: 2
Comment: this is an esample of a policy delegating to a key.
Authorizer: "Policy"
licensees: "x509-base64: MIIBsTCCARoCAQAwDQYJKoZIhvcNAQEEBQAwITELMAkGA1UEBhMCc2UxEjAQBgNV BAMTCUlLRUxBQiBDQTAeFw0wMDAxMjgxNzQyMTZaFw0wMTAxMjcxNzQyMTZaMCEx CzA This would be the CA certificate AQEB BQA IUuz eOW8P5UGJUH2JVkiA2CTDryFf0CHYwd2P003dtVYw5RvET7XLMpRZiCcWtBdxneW ct 016zUBP / cQMMl KownxAUq9ezA8GvTyUWC97SOMOgoVj / QR3FHmEjpUi3AgMB AAEwDQYJKoZIhvcNAQEEBQADgYEALGShaAxHvGncev0iFnKrJI4x5T4vlaMP1ad iWLV5q9H3wickVGN0NPerq0YLwx / VA9WaecYN8V ALtNKYPuDiT11zwvE8GQeaai NuzgmQ9hh3GifEgN9VEiC3j4kTytonKr0Q vTLM7xYzheOxvrtUErRwZ9Xs1KzHe yiXHSU8 ="
Conditions: App_Domain == "IPSec Policy" &&
ESP_PRESENT == "YES" &&
ESP_ENC_ALG! = "NULL" -> "true";
Thus the above policy is a simple example of a policy that delegates to a CA. Thus any user that has a certificate that is signed by the CA that has this certificate and otherwise comply to other conditions set by the policy and the configuration file would be authorized.Almost secure ... is not secure! Now, to be really safe, this is not enough unfortunately. There are ways to attack a security gateway that is configured in this way. If you really do not want the details, skip A to the next section now. To Everyone else, Let's try to understand why this is not secure. it's not hard.
Consider what information one of the isakmpds has access to at this stage. From the configuration file, isakmpd knows which IP-address its peer will send from (in the [Phase 1] section). From the information it gets at the phase 1 negotiation IT KNOWS THAT That The Peer Presents Itself with and the certificate it gets from The Peer Proves That The Peer Real Really Have this ID. Looks Fine So Far?
Well, if the ID information was the IP (the default situation if we do not provide a phase 1 ID section) everything would be fine. The CA would have tied the IP to the cert and the IP in the configuration would be all information we need. It would be possible for an imposter to use the same IP from another computer in some cases (eg if both computers were on the same local network and the computer that usually have this IP is down for some reason). It should however not BE POSSIBLE for an IMPOSTER TO BE ABLE TO HAVE A CERTIFICATE AND A CORRESPONDING Private Key That (falsely) Proves That this ip belongs to the imposter.
If that ever happened, the imposter would have managed to either steal the private key from the real owner of the IP, or the imposter would have managed to fool the CA into issuing a certificate containing false information somehow. If any of these things happened, then either the private key had not been protected well enough, the CA had failed to check the identity of the imposter well enough (or the ID info for the cert) or the CA private key had not been well enough protected. Since all these are prerequisites for security to work at all, none of these situations can be allowed to ever occur.Now, in our example the situation is different. Here we actually have an FQDN in the certificate instead of an IP address. Since we still have an IP address in the [Phase 1] section this will result in a possible security problem. What now would happen during an ISAKMP phase 1 negotiation would be that we could check that the peer was sending from the expected IP (but as explained earlier that could possibly be forged in some situations). We could check that the ID our peer presents actually belongs to our peer. But what we can not check now is if that ID really is the ID we expect our peer to have, because isakmpd have never BEEN TOLD What ID THAT SHOULD BE.
Someone now might say that the DNS system ties the IP to the FQDN for the host. That is true, however today's DNS system is not secure and can, under some circumstances, be fooled to give out false information (or, it could be subject to a denial of service (DoS) attack by an attacker, and the attacker's computer might be able to fake the DNS server's answer). Secure DNS will come in the future, but it is not here yet (at least most DNS servers are not secure yet), thus today, using DNS to check if the FQDN in the cert corresponds to the expected IP is no guarantee. in fact isakmpd does not check this with DNS. Even if DNS was secure, checking this would not help in the case of using an UFQDN.Thus in the case of having an FQDN as ID, it could be possible for an attacker to get an own private key and having this key signed by the same CA that we use (but with the attacker's own FQDN, of Course). The launch a dos attack on Our Peer So That It Goes Down (in Fact, There Area Some Flaws in the ISAKMP protocol itself that possibly could be used to launch a remote DoS against the peer an make it go down, although I do not know how sensitive isakmpd is to those attacks). Then the attacker could configure its own computer in the same way As our peer, Connect It To Our Peers Network and try to connect using its oown ID, private key and certificate.
Since our own isakmpd has not been informed about what ID to our peer (and it is because the attacker is identically configured as our peer besides the certificate, ID and private key). Further our isakmpd can check that the certificate was signed by the same CA (But Most Might Not Be Hard To Get), And That The Presented ID Is The Same As The ID in The Cert. However It Would Not, With The Configuration Presented So Far, Check That this ID is the expected ID. Thus the attacker would be allowed to connect.Preventing the attack.The question now thus is, how can we inform isakmpd about what ID to expect? This is fortunately easy, and documented in the
Isakmpd.policy (5). We Must do the check in the policy. like this:
Keynote-Version: 2
Comment: this is an esample of a policy delegating to a key.
Authorizer: "Policy"
licensees: "x509-base64: MIIBsTCCARoCAQAwDQYJKoZIhvcNAQEEBQAwITELMAkGA1UEBhMCc2UxEjAQBgNV BAMTCUlLRUxBQiBDQTAeFw0wMDAxMjgxNzQyMTZaFw0wMTAxMjcxNzQyMTZaMCEx CzA This would be the CA certificate AQEB BQA IUuz eOW8P5UGJUH2JVkiA2CTDryFf0CHYwd2P003dtVYw5RvET7XLMpRZiCcWtBdxneW ct 016zUBP / cQMMl KownxAUq9ezA8GvTyUWC97SOMOgoVj / QR3FHmEjpUi3AgMB AAEwDQYJKoZIhvcNAQEEBQADgYEALGShaAxHvGncev0iFnKrJI4x5T4vlaMP1ad iWLV5q9H3wickVGN0NPerq0YLwx / VA9WaecYN8V ALtNKYPuDiT11zwvE8GQeaai NuzgmQ9hh3GifEgN9VEiC3j4kTytonKr0Q vTLM7xYzheOxvrtUErRwZ9Xs1KzHe yiXHSU8 ="
Conditions: App_Domain == "IPSec Policy" &&
ESP_PRESENT == "YES" &&
ESP_ENC_ALG! = "NULL" && remote_id == "gw.worksite.se" -> "true";
Now Only Gw.Worksite.se Should Be Able To Get An Ipsec Connection. More All Co. The More Alternative Remote_id Checks, E.g. by Having Conditions Like There In The Policy:
Conditions: App_Domain == "IPSec Policy" &&
ESP_PRESENT == "YES" &&
ESP_ENC_ALG! = "NULL" &&
(Remote_id == "gw.worksite.se" ||
Remote_id == "gw.whatsite.se") -> "true";
With this policy. S, gw.somesite.se or gw.whatsite.se Could Connect.
Some might say that is unfortunate that there has to be entire certificates inserted in the policy. It requires some work to reformat the certificates into the format in the policy and it makes the policy rather unreadable. If someone by mistake replaced a user certificate with the corresponding CA certificate somewhere in a complex policy it might cause unauthorized users to be allowed to connect in some cases and worse, it would not be easily detectable by reading through the policy file (since X.509 certificates are not in a human readable format) .
Now, for the really bleeding edge people out there a solution to this problem is available. It is now possible to use the certificate Distinguished Name (DN) instead of a certificate in the policy (the corresponding certificate must of course be available from the certs OR CA DIRECTORIES ON Disk So That Isakmpd CAN Find IT). with this format The Policy ABOVE Might Look Like Something Like this Instead:
Keynote-Version: 2
Comment: this is an esample of a policy delegating to a key.
Authorizer: "Policy" licensees: "DN: / C = SE / CN = Ikelab CA"
Conditions: App_Domain == "IPSec Policy" &&
ESP_PRESENT == "YES" &&
ESP_ENC_ALG! = "NULL" &&
(Remote_id == "gw.worksite.se" ||
Remote_id == "gw.somesite.se" ||
Remote_id == "gw.whatsite.se") -> "true";
Much more readable, isn't it? The information about what the exact dn for a certificate is can be found by looking at the certificate. Something Like:
$ openssl x509 -text More complicated policy. This should provide the necessary information about the certificate in ca.crt. Now this is good as long as we have a small or at least reasonably small policy. It is however still not too great if we have a gigantic site with lots of users that Should be allowed to connect. Multiuser configurations and / or centrally managed authorization.Now, lets look at some really cool features of isakmpd. Previously we assumed that the expected peer was well known and had a static IP address. This is not always the case. Lots of people use dynamically Assigned IPS or Use Many Different Computers. In Other Cases (Like for a Server) We might Not know for Sure Who Wants To Connect. Therefor one very nice feature of isakmpd is the ability to use a default tag instead of an IP in the [Phase 1] section, thus allowing isakmpd negotiations from any IP This might thus look something like this.: [Phase 1] Default = WORK-GW First, it should be said that this configuration might not be secure from DoS attacks. As said before, there are some flaws in the ISAKMP / IKE protocols. Anyway, using a default [phase 1] section also enable us to use a kind of "authorization certificates" instead.Consider the case where we have a lot of authorized users but when we would not accept just any user. like at a company. We would like company employees to be allowed to connect but nobody else. Now, imagine a big company where there might be thousands of employees. We might like them to all be able to connect from any computer (not only from within the company network) but everyone should not be allowed to do anything. It should now be possible to write a Policy Like this: Keynote-Version: 2 Authorizer: "Policy" Licensees: "Telnet @ Work" || "telnet @ lab" || "POP3 @ Work" Conditions: App_Domain == "IPSec Policy" && ESP_PRESENT == "YES" && ESP_ENC_ALG! = "NULL" && Remote_id_type == "ufqdn" && (Remote_id == "Telnet@worksite.se" || Remote_id == "Pop3@worksite.se" || Remote_id == "telnet@lab.worksite.se") -> "true"; Authorizer: "Telnet @ Work" Licensees: "DN: / C = SE / CN = Ikelab CA" Conditions: remote_id == "telnet@worksite.se" && Local_filter_type == "IPv4 Address" && Local_Filter_Port == "23" && Local_filter == "192.168.002.003" Authorizer: "Telnet @ LAB" Licensees: "DN: / C = SE / CN = Ikelab CA" Conditions: remote_id == "telnet@lab.worksite.se" && local_filter_type == "IPv4 address" && Local_Filter_Port == "23" && Local_filter == "192.168.002.002" -> "True"; Authorizer: "POP3 @ Work" Licensees: "DN: / C = SE / CN = Ikelab CA" Conditions: local_filter_type == "IPv4 Address" && Local_Filter_Port == "110" && Local_filter == "192.168.002.003" && Remote_id == "telnet@worksite.se" -> "true"; This might not be exactly how it should be. This is as far as I know completely untested (in fact, these filter conditions might not work at all as I expect). Also, a policy such as this one (in fact any with default as peer IP), would require rewrites of the isakmpd.conf file too. This would have some security implications too. Further, for this kind of connections where anyone should be allowed to connect, it would probably be desirable to log the DN of anyone who connected. isakmpd does not yet support that to my knowledge. Also this probably could have other security implications. you are on your own, you have been warned. The basic idea should be clear anyway. Just in case someone missed the really interesting possibilities this would have. If all computers using ISAKMP / IKE this way had a standard set of conditions for all services the users might like to use from remote, the CA could actually authorize users by just putting the right SubjectAltName extensions in their certificates. Further, the expiration time for such certificates could be set to expire relatively often although the users would be able to download new reissued certificates when their current certificate is getting old. If the users misuse their authorizations, just stop reissuing the certificates and they will not get in more after it has expired. No need to change policy files on all computers just because an employee eg quits their job. The same scheme should work for other purposes than ISAKMP / IPsec too (including authorization For off-line systems!) Althought, IN Any Case, Any Organization Doing this Would Probably Want To Be Their Own CA.Multiuser configurations (mobile users) like these are possible with pre-shared keys too, but then it is required that AGGRESSIVE mode is used instead of ID_PROT mode since we then must be able to choose the right password phrase based on ID since we do not know that from what the IP is in this case (in AGGRESSIVE mode the ID is sent over at an earlier stage of the negotiation, but it is sent unencrypted, thus AGGRESSIVE mode is faster because it needs fewer message exchanges, but it also IS A Bit Less Secure Since The Id IS Sent In Clear. 13.10 - What IKE Clients Are Compatible with isakmpd? isakmpd is the ISAKMP / Oakley key management daemon that comes with OpenBSD. We suspect that it interoperates, at least partially, with most ISAKMP implementations, but the following have actually been tested. Note that some isakmp software out there are actually based on the OpenBSD Isakmp Daemon.The Following MS-Windows Clients Have Been Reported to Be Compatible: Timestep Permit / Client Ashley Laurent VPCM VPN Software PGP VPN Software Radguard Cipro Client Cisco Ire Client Microsoft Windows 2000 (Transport Mode ONLY) The Following Gateway / Routers Have Been Reported To Be Compatible: Cisco IOS Cisco PIX Intel LanRover TimeStep PERMIT / Gate Cendio Fuego KAME for FreeBSD FreeS / WAN for Linux Axent Raptor Ericsson eBox Radguard cIPro-VPN F-Secure VPN Teamware TWISS 3com Pathbuilder Nortel Contivity CheckPoint FW-1 13.11 - Troubleshooting IPSec / VPN Your first Tool for Troubleshooting IPsec is Tcpdump (8). Use tcpdump to look for several things. First, if you are using tcpdump from OpenBSD, you have an enhanced version of tcpdump which can show some information about ESP and AH packets. If you are using tcpdump from OpenBSD 2.5 or on another operating system, chances are you have an older version that Will Simply Show The Protocol Number for Ah OR ESP. (ESP IP Protocol 50, AH IS 51) With tcpdump, look and see if traffic is using AH / ESP or cleartext. If your traffic is in cleartext, then your flows are setup incorrectly or your isakmp is not negotiating properly. Use ping (8) to generate simple traffic. For Instance, I Have Two Hosts, 208.1.1.1 and 208.2.2.2. Logged in To 208.2.2.2, I am doing this: VPN # ping -c 3 208.1.1.1 Ping Esp.MIL (208.1.1.1): 56 data bytes 64 bytes from 208.1.1.1: ICMP_SEQ = 0 TTL = 255 TIME = 190.155 MS64 bytes from 208.1.1.1: ICMP_SEQ = 1 TTL = 255 TIME = 201.040 MS 64 bytes from 208.1.1.1: ICMP_SEQ = 2 TTL = 255 TIME = 165.481 MS --- esp.mil ping statistics --- 3 Packets Transmitted, 3 Packets Received, 0% Packet LOSS Round-Trip Min / Avg / Max = 165.481 / 185.558 / 201.040 MS And in another session, i can see my encapsulated pings: VPN # tcpdump -ni fxp7 host 208.1.1.1 TCPDUMP: LISTENING ON FXP7 14: 12: 19.630274 ESP 208.2.2.2> 208.1.1.1 SPI 0x00001000 SEQ 4535 LEN 116 14: 12: 19.813519 ESP 208.1.1.1> 208.2.2.2 SPI 0x00001001 SEQ 49313 LEN 116 14: 12: 20.630277 ESP 208.2.2.2> 208.1.1.1 SPI 0x00001000 SEQ 4536 LEN 116 14: 12: 20.832458 ESP 208.1.1.1> 208.2.2.2 SPI 0x00001001 SEQ 49314 LEN 116 14: 12: 21.630273 ESP 208.2.2.2> 208.1.1.1 SPI 0x00001000 SEQ 4537 Len 116 ^ C 1831 Packets Received by Filter 0 packets dropped by kernel Isakmp Runs ON UDP Port 500. IF this is locked out through a firewall or packet filter, the you need to change it! # Passing in isakmp Traffic from the security gateways PASS IN NE0 PROTO UDP from GateWB / 32 Port = 500 to GateWa / 32 Port = 500 Pass Out on Ne0 Proto UDP from GateWa / 32 Port = 500 to GateWB / 32 Port = 500 # Passing in Encrypted Traffic from Security Gateways Pass in proto esp from GateWB / 32 To GateWa / 32 Pass Out Proto ESP from GateWa / 32 To GateWB / 32 Ph.10. Same Considerations, But The Protocol is AH. # Passing in photuris traffic from the security gateways PASS IN NE0 PROTO UDP from GateWB / 32 Port = 468 to GateWa / 32 Port = 468 Pass Out on Ne0 Proto UDP from Gatewa / 32 Port = 468 To GateWB / 32 Port = 468 # Passing in Encrypted Traffic from Security GatewaySpass in Proto Ah from Gatewb / 32 To GateWa / 32 Pass Out Proto Ah from GateWa / 32 To GateWB / 32 To Turn on All Debugging in isakmpd, Start IT AS # / sbin / isakmpd -d -da = 99 or (To Skip the Most Detailed Timer Debug Info) # / sbin / isakmpd -d -da = 99 -d1 = 70 You NEED TO Allow Traffic Which Has Been Processed by IPSec from Netb Into Your Local FireWalled Neta. # Passing in traffic from the designated subnet. PASS IN ENC0 from Netb / NetBmask to Neta / Netamask With tcpdump on OpenBSD, you can decode most cleartext parts of Internet Key Exchange sessions. Tcpdump will also show AH payload data. Mount a / kern filesystem (if you do not use one by default already.) # mkdir / kern; mount -t keernfs / kern / kern In / kern, there is a table of current SA / SPIs, including which have flows (outgoing SAs) or not (incoming SAs). There are also traffic counters which you can use to see what traffic is going where. Finally, you can Use netstat (1) to see your sas. VPN% netstat -rn -f eNCAP Routing Tables ENCAP: Source Port Destination Port Proto SA (Address / SPI / PROTO) 0.0.0.0/32 0 192.168.99 / 24 0 0 081.1.1.1.1/00001000/50 0.0.0.0/32 0 208.1.1.1/32 0 0 0 0 081.1.1.1/00001000/50 208.1.2.0/24 0 192.168.99 / 24 0 0 0 081.1.1.1.1/00001000/50 208.1.2.0/24 0 208.1.1.1.1/32 0 0 0 081.1.1.1.1/00001000/50 208.1.5.99 / 24 0 192.168.99 / 24 0 0 088.1.1.1.1/00001000/50 208.1.5.0: 0 081.1.1/32 0 0 0 081.1.1.1.1/00001000/50 208.2.2.2/32 0 192.168.99 / 24 0 0 081.1.1.1/00001000/50 208.2.2.2/32 0 2081.1.1/32 0 0 0 081.1.1.1/00001000/50IF All else fails, Recompile Your kernel with option encDebug. Then, set the sysctl net.inet.ip.encdebug to 1. Look in Your Dmesg For Warnings Or Errors, And Report The USing Sendbug To The OpenBSD Developers.