我想要创建一个两个Solaris10隧道,用ipsec.Configuration加密是简单的:2个solaris10节点,lan不加密,隧道加密。Lan是e1000g0,隧道是ip.tun0,Ip是node1是192.168.0.21 Ip是node2是192.168.0.199我做了这个过程
(A)在两个节点中启用ipv4转发和路由
routeadm -u -e ipv4-routing
routeadm -u -e ipv4-forwarding(B)在两个节点上编辑/etc/inet/ike/config
p1_xform
{ auth_method preshared oakley_group 5 auth_alg sha encr_alg 3des }
p2_pfs 2(C)在两个节点上进行编辑/etc/inet/秘/inet,当然是反向本地/远程。
{ localidtype IP
localid 192.168.0.21
remoteidtype IP
remoteid 192.168.0.119
}D)在两个节点上启用IKE,svcs确认正在工作。
svcadm enable ike
svcs ike(E)编辑文件/etc/inet/ipsecinit.conf
# LAN traffic to and from this host can bypass IPsec.
{laddr 192.168.0.0 dir both} bypass {}
# WAN traffic uses ESP with AES and SHA-1.
{tunnel ip.tun0 negotiate tunnel}
ipsec {encr_algs aes encr_auth_algs sha1 sa shared}F)刷新..。
svcadm refresh ipsec/policy)看起来一切正常,所以我创建了隧道。
svcs -a|grep -i ipsec
disabled 9:35:34 svc:/network/ipsec/manual-key:default
online 9:35:53 svc:/network/ipsec/ipsecalgs:default
online 9:35:53 svc:/network/ipsec/ike:default
online 9:54:38 svc:/network/ipsec/policy:default论HostA
ifconfig ip.tun0 plumb
ifconfig ip.tun0 192.168.192.24 192.168.192.40 tsrc 192.168.0.21 tdst 192.168.0.199 router up论HostB
ifconfig ip.tun0 plumb
ifconfig ip.tun0 192.168.192.40 192.168.192.24 tsrc 192.168.0.199 tdst 192.168.0.21 router up看起来很好但是.不要工作。
HostA can ping HostB
ping 192.168.0.199
192.168.0.199 is aliveHostB can ping HostA
ping 192.168.0.2
192.168.0.2 is alive但如果我打开隧道..。
从HostA到HostB
ping -s 192.168.192.40
PING 192.168.192.40: 56 data bytes
----192.168.192.40 PING Statistics----
25 packets transmitted, 0 packets received, 100% packet loss从HostB到HostA
ping -s 192.168.192.24
PING 192.168.192.24: 56 data bytes
----192.168.192.24 PING Statistics----
25 packets transmitted, 0 packets received, 100% packet loss关于hostA,netstat -rn说
netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ---------- ---------
default 192.168.0.1 UG 1 1
192.168.0.0 192.168.0.21 U 1 3 e1000g0
192.168.192.40 192.168.192.24 UH 1 0 ip.tun0
224.0.0.0 192.168.0.21 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 1 48 lo0 关于HostB,netstat -rn说
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ---------- ---------
default 192.168.0.1 UG 1 2 e1000g0
192.168.0.0 192.168.0.199 U 1 7 e1000g0
192.168.192.24 192.168.192.40 UH 1 1 ip.tun0
127.0.0.1 127.0.0.1 UH 3 122 lo0 我错过了什么?防火墙在两个节点上都是禁用的。
发布于 2019-02-17 21:54:46
解决方案发现错误在许多conf的语法中。文件第一
/etc/inet/ike.preshared必须是这样,使用的ip必须是隧道的ip,而不是“主”接口的ip。
# ike.preshared on hostA
#…
{ localidtype IP
localid 10.4.0.1
remoteidtype IP
remoteid 10.4.0.2
key keyinhexformat
# The preshared key can also be represented in hex
# as in 0xf47cb0f432e14480951095f82b
# key "This is an ASCII Cqret phrAz, use str0ng p@ssword tekniques"
}若要在十六进制中生成密钥,请使用以下命令
echo "mypassword" | od -t x1|head -1|tr -d ' '该文件
/etc/inet/ike/config必须与此类似,即使在这种情况下使用隧道的ip,而不是主接口的ip。
p1_xform
{ auth_method preshared oakley_group 5 auth_alg sha encr_alg 3des }
p2_pfs 2
{ label "test1-test2" local_addr 10.4.0.1 remote_addr 10.4.0.2 p1_xform { auth_method preshared oakley_group 5 auth_alg sha256 encr_alg aes } p2_pfs 5 }当然,在hostB中,两个文件都必须反向10.4.0.1和10.4.0.2。
最后编辑文件/etc/inet/ipsecinit.conf
{laddr 192.168.0.21 dir both} bypass {}
{laddr 10.4.0.1 raddr 10.4.0.2} ipsec {encr_algs aes encr_auth_algs sha256 sa shared}当然,在hostB中,10.4.0.1与10.4.0.2和192.168.0.21必须与hostB的主机主ip交换。
现在在hostA上运行脚本
ifconfig ip.tun0 unplumb
ifconfig ip.tun0 plumb
ifconfig ip.tun0 10.4.0.1 10.4.0.2 netmask 255.255.255.0 tsrc 192.168.0.21 tdst 192.168.0.199 router up
for i in ike ipsec/policy;do svcadm refresh $i; done现在在hostB上运行脚本
ifconfig ip.tun0 unplumb
ifconfig ip.tun0 plumb
ifconfig ip.tun0 10.4.0.2 10.4.0.1 netmask 255.255.255.0 tsrc 192.168.0.199 tdst 192.168.0.21 router up
for i in ike ipsec/policy;do svcadm refresh $i; done一切正常,用平和窥探测试。
https://unix.stackexchange.com/questions/501127
复制相似问题