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.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Profiles and RC Files
- Understanding Ceph and Its Place in the Market
- Git 2.9 Released
- Astronomy for KDE
- Maru OS Brings Debian to Your Phone
- OpenSwitch Finds a New Home
- What's Our Next Fight?
- The Giant Zero, Part 0.x
- Snappy Moves to New Platforms
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide