Benchmarks for Native IPsec in the 2.6 Kernel
The following listing is used to illustrate how to set up a secure connection between two computers on different LANs. Below, we provide the script file of gouda that sets a secure connection between two systems. gouda is at IP address 192.168.0.1 and reblochon is at IP address 192.168.0.2.
1: #!/usr/local/sbin/setkey -f 2: flush; 3: spdflush; 4: 5: # AH gouda to reblochon 6: add 192.168.0.1 192.168.0.2 ah 1000 7: -A hmac-md5 "1234567890123456"; 8: add 192.168.0.2 192.168.0.1 ah 2000 9: -A hmac-md5 "1234567890123456"; 10: 11: # ESP gouda to reblochon 12: add 192.168.0.1 192.168.0.2 esp 1001 13: -E 3des-cbc "123456789012345678901234" 14: -A hmac-sha1 "12345678901234567890"; 15: add 192.168.0.2 192.168.0.1 esp 2001 16: -E 3des-cbc "123456789012345678901234" 17: -A hmac-sha1 "12345678901234567890"; 18: 19: spdadd 192.168.0.1 192.168.0.2 any -P out IPsec 20: esp/transport//require 21: ah/transport//require; 22: 23: spdadd 192.168.0.2 192.168.0.1 any -P in IPsec 24: esp/transport//require 25: ah/transport//require;
For reblochon, we use the same script file with only the following differences on line 19:
19: spdadd 192.168.0.1 192.168.0.2 any -P in IPsec
and on line 23:
23: spdadd 192.168.0.2 192.168.0.1 any -P out IPsec
Note the in and out keywords are reversed.
In line 1, the setkey command is invoked. This program inserts or deletes IPsec rules in the kernel. In lines 2 and 3, we use the setkey command to clear all security associations (SA) and security policies (SP), because we want to begin from a clean state.
Before diving into more technical details, we need to become familiar with two basic concepts in IPsec protocol, security association (SA) and security policy (SP). An SA defines the security parameters, for example, the crypto algorithm to be used, to create a secure connection between two systems. An SP, on the other hand, is the security rule defining the security context to be used between the two systems. For example, an SP can specify that we need to use encryption between my desktop and a remote system on the Internet. An SA then is the effective secure connection created between my desktop and that system. Be aware that SAs are unidirectional.
In our scenario, we define two SPs between reblochon and gouda. An SP is defined as:
source | destination | on which kind of traffic to apply the policy (TCP, UDP, port, any) | the direction in/out | what to do (IPsec/discard/none) | (esp/ah) / (transport/tunnel) / (IP address of both ends of the tunnel) not required in transport mode / require.
For example, these lines:
spdadd 192.168.0.1 192.168.0.2 any -P out IPsec esp/transport//require ah/transport//require;
declare a security policy stating that any packets coming from 192.168.0.1 and going to 192.168.0.2 should use IPsec on transport mode with ESP and AH functionality.
Now that you defined the policy between your systems, you need to define SAs in order to be able to achieve that policy. You need two SAs for communication, one from gouda to reblochon and one from reblochon to gouda. The two SAs do not need to use the same algorithm. In fact, unlike this example, for better security you should not use the same key for both SAs.
You define a SA as
source | destination | ah/esp | SPI (Security Policy Index) any number but should be unique | algorithm and associated secret key.
For example, these lines:
add 192.168.0.1 192.168.0.2 esp 1001 -E 3des-cbc "123456789012123456789012" -A hmac-sha1 "12345678901234567890";
define that if you want to use ESP on a packet going from gouda to reblochon, you should use 3DES as the encryption algorithm with the quoted text as the key and SHA1 as the authentication algorithm.
Now, you finally can run the script on both nodes. You can check the status of different SAs established by using setkey -D. If you want to see existing policies on your system, you can use setkey -DP. At the end, to be sure that the traffic between two systems actually is encrypted, you can use Ethereal to monitor the traffic between two nodes. For example, in Figure 1, we show the traffic between two systems exchanging messages containing the "hello world" text. As you see, the message is encrypted between gouda and reblochon.
|HPC Cluster Grant Accepting Applications!||Jan 28, 2015|
|Sharing Admin Privileges for Many Hosts Securely||Jan 28, 2015|
|Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform||Jan 23, 2015|
|Designing with Linux||Jan 22, 2015|
|Wondershaper—QOS in a Pinch||Jan 21, 2015|
|Ideal Backups with zbackup||Jan 19, 2015|
- Designing with Linux
- Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform
- Wondershaper—QOS in a Pinch
- HPC Cluster Grant Accepting Applications!
- Internet of Things Blows Away CES, and it May Be Hunting for YOU Next
- Ideal Backups with zbackup
- Sharing Admin Privileges for Many Hosts Securely
- Slow System? iotop Is Your Friend
- Hats Off to Mozilla
- diff -u: What's New in Kernel Development
Editorial Advisory Panel
Thank you to our 2014 Editorial Advisors!
- Jeff Parent
- Brad Baillio
- Nick Baronian
- Steve Case
- Chadalavada Kalyana
- Caleb Cullen
- Keir Davis
- Michael Eager
- Nick Faltys
- Dennis Frey
- Philip Jacob
- Jay Kruizenga
- Steve Marquez
- Dave McAllister
- Craig Oda
- Mike Roberts
- Chris Stark
- Patrick Swartz
- David Lynch
- Alicia Gibb
- Thomas Quinlan
- Carson McDonald
- Kristen Shoemaker
- Charnell Luchich
- James Walker
- Victor Gregorio
- Hari Boukis
- Brian Conner
- David Lane