我有一个运行 2 个网卡的系统。为了确保每个卡的默认路由正确,在 /etc/dhclient-exit-hooks 中添加了以下内容:
if [[ "$interface" == "eth0" ]]; then
if [ "$reason" == "BOUND" ]; then
ip rule add from "$new_ip_address" table 234
ip route add default via "$new_dhcp_server_identifier" dev "$interface" table 234
fi
fi
if [[ "$interface" == "eth1" ]]; then
if [[ "$reason" == "BOUND" ]]; then
ip rule add from "$new_ip_address" table 345
ip route add default via "$new_dhcp_server_identifier" dev "$interface" table 345
fi
fi
现在,当我尝试 ssh 进入系统时,问题显示没有到主机的路由。但如果我先 ping 系统,然后尝试 ssh,它就可以正常工作。我在这里做错了什么?