特殊:Badtitle/NS100:IPSecHowTo
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/IPSecHowTo }} |
点击翻译: |
English {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/af | • {{#if: php5|Afrikaans| [[::IPSecHowTo/af|Afrikaans]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/ar | • {{#if: php5|العربية| [[::IPSecHowTo/ar|العربية]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/az | • {{#if: php5|azərbaycanca| [[::IPSecHowTo/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/bcc | • {{#if: php5|جهلسری بلوچی| [[::IPSecHowTo/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/bg | • {{#if: php5|български| [[::IPSecHowTo/bg|български]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/br | • {{#if: php5|brezhoneg| [[::IPSecHowTo/br|brezhoneg]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/ca | • {{#if: php5|català| [[::IPSecHowTo/ca|català]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/cs | • {{#if: php5|čeština| [[::IPSecHowTo/cs|čeština]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/de | • {{#if: php5|Deutsch| [[::IPSecHowTo/de|Deutsch]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/el | • {{#if: php5|Ελληνικά| [[::IPSecHowTo/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/es | • {{#if: php5|español| [[::IPSecHowTo/es|español]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/fa | • {{#if: php5|فارسی| [[::IPSecHowTo/fa|فارسی]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/fi | • {{#if: php5|suomi| [[::IPSecHowTo/fi|suomi]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/fr | • {{#if: php5|français| [[::IPSecHowTo/fr|français]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/gu | • {{#if: php5|ગુજરાતી| [[::IPSecHowTo/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/he | • {{#if: php5|עברית| [[::IPSecHowTo/he|עברית]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/hu | • {{#if: php5|magyar| [[::IPSecHowTo/hu|magyar]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/id | • {{#if: php5|Bahasa Indonesia| [[::IPSecHowTo/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/it | • {{#if: php5|italiano| [[::IPSecHowTo/it|italiano]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/ja | • {{#if: php5|日本語| [[::IPSecHowTo/ja|日本語]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/ko | • {{#if: php5|한국어| [[::IPSecHowTo/ko|한국어]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/ksh | • {{#if: php5|Ripoarisch| [[::IPSecHowTo/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/mr | • {{#if: php5|मराठी| [[::IPSecHowTo/mr|मराठी]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/ms | • {{#if: php5|Bahasa Melayu| [[::IPSecHowTo/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/nl | • {{#if: php5|Nederlands| [[::IPSecHowTo/nl|Nederlands]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/no | • {{#if: php5|norsk| [[::IPSecHowTo/no|norsk]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/oc | • {{#if: php5|occitan| [[::IPSecHowTo/oc|occitan]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/pl | • {{#if: php5|polski| [[::IPSecHowTo/pl|polski]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/pt | • {{#if: php5|português| [[::IPSecHowTo/pt|português]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/ro | • {{#if: php5|română| [[::IPSecHowTo/ro|română]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/ru | • {{#if: php5|русский| [[::IPSecHowTo/ru|русский]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/si | • {{#if: php5|සිංහල| [[::IPSecHowTo/si|සිංහල]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/sq | • {{#if: php5|shqip| [[::IPSecHowTo/sq|shqip]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/sr | • {{#if: php5|српски / srpski| [[::IPSecHowTo/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/sv | • {{#if: php5|svenska| [[::IPSecHowTo/sv|svenska]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/th | • {{#if: php5|ไทย| [[::IPSecHowTo/th|ไทย]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/tr | • {{#if: php5|Türkçe| [[::IPSecHowTo/tr|Türkçe]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/vi | • {{#if: php5|Tiếng Việt| [[::IPSecHowTo/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/yue | • {{#if: php5|粵語| [[::IPSecHowTo/yue|粵語]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/zh | • {{#if: php5|中文| [[::IPSecHowTo/zh|中文]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/zh-hans | • {{#if: php5|中文(简体)| [[::IPSecHowTo/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}IPSecHowTo}}/zh-hant | • {{#if: php5|中文(繁體)| [[::IPSecHowTo/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:php5|:IPSecHowTo|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :IPSecHowTo/zh | | {{#ifexist: IPSecHowTo/zh | | {{#ifeq: {{#titleparts:IPSecHowTo|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:IPSecHowTo|1|-1|}} | zh | | }}
This howto is primarily taken from IPSec - Linux Kernel 2.6 using KAME-tools; the native IPSec stack in the 2.6 kernel series.
This covers using manually-keyed connections, and is geared toward very small or primarily star toplogy networks (an NIS server and all it's clients, for example). Larger networks (if all the NIS clients want to talk to each other in an encrypted fashion) would benefit from the use of an automated keying agent, such as racoon
. Discussion of such agents is outside the scope of this draft of this document (maybe later).
1. Install the tools:
sudo apt-get install ipsec-tools
2. Edit /etc/ipsec-tools.conf file. This file should be of the general form:
#!/usr/sbin/setkey -f # Configuration for 192.168.1.100 # Flush the SAD and SPD flush; spdflush; # Attention: Use this keys only for testing purposes! # Generate your own keys! # AH SAs using 128 bit long keys add 192.168.1.100 192.168.2.100 ah 0x200 -A hmac-md5 0xc0291ff014dccdd03874d9e8e4cdf3e6; add 192.168.2.100 192.168.1.100 ah 0x300 -A hmac-md5 0x96358c90783bbfa3d7b196ceabe0536b; # ESP SAs using 192 bit long keys (168 + 24 parity) add 192.168.1.100 192.168.2.100 esp 0x201 -E 3des-cbc 0x7aeaca3f87d060a12f4a4487d5a5c3355920fae69a96c831; add 192.168.2.100 192.168.1.100 esp 0x301 -E 3des-cbc 0xf6ddb555acfd9d77b03ea3843f2653255afe8eb5573965df; # Security policies spdadd 192.168.1.100 192.168.2.100 any -P out ipsec esp/transport//require ah/transport//require; spdadd 192.168.2.100 192.168.1.100 any -P in ipsec esp/transport//require ah/transport//require;
It is important to understand this, so let me break it down:
# AH SAs using 128 bit long keys add 192.168.1.100 192.168.2.100 ah 0x200 -A hmac-md5 0xc0291ff014dccdd03874d9e8e4cdf3e6; add 192.168.2.100 192.168.1.100 ah 0x300 -A hmac-md5 0x96358c90783bbfa3d7b196ceabe0536b;
This section lists the 128 bit keys for the 192.168.2.100 and 192.168.1.100 connection. Each IP pair has 2 keys - one for each direction (in and out). Each pair of machines needs to know the this information. So, this means that, for each pair of IP's, you need to generate a new key (hence why this works for small networks, but anything major probably wants a daemon to handle this. Maybe if I feel ambitious, I'll set mine up to use it and update this with that info).
Also, note the number right after the 'ah' for each of these keys. This number needs to be unique for each 'add' statement. These keys are generated as follows:
dd if=/dev/random count=16 bs=1| xxd -ps
Don't forget to add the 0x in front of it.
Similarly, this section:
# ESP SAs using 192 bit long keys (168 + 24 parity) add 192.168.1.100 192.168.2.100 esp 0x201 -E 3des-cbc 0x7aeaca3f87d060a12f4a4487d5a5c3355920fae69a96c831; add 192.168.2.100 192.168.1.100 esp 0x301 -E 3des-cbc 0xf6ddb555acfd9d77b03ea3843f2653255afe8eb5573965df;
This works just like the AH keys, except that they are longer. Again, the number after 'esp' must be unique. These keys are generated as follows:
dd if=/dev/random count=24 bs=1| xxd -ps
Again, don't forget to add the 0x in front of it.
So, these top two sections should list keys for all the IP addresses that the machine cares about. These sections do not change when moving the file amongst machines on either side of a connection. That brings us to the next section:
# Security policies spdadd 192.168.1.100 192.168.2.100 any -P out ipsec esp/transport//require ah/transport//require; spdadd 192.168.2.100 192.168.1.100 any -P in ipsec esp/transport//require ah/transport//require;
This sets up the policies for in and out communications. So, the above version will work for 192.168.1.100, because all outgoing communication to 192.168.2.100 and all incoming communication from 192.168.2.100 will be encrypted. To use this on the other machine (192.168.2.100), flip the in and out directives, as follows:
# Security policies spdadd 192.168.1.100 192.168.2.100 any -P in ipsec esp/transport//require ah/transport//require; spdadd 192.168.2.100 192.168.1.100 any -P out ipsec esp/transport//require ah/transport//require;
3. Make the conf file not readable to the world:
sudo chmod 750 ipsec-tools.conf
Okay, do both sides of the connection have an ipsec-tools.conf? Everyone set? Good, now it gets easy.
4. It will be started at boot by default on systems, so you don't have to worry about that.
5. Also, starting it wouldn't hurt either (make sure to do this on both sides of the connection before trying to have them talk to each other; you could also reboot):
sudo /etc/init.d/setkey start
CategoryDocumentation CategoryCleanup