在Linux上,我一直在搞ipsec
(Strongswan)和動態路由(OSPF
/RIP
)。 在Ubuntu服務器上,我有一堆連接到虛擬交換機的以太網接口。其中每一個都運行OSPF來獲得外部路由:在這種情況下,只是到一個ipsec端點的路由。我想運行這個遠程安全設備到Ubuntu服務器的ipsec。問題是我需要OSPF動態選擇將其路由到哪個接口。不幸的是,ipsec不能以這種方式神奇地得到它的左/右IP。 相反,我將附加一個新的IP到環回(或任何地方),並將IPsec傳遞給這個IP。它會嘗試和失敗,讓我有以下錯誤:strongswan虛擬ip和動態路由
#grep charon /var/log/messages
...<trimmed>
Aug 18 22:04:59 system charon: 10[IKE] retransmit 4 of request with message ID 0
Aug 18 22:04:59 system charon: 10[NET] sending packet: from 10.1.2.3[500] to 10.1.1.1[500] (1196 bytes)
Aug 18 22:04:59 system charon: 02[NET] error writing to socket: Operation not permitted
...
所以,如果我用以太網IP,它是註定要失敗的時候動態路由變化。如果我使用虛擬IP,它會嘗試並且無法發送任何內容。
問題:如何使用Strongswan動態路由?
這裏有一些CONFIGS ...
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet 10.1.2.3/32 scope global lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
...<trimmed>
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
...
inet 192.168.1.1/24 ...
...
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
...
inet 192.168.4.1/24
# cat /etc/quagga/Quagga.conf
...<trimmed>
interface eth1
ip address 192.168.1.1/24
ip ospf network point-to-point
ipv6 nd suppress-ra
!
interface eth2
ip address 192.168.2.1/24
ip ospf network point-to-point
ipv6 nd suppress-ra
!
interface eth3
ip address 192.168.3.1/24
ip ospf network point-to-point
ipv6 nd suppress-ra
!
interface eth4
ip address 192.168.4.1/24
ip ospf network point-to-point
ipv6 nd suppress-ra
!
interface lo
!
router ospf
network 192.168.1.1/24 area 0.0.0.0
network 192.168.2.1/24 area 0.0.0.0
network 192.168.3.1/24 area 0.0.0.0
network 192.168.4.1/24 area 0.0.0.0
!
ip forwarding
!
line vty
!
# cat /etc/ipsec.conf
conn tuntun0
leftid=10.1.2.3
left=%10.1.2.3
leftfirewall=no
leftsourceip=10.1.2.3
leftsubnet=10.1.2.3/32[gre]
right=10.1.1.1
rightsubnet=10.1.1.1/32[gre]
auto=route
ike=aes256-sha1-modp3072
esp=aes256-sha1!
編輯: 我誤解爲IP /路由問題的錯誤。它實際上部分是路由問題,部分是防火牆問題;一旦我明白,就很容易修復