IPSEC over GRE в CentOs
Создаем в /etc/sysconfig/network-scripts/ifcfg-gre1
ONBOOT=YES
DEVICE=gre1
IPADDR=10.100.0.2 # Внутренний адрес туннеля
MY_INNER_IPADDR=10.100.0.2 # Внутренний адрес туннеля
MY_OUTER_IPADDR=2.2.2.2 # Внешний адрес на котором будем создавать туннель
PEER_INNER_IPADDR=10.100.0.1 # Внутренний адрес туннеля с другой стороны
PEER_OUTER_IPADDR=3.3.3.3 # Внешний адрес куда будет создаваться туннель
2. Добавляем на /etc/rc.d/rc.local
iptunnel add gre1 mode gre remote 3.3.3.3 local 2.2.2.2 dev eth1
Ставим если нет репозитарии (CentOS 6).
rpm -ivH http://repo.nikoforge.org/redhat/el6/nikoforge-release-latest
3. yum install ipsec-tools
4. Правим /etc/racoon/racoon.conf
# Racoon IKE daemon configuration file.
# See 'man racoon.conf' for a description of the format and entries.
path include "/etc/racoon";
path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";
path script "/etc/racoon/scripts";
sainfo anonymous
{
pfs_group 2;
lifetime time 1 hour ;
encryption_algorithm 3des, aes 256, blowfish 448, rijndael ;
authentication_algorithm hmac_sha1, hmac_md5 ;
compression_algorithm deflate ;
}
include "/etc/racoon/3.3.3.3.conf";
#remote <IP-of-Cisco-ASA>
#{
# exchange_mode main;
# my_identifier fqdn "host.name.of.vpn.client";
# certificate_type x509 "client.crt" "client.key";
# ca_type x509 "ca.crt";
# mode_cfg on;
# script "p1_up_down" phase1_up;
# script "p1_up_down" phase1_down;
# proposal
# {
# encryption_algorithm 3des;
# hash_algorithm sha1;
# authentication_method xauth_rsa_client;
# dh_group 2;
# }
#}
5. Создаем /etc/racoon/3.3.3.3.conf
remote 3.3.3.3
{
exchange_mode aggressive, main;
my_identifier address;
proposal {
encryption_algorithm aes 256;
hash_algorithm sha1;
authentication_method pre_shared_key;
dh_group 2;
}
}
6. Правим /etc/racoon/psk.txt
3.3.3.3 KakoitoParol
7. Создаем правила безопасности
setkey -c << EOF
flush;
spdflush;
spdadd 2.2.2.2/24 3.3.3.3/24 gre -P out ipsec esp/tunnel/2.2.2.2-3.3.3.3/require;
spdadd 3.3.3.3/24 2.2.2.2/24 gre -P in ipsec esp/tunnel/3.3.3.3-2.2.2.2/require;
EOF
8. service network restart
service racoon start
9. Правим iptables
# gre
$IPT -A INPUT -i $GRE_IFACE -j ACCEPT
$IPT -A OUTPUT -o $GRE_IFACE -j ACCEPT
# Разрешаем пересылку трафика из локальной сети через GRE-туннель в другой офис и обратно
$IPT -A FORWARD -i $GRE_IFACE -j ACCEPT
$IPT -A FORWARD -0 $GRE_IFACE -j ACCEPT
10. То же самое делаем на другом конце, но меняем местами IP адреса.
11. Проверить: tailf /var/log/messages | grep racoon