echo net.ipv4.ip_forward=1 >>/etc/sysctl.d/ipv4.forward.enable.conf sysctl -a
firewall-cmd --zone=dmz --permanent --add-rich-rule='rule protocol value="esp" accept' firewall-cmd --zone=dmz --permanent --add-port=500/udp firewall-cmd --zone=dmz --permanent --add-port=4500/udp firewall-cmd --permanent --add-service="ipsec" firewall-cmd --reload firewall-cmd --list-all
yum install -y epel-release yum install -y strongswan
charon { # Cisco IKEv2 make_before_break = yes # install_routes = no }
systemctl stop strongswan
connections { ToWorld { local_addrs = 10.3.3.1 version = 1 proposals = aes256-sha1-modp1536 reauth_time = 1440m local { auth = psk } remote { auth = psk } children { ToWorld-1 { local_ts = dynamic[gre] remote_ts = dynamic[gre] mode = transport esp_proposals = aes128-sha1-modp1536 rekey_time = 60m start_action = trap dpd_action = restart } } } } secrets { ike-To-2951 { id = 1.1.1.1 secret = "etokto2ttakoimohnatenkyi" } ike-To-CSR1000V { id = 2.2.2.2 secret = "zdorovkakzhiznkasampro100klass" } }
connections { To2951 { encap = no remote_addrs = 1.1.1.1 version = 1 proposals = aes256-sha1-modp1536 reauth_time = 1440m fragmentation = yes local-1 { auth = psk id = 10.3.3.1 } remote-1 { auth = psk } children { To2951-1 { local_ts = 10.3.3.1/32[gre] remote_ts = 1.1.1.1/32[gre] mode = transport esp_proposals = aes128-sha1-modp1536 rekey_time = 60m start_action = start dpd_action = restart } } } ToCSR1000V { encap = no remote_addrs = 2.2.2.2 version = 1 proposals = aes256-sha1-modp1536 reauth_time = 1440m fragmentation = yes local-1 { auth = psk id = 10.3.3.1 } remote-1 { auth = psk } children { ToCSR1000V-1 { local_ts = 10.3.3.1/32[gre] remote_ts = 2.2.2.2/32[gre] mode = transport esp_proposals = aes128-sha1-modp1536 rekey_time = 60m start_action = start dpd_action = restart } } } } secrets { ike-To-2951 { id-1 = 1.1.1.1 secret = "etokto2ttakoimohnatenkyi" } ike-To-CSR1000V { id-1 = 2.2.2.2 secret = "zdorovkakzhiznkasampro100klass" } }
sudo systemctl enable strongswan-swanctl sudo systemctl start strongswan-swanctl
/etc/sysconfig/network-scripts/ifcfg-Tunnel13
NAME=Tunnel13 DEVICE=Tunnel13 ONBOOT=yes STARTMODE=onboot BOOTPROTO=none TYPE=GRE PEER_OUTER_IPADDR=1.1.1.1 PEER_INNER_IPADDR=172.16.130.2/30 MY_INNER_IPADDR=172.16.130.1/30 MY_OUTER_IPADDR=10.3.3.1 ZONE=trusted TTL=30 MTU=1400
/etc/sysconfig/network-scripts/ifcfg-Tunnel23
NAME=Tunnel23 DEVICE=Tunnel23 ONBOOT=yes STARTMODE=onboot BOOTPROTO=none TYPE=GRE PEER_OUTER_IPADDR=2.2.2.2 PEER_INNER_IPADDR=172.16.230.2/30 MY_INNER_IPADDR=172.16.230.1/30 MY_OUTER_IPADDR=10.3.3.1 ZONE=trusted TTL=30 MTU=1400
ifup Tunnel13 ifup Tunnel23
crypto keyring StrongSwanKeyring pre-shared-key address 3.3.3.1 key etokto2ttakoimohnatenkyi crypto isakmp policy 60 encr aes 256 authentication pre-share group 5 crypto isakmp identity address crypto isakmp profile StrongSwanIsakmpProfile keyring StrongSwanKeyring match identity address 3.3.3.1 crypto ipsec transform-set StrongSwanTransformSet esp-aes esp-sha-hmac mode transport crypto ipsec profile StrongSwanIpsecProfile set transform-set StrongSwanTransformSet set pfs group5 set isakmp-profile StrongSwanIsakmpProfile interface Tunnel13 ip address 172.16.130.2 255.255.255.252 tunnel source GigabitEthernet2 tunnel destination 3.3.3.1 tunnel protection ipsec profile StrongSwanIpsecProfile
crypto keyring StrongSwanKeyring pre-shared-key address 3.3.3.1 key etokto2ttakoimohnatenkyi crypto isakmp policy 60 encr aes 256 authentication pre-share group 5 crypto isakmp identity address crypto isakmp profile StrongSwanIsakmpProfile keyring StrongSwanKeyring match identity address 3.3.3.1 crypto ipsec transform-set StrongSwanTransformSet esp-aes esp-sha-hmac mode transport crypto ipsec profile StrongSwanIpsecProfile set transform-set StrongSwanTransformSet set pfs group5 set isakmp-profile StrongSwanIsakmpProfile interface Tunnel23 ip address 172.16.230.2 255.255.255.252 tunnel source GigabitEthernet2 tunnel destination 3.3.3.1 tunnel protection ipsec profile StrongSwanIpsecProfile
strongswan statusall
show crypto session detail
yum install -y quagga
/etc/quagga/zebra.conf
hostname StrongSwanServer log file /var/log/quagga/quagga.log ! interface Tunnel13 ip address 172.16.130.1/30 ! interface Tunnel23 ip address 172.16.230.1/30 !
chown quagga:quaggavt /etc/quagga/zebra.conf systemctl enable zebra.service systemctl start zebra.service
/etc/quagga/ospfd.conf
log file /var/log/quagga/ospfd.log ! router ospf ospf router-id 10.3.3.1 passive-interface default no passive-interface Tunnel13 no passive-interface Tunnel23 network 172.16.130.0/30 area 0.0.0.0 network 172.16.230.0/30 area 0.0.0.0
chown quagga:quaggavt /etc/quagga/ospfd.conf systemctl enable ospfd.service systemctl start ospfd.service
vtysh show running-config
router ospf 1 passive-interface default no passive-interface Tunnel12 no passive-interface Tunnel13 no passive-interface GigabitEthernet1 network 192.168.1.0 0.0.0.255 area 0 network 172.16.120.0 0.0.0.3 area 0 network 172.16.130.0 0.0.0.3 area 0
router ospf 1 passive-interface default no passive-interface Tunnel12 no passive-interface Tunnel23 no passive-interface GigabitEthernet1 network 192.168.2.0 0.0.0.255 area 0 network 172.16.120.0 0.0.0.3 area 0 network 172.16.230.0 0.0.0.3 area 0
vtysh show ospf neighbor show ip ospf route
show ospf neighbor show ip ospf route
Source: https://habr.com/ru/post/354490/
All Articles