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!
- Back to Backups
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Google's Abacus Project: It's All about Trust
- Secure Desktops with Qubes: Introduction
- Fancy Tricks for Changing Numeric Base
- Seeing Red and Getting Sleep
- Secure Desktops with Qubes: Installation
- Working with Command Arguments
- Linux Mint 18
- CentOS 6.8 Released
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide