大网数据广告活动
服务器运维问答

When using `xfrm` and strongswan for an ipsec tunnel, where are the routes stored?

· 52CE 我爱测

I am using strongswan to establish an ipsec connection in tunnel mode. When the client connects to the gateway, strongswan receives a new ipv6 address assigned to the client from the server. All traffic send to the tunneled netwo…

问题原文

原帖链接 · xeyipes · CC BY-SA 4.0

I am using strongswan to establish an ipsec connection in tunnel mode. When the client connects to the gateway, strongswan receives a new ipv6 address assigned to the client from the server. All traffic send to the tunneled network is then send from this ip6 address. The ipv6 address is assigned to the client's wlp61s0 interface as, for example,2222:33:8085:cf0:1:2:f6e5:a5d0/128. My understanding of the xfrm state and the xfrm policy command is that they only store information about the security Associations (SA) and policies respectively, which select the used SA based on the source and destination address.

But how does the client kernel know that when the client sends information to the target network, e.g. 2222::/16, that it should use a certain source address? And where can I retrieve this information about the current routes?

已采纳解答

原帖链接 · A.B · CC BY-SA 4.0

https://docs.strongswan.org/docs/5.9/howtos/introduction.html#_routing tells:

On Linux, strongSwan installs routes into routing table 220 by default and hence requires the kernel to support policy based routing.

(And it's also using priority 220 to lookup table 220.)

So for IPv6 this should be seen with:

ip -6 rule show priority 220

or

ip -6 rule show lookup 220

for the policy routing part.

plus:

ip -6 route show table 220

for the routing table part.

To know what decision is taken by the kernel without having to think about it, one can ask the kernel what would be the decision. For example:

ip route get to 2222::1

will tell among other pieces of information the chosen source address, the chosen interface, the gateway if any and (if not the main table) the chosen routing table.

Please also note that IPv6 has a quite complex but well documented way to select source addresses when not explicitly overridden in (main) routes, routing rules/routing tables: RFC 6724: Default Address Selection for Internet Protocol Version 6 (IPv6) 5. Source Address Selection

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-08-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。