Ciao, avendo due immobili con relativa connettività e in ognuno un bel DGA4130 (AGTEF) ho voluto tentare di collegarli tra loro tramite vpn ipsec lan-to-lan
Non è stato facile ma alla fine il tunnel è andato up e le due reti sono "fuse" in un'unica grande rete!
Prerequisiti:- DGA413x rootato (la gui è consigliata ma non indispensabile)
- Firmware basato su kernel 4.1
- Ip pubblico statico o DDNS
- Repository Ansuel
src/gz chaos_calmer_base https://raw.githubusercontent.com/Ansuel/GUI_ipk/kernel-4.1/base
src/gz chaos_calmer_packages https://raw.githubusercontent.com/Ansuel/GUI_ipk/kernel-4.1/packages
src/gz chaos_calmer_luci https://raw.githubusercontent.com/Ansuel/GUI_ipk/kernel-4.1/luci
src/gz chaos_calmer_routing https://raw.githubusercontent.com/Ansuel/GUI_ipk/kernel-4.1/routing
src/gz chaos_calmer_telephony https://raw.githubusercontent.com/Ansuel/GUI_ipk/kernel-4.1/telephony
src/gz chaos_calmer_core https://raw.githubusercontent.com/Ansuel/GUI_ipk/kernel-4.1/target/packages
Le operazioni seguenti sono da effettuare su
entrambi i DGA413x:
1) Installare il parckage strongswan-default
opkg update
opkg install strongswan-default
2) Configurare i files come negli esempi:
/etc/ipsec.conf
/etc/ipsec.secrets
/etc/firewall.user
/etc/config/firewall
3) Avviare il tunnel con il comando
ipsec start
ConfiguarazioneAssumiamo che questi siano i due network:
SIDEA
Subnet 192.168.1.0/24
DDNS sidea.ddns.net
SIDEB
Subnet 192.168.2.0/24
DDNS sideb.ddns.net
CONFIG MODEM IN SIDEA/etc/ipsec.conf
versionon 2
config setup
conn sidea-lan
keyexchange=ikev2
authby=secret
left=sidea.ddns.net
right=sideb.ddns.net
leftsubnet=192.168.1.0/24
rightsubnet=192.168.2.0/24
auto=route
leftid=sidea
rightid=sideb
esp=aes128-sha1-modp1024
ike=aes128-sha1-modp1024
type=tunnel
keylife=3600s
/etc/ipsec.secrets
# /etc/ipsec.secrets - strongSwan IPsec secrets file
sidea sideb : PSK "Questaèlapasswordchevolete"
Per quanto riguarda il modem in SIDEB dovete solo invertire tutti i valori di left <-> right
Poi aggiungete queste righe al file/etc/firewall.user
iptables -I INPUT -m policy --dir in --pol ipsec --proto esp -j ACCEPT
iptables -I FORWARD -m policy --dir in --pol ipsec --proto esp -j ACCEPT
iptables -I FORWARD -m policy --dir out --pol ipsec --proto esp -j ACCEPT
iptables -I OUTPUT -m policy --dir out --pol ipsec --proto esp -j ACCEPT
Poi aggiungete queste righe al file /etc/confg/firewall
config zone
option name 'vpn'
option network 'vpn'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option subnet '192.168.2.0/24' ##NOTATE BENE QUESTA è LA SUBNET REMOTA E VA INVERTITA TRA I DUE MODEM
option extra_src '-m policy --dir in --pol ipsec --proto esp'
option extra_dest '-m policy --dir out --pol ipsec --proto esp'
option mtu_fix '1'
config forwarding
option src 'vpn'
option dest 'lan'
config forwarding
option src 'lan'
option dest 'vpn'
config forwarding
option src 'vpn'
option dest 'wan'
config rule
option name 'IPSec-ESP'
option src 'wan'
option proto 'esp'
option target 'ACCEPT'
config rule
option name 'IPSec-IKE'
option src 'wan'
option dest_port '500'
option proto 'udp'
option target 'ACCEPT'
config rule
option name 'IPSec-NAT-T'
option src 'wan'
option dest_port '4500'
option proto 'udp'
option target 'ACCEPT'
config rule
option name 'IPSec-Auth-Header'
option src 'wan'
option proto 'ah'
option target 'ACCEPT'
config rule
option name 'Allow-Ping-From-VPN'
option src 'vpn'
option proto 'igmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-Ping-To-VPN'
option dest 'vpn'
option proto 'igmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
dopo la modifica del firewall date il comando:
/etc/init.d/firewall reloadSe avete effettuato correttamente tutte le modifiche potete dare il comando:
ipsec startDopo qualche istante dovreste vedere il tunnel stabilito e potete verificarlo con il comando:
ipsec statusDovreste avere un output del genere:
Routed Connections:
sideb-lan{1}: ROUTED, TUNNEL, reqid 1
sideb-lan{1}: 192.168.1.0/24 === 192.168.2.0/24
Security Associations (1 up, 0 connecting):
sideb-lan[45]: ESTABLISHED 1 minutes ago, x.x.x.x[sidea]...x.x.x.x[sideb]
sideb-lan{88}: INSTALLED, TUNNEL, reqid 1, ESP SPIs: cf34cfb4_i c94facf9_o
sideb-lan{88}: 192.168.1.0/24 === 192.168.2.0/24
Spero la mia piccola guida sia chiara e possa esser utile ad altri
