Show Table of Contents
3.7. 開啟封包轉送與 Nonlocal 綁定
若要確保 Keepalived 服務能正確轉送網路封包至真實伺服器上,各個路由器節點在 kernel 中的 IP 轉送功能皆必須開啟。請以 root 登入並將
/etc/sysctl.conf 中的 net.ipv4.ip_forward = 0 一行改為:
net.ipv4.ip_forward = 1
當您重新啓動系統時,變更便會生效。
HAProxy 中的 Load Balancing 也需要能綁定至一組nonlocal(非本機)的 IP 位址,代表它不會被分配至本機系統上的裝置。這能讓一個運作中的負載平衡 instance 綁定至一組非本機的的 IP 位址,以進行容錯移轉。
若要啟用,請將
/etc/sysctl.conf 中的 net.ipv4.ip_nonlocal_bind 一行編輯為:
net.ipv4.ip_nonlocal_bind = 1
當您重新啓動系統時,變更便會生效。
若要檢查 IP 轉送是否已開啟,請以 root 身份輸入以下指令:
/usr/sbin/sysctl net.ipv4.ip_forward
若要檢查 nonlocal 綁定是否已開啟,請以 root 身份輸入以下指令:
/usr/sbin/sysctl net.ipv4.ip_nonlocal_bind
若以上指令回傳了
1,則代表相應的設定已啟用。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.