Openswan Porting to Pronghorn-Metro 實務經驗分享 06

最後一回精彩大結局~

# ipsec --help

理論上來說,這個指令會 show 出所有支援的指令,但...沒 show 出來...。看了一下,show 指令的方式也夠奇特,居然事先用 ls 讀 /usr/local/libexec/ipsec/ 下面的檔案,然後在用 egrep 進行過濾的動作... 好傢伙。因為我懶的去安裝 egrep 了,就把 ipsec 這隻 script 稍微改寫一下,達到相同的目的(不過好像沒完全濾完,管他的,反正我也只用那幾個指令)

正當我把一切都準備好了以後,鼓起勇氣執行:

# ipsec setup start

產生了下面的 Log:

ipsec_setup: Starting Openswan IPsec U2.4.5/K2.6.17-uc1-adi3...
ipsec_setup: modprobe: module ah4 not found.
ipsec_setup: modprobe: failed to load module ah4
ipsec_setup: modprobe: module esp4 not found.
ipsec_setup: modprobe: failed to load module esp4
ipsec_setup: modprobe: module ipcomp not found.
ipsec_setup: modprobe: failed to load module ipcomp
ipsec_setup: modprobe: module xfrm4_tunnel not found.
ipsec_setup: modprobe: failed to load module xfrm4_tunnel
ipsec_setup: modprobe: module xfrm_user not found.
ipsec_setup: modprobe: failed to load module xfrm_user
ipsec_setup: modprobe: module hw_random not found.
ipsec_setup: modprobe: failed to load module hw_random
ipsec_setup: modprobe: module padlock not found.
ipsec_setup: modprobe: failed to load module padlock
ipsec_setup: modprobe: module sha1 not found.
ipsec_setup: modprobe: failed to load module sha1
ipsec_setup: modprobe: module md5 not found.
ipsec_setup: modprobe: failed to load module md5
ipsec_setup: modprobe: module des not found.
ipsec_setup: modprobe: failed to load module des
ipsec_setup: modprobe: module aes not found.
ipsec_setup: modprobe: failed to load module aes
ipsec_setup: ipsec_setup: WARNING: cannot flush state/policy database -- `%defaultroute'. Install a newer version.
ipsec_setup: no default route, %defaultroute cannot cope!!!

前面的 Log 可以完全不理他,原因很簡單,因為我已經把他們都編入核心了,根本不用載入 module。但,好傢伙,一定要 default GW 就是了,那就加吧

route add default gw 192.168.8.1

再執行一次...看起來好像OK了,那就繼續下去~

# ipsec auto --up mswitch

"024 need --listen before --initiate"

這甚麼意思,稍微查了一下 ... 好傢伙,這代表我的 ipsec 沒有執行起來,查了一下 /var/log/messages

ip: an inet address is expected rather than "cache".

well ... 反正我也不需要他去清 cache,那就改掉吧 ,以我來說,我改成 ip route show。

於是,總算,成功了... 來 ping 一下吧...結果,沒有加密!!!
Why?? 再看一下官方網頁,他說「Sit at one of your local subnet nodes *(not the gateway)*, and ping a subnet node on the other *(again, not the gateway)*.」...難怪我兩台 gateway ping 起來沒有加密。可是,我需要的是 host to host 啊,那麼,就把 ipsec.conf 裡面的 subnet 選項拿掉吧。

At last, I succeed~

最後付一下我開機執行的指令以及 ipsec.conf

ifconfig ixp0 192.168.8.227
(nfig ixp0 192.168.8.228 )
mv /dev/random /dev/random_bak
ln -s /dev/urandom /dev/random
hostname 123.mswitch
(hostname 456.mswitch )
ln -s /etc/ipsec.secrets.1 /etc/ipsec.secrets
( ln -s /etc/ipsec.secrets.2 /etc/ipsec.secrets )
route add default gw 192.168.8.1 (This is necessary ... but I don't know why ...)

conn mswitch
....left=192.168.8.227
....leftid=@123.mswitch
....leftrsasigkey=xxx
.... leftnexthop=192.168.8.228
.... right=192.168.8.228
.... rightid=@456.mswitch
.... rightrsasigkey=yyy
.... rightnexthop=192.168.8.227
.... auto=add

留下這個紀錄沒有甚麼,重點不在乎最後完工,而是中間的過程跟經驗。很多東西從後面來看沒什麼,但中間所學習的,又豈是三言兩語說得完的~

留言

這個網誌中的熱門文章

我弟家的新居感恩禮拜分享:善頌善禱

Openssl 範例程式:建立SSL連線

如何利用 Wireshark 來監聽 IEEE 802.11 的管理封包