我们有一个心跳切换,它发生在我们其中一个网络的两个防火墙之间,切换发生的接口默认没有设置 IP,只有在切换发生时才会获取此 IP。这也恰好是这个网络的默认路由(用作防火墙的机器),我们没有 IP 空间为这些机器分别提供另一个 IP 地址。然而,当尝试将流量路由到 WAN 端口之外的任何东西时,这会导致问题。
我该如何向当前没有 IP 地址的接口添加默认路由(该接口在启动时通过 system.d 服务启动)或者我是否可以在 IP 切换时添加路由?
答案1
您可以使用资源代理添加/删除路线ocf:heartbeat:Route
。
资源代理的描述Route
是:
Manages network routes (ocf:heartbeat:Route)
Enables and disables network routes.
Supports host and net routes, routes via a gateway address,
and routes using specific source addresses.
This resource agent is useful if a node's routing table
needs to be manipulated based on node role assignment.
Consider the following example use case:
- One cluster node serves as an IPsec tunnel endpoint.
- All other nodes use the IPsec tunnel to reach hosts
in a specific remote network.
Then, here is how you would implement this scheme making use
of the Route resource agent:
- Configure an ipsec LSB resource.
- Configure a cloned Route OCF resource.
- Create an order constraint to ensure
that ipsec is started before Route.
- Create a colocation constraint between the
ipsec and Route resources, to make sure no instance
of your cloned Route resource is started on the
tunnel endpoint itself.
Parameters (*: required, []: default):
destination* (string): Destination network
The destination network (or host) to be configured for the route.
Specify the netmask suffix in CIDR notation (e.g. "/24").
If no suffix is given, a host route will be created.
Specify "0.0.0.0/0" or "default" if you want this resource to set
the system default route.
device (string): Outgoing network device
The outgoing network device to use for this route.
gateway (string): Gateway IP address
The gateway IP address to use for this route.
source (string): Source IP address
The source IP address to be configured for the route.
table (string): Routing table
The routing table to be configured for the route.
Operations' defaults (advisory minimum):
start timeout=20
stop timeout=20
monitor timeout=20 interval=10
reload timeout=20
在您的配置中在您的 IP 后面定义它,并且一旦 IP 存在,就会添加路由。
不使用 Pacemaker 的情况下使用 Heartbeat 已被弃用,因此很难找到有关此问题的任何当前文档。如果可以,您应该考虑将 Pacemaker 添加到您的设置中。