TCP/IP
Arnaud Aubert
TCP/IP . , , . , TCP/IP , , . , , HTTP, POP3, telnet .
IPsec, IESG (Internet Engineering Steering Group - ), , . IP :
Authentication Header (AH) , anti-replay . 100%, MITM, .. .
Encapsulating Security Payload (ESP) () . ESP , anti-replay . . ESP.
, . MD5 SHA1 , DES, 3DES, Blowfish .
IPsec , , IP , , . .
, , , Security Association Database - SADB. (security associations, SA), , , :
(ESP AH)
8- , Security Parameter Index SPI. .
( ESP).
( ESP ).
. , ; .
, , . .
IPsec Solaris/Linux
Linux IPsec:
FreeSWAN IPsec . , . : openSWAN strongSWAN.
KAME BSD . Linux , 2.5.47 , Red Hat Enterprise Linux. Linux.
IPsec Solaris 9 192.168.1.201 Red Hat Enterprise Linux 3 ES host 192.168.1.203. ESP DES MD5 .

(Policy Database)
Solaris /usr/sbin/ipsecconf. /etc/inet/ipsecinit.conf. -a policyfile, . Solaris 192.168.1.203, ESP Linux. Solaris IPsec 192.168.1.203:
#!/usr/sbin/ipsecconf -a
{ raddr 192.168.1.203 } ipsec { encr_algs any encr_auth_algs any }
Solaris, IPsec ipsecconf. :
-a IPsec.
-f IPsec.
-l .
, , IPsec .
KAME setkey. KAME stdin f. Solaris, .
Solaris:
#!/sbin/setkey -f
# Secure outgoind communications
spdadd 192.168.1.203 192.168.1.201 any -P out ipsec esp/transport//require;
# Secure ingoing communications
spdadd 192.168.1.201 192.168.1.203 any -P in ipsec esp/transport//require;
setkey KAME . :
-f filename KAME.
-DP -FP .
-D -F .
spdadd : src_range dst_range proto_to_secure -P in|out policy.
KAME ( -P in|out). Solaris raddr .
(Security Association Database)
, .. , . /etc/inet/secret/ipseckeys Solaris. ipseckey -f filename. .
Solaris , :
#!/usr/sbin/ipseckey -f
add esp spi 0x10001 src 192.168.1.201 dst 192.168.1.203 \
encralg DES encrkey 0123456789abcdef authalg MD5 authkey \
0123456789abcdef0123456789abcdef
add esp spi 0x10002 src 192.168.1.203 dst 192.168.1.201 \
encralg DES encrkey fedcba9876543210
authalg MD5 authkey fedcba9876543210fedcba9876543210
KAME setkey:
#!/sbin/setkey -f
add 192.168.1.2O1 192.168.1.203 esp 0x10001 -E \
des-cbc 0x0123456789abcdef -A hmac-md5 0x \
0123456789abcdef0123456789abcdef;
add 192.168.1.2O3á192.168.1.201 esp 0x10002 -E des-cbc \
0xfedcba9876543210 -A hmac-md5 0x fedcba9876543210fedcba9876543210;
, 0x10001 0x10002 (Security Parameter Indexes - SPI). SADB . , . telnet :
# tcpdump host 192.168.1.101
18:07:51.910553 test1 > test3: ESP(spi=0x00010002,seq=0x1e2) (DF)
18:07:51.910754 test3 > test1: ESP(spi=0x00010001,seq=0x191) (DF) [tos 0x10]
18:07:51.912927 test3 > test1: ESP(spi=0x00010001,seq=0x192) (DF) [tos 0x10]
18:07:51.953335 test1 > test3: ESP(spi=0x00010002,seq=0x1e3) (DF)
18:07:51.953436 test3 > test1: ESP(spi=0x00010001,seq=0x193) (DF) [tos 0x10]
18:07:52.003291 test1 > test3: ESP(spi=0x00010002,seq=0x1e4) (DF)
. SPI, IPsec . tcpdump , .
IPsec
IPsec , . . , Internet. , .
: Linux 172.17.0.0/16 eth1 172.17.0.1; Solaris 172.16.0.0/16 sfe1 172.16.0.1.
Solaris ipsecconf f IP-IP . . ESP DES MD5 encr_algs encr_auth_algs ifconfig:
#!/bin/sh
ipsecconf -f
ndd -set /dev/ip ip_forwarding 0
ndd -set /dev/ip ip_strict_dst_multihoming 1
ifconfig ip.tun0 plumb
ifconfig ip.tun0 172.16.0.1 172.17.0.1 tsrc 192.168.1.201 tdst 192.168.1.203
ifconfig ip.tun0 encr_algs DES encr_auth_algs MD5
ifconfig ip.tun0 up
ndd -set /dev/ip sfe1:ip_forwarding 1
ndd -set /dev/ip ip.tun0:ip_forwarding 1
Linux/KAME:
#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
ip tunnel add mytun mode ipip remote 192.168.1.201 local 192.168.1.203
ifconfig mytun 172.17.0.1
route add -net 172.16.0.0/16 dev mytun
setkey -c << EOF
spdflush;
flush;
add 192.168.1.201 192.168.1.203 esp 0x10001 -m tunnel -E des-cbc \
0x0123456789abcdef -A hmac-md5 0x0123456789abcdef0123456789abcdef;
add 192.168.1.203 192.168.1.201 esp 0x10002 -m tunnel -E des-cbc \
0xfedcba9876543210 -A hmac-md5 0xfedcba9876543210fedcba9876543210;
spdadd 172.16.0.0/16 172.17.0.0/16 any -P in ipsec \
esp/tunnel/192.168.1.201-192.168.1.203/require;
spdadd 172.17.0.0/16 172.16.0.0/16 any -P out ipsec \
esp/tunnel/192.168.1.203-192.168.1.201/require;
EOF
spdflush flush, , .
, Linux m. 172.16.0.0/16 172.17.0.0/16 192.168.1.0/24, 192.168.1.203 192.168.1.201.
IPsec Internet Key Exchange IKE (RFC 2409). . , , IKE . IKE :
1 (a.k.a. - Main Mode) ISAKMP (Internet Security Association and Key Management Protocol). . , , . , X.509.
2 (a.k.a. - Quick Mode) ISAKMP SADB. SADB setkey -D Linux ipseckey dump Solaris.
, , 3DES, . . , ipsecconf f SADB ipseckey flush. , 3DES Solaris:
#!/usr/sbin/ipsecconf -a
{ raddr 192.168.1.203 } ipsec { encr_algs 3des encr_auth_algs md5 }
The same would be done on Linux/KAME using:
#!/sbin/setkey -f
spdflush;
spdadd 192.168.1.203 192.168.1.201 any -P out ipsec esp/transport//require;
spdadd 192.168.1.201 192.168.1.203 any -P in ipsec esp/transport//require;
SPD , IKE.
IKE Solaris
Solaris. /etc/inet/ike/config, in.iked :
{
label "Partnership with Linux/Racoon"
local_addr 192.168.1.201
remote_addr 192.168.1.203
local_id_type ip
p1_xform { auth_method preshared oakley_group 2 auth_alg md5 encr_alg 3des }
}
IKE (label). (local_addr) (remote_addr) . , p1_xform . man ike.config (4).
IKE local_addr remote_addr . p1_xform , . oakley_group . .
, IKE. Solaris etc/inet/secret/ike.preshared . SunOS . "AAAAAAAA":
{
localidtype IP
localid 192.168.1.201
remoteidtype IP
remoteid 192.168.1.203
key 4141414141414141
}
. . Localid remoteid localidtype remoteidtype, , ( IP ).
/usr/lib/inet/in.iked -f /etc/inet/ike/config , .
IKE Racoon
KAME racoon, . /etc/racoon/racoon.conf , Solaris, , .
path include '/etc/racoon';
path pre_shared_key '/etc/racoon/psk.txt'
# Phase 1 - Configuration
remote anonymous
{
exchange_mode main;
proposal { encryption_algorithm 3des; hash_algorithm md5; \
authentication_method pre_shared_key; dh_group 2; }
}
# Phase 2 - Configuration
sainfo anonymous
{
encryption_algorithm 3des ;
authentication_algorithm hmac_md5;
compression_algorithm deflate;
}
(Phase 1), (Phase 2) racoon.conf. p1_xform Solaris. Compression_algorithm , , (IPComp).
/etc/racoon/psk.txt - "AAAAAAAA" :
192.168.1.101 0x4141414141414141
racoon -f /etc/racoon/racoon.conf.
raccoon in.iked . tcpdump , SPI, :
# tcpdump host 192.168.1.201
tcpdump: listening on eth0
19:39:26.127175 test1 > test3: ESP(spi=0x06db34e8,seq=0x3) (DF)
19:39:26.127284 test3 > test1: ESP(spi=0x7aa657a6,seq=0x2)
2 packets received by filter
0 packets dropped by kernel
IPsec. , .