搜索

3.4. 多​​​​​​​端​​​​​​​口​​​​​​​服​​​​​​​务​​​​​​​和​​​​​​​ LVS

download PDF
LVS routers under any topology require extra configuration when creating multi-port LVS services. Multi-port services can be created artificially by using firewall marks to bundle together different, but related protocols, such as HTTP (port 80) and HTTPS (port 443), or when LVS is used with true multi-port protocols, such as FTP. In either case, the LVS router uses firewall marks to recognize that packets destined for different ports, but bearing the same firewall mark, should be handled identically. Also, when combined with persistence, firewall marks ensure connections from the client machine are routed to the same host, as long as the connections occur within the length of time specified by the persistence parameter. For more on assigning persistence to a virtual server, see 第 4.6.1 节 “「​​​​​​​虚​​​​​​​拟​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​」​​​​​​​子​​​​​​​界​​​​​​​面​​​​​​​”.
遗​​​​​​​憾​​​​​​​的​​​​​​​是​​​​​​​,用​​​​​​​来​​​​​​​平​​​​​​​衡​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​中​​​​​​​负​​​​​​​载​​​​​​​的​​​​​​​机​​​​​​​制​​​​​​​ — IPVS — 可​​​​​​​以​​​​​​​识​​​​​​​别​​​​​​​为​​​​​​​数​​​​​​​据​​​​​​​包​​​​​​​分​​​​​​​配​​​​​​​的​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​,但​​​​​​​无​​​​​​​法​​​​​​​自​​​​​​​己​​​​​​​分​​​​​​​配​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​。​​​​​​​分​​​​​​​配​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​的​​​​​​​工​​​​​​​作​​​​​​​必​​​​​​​须​​​​​​​由​​​​​​​网​​​​​​​络​​​​​​​数​​​​​​​据​​​​​​​包​​​​​​​过​​​​​​​滤​​​​​​​器​​​​​​​ iptables 在​​​​​​​ Piranha Configuration Tool之​​​​​​​外​​​​​​​执​​​​​​​行​​​​​​​。​​​​​​​

3.4.1. 分​​​​​​​配​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​

要​​​​​​​为​​​​​​​目​​​​​​​的​​​​​​​地​​​​​​​址​​​​​​​为​​​​​​​特​​​​​​​定​​​​​​​端​​​​​​​口​​​​​​​的​​​​​​​数​​​​​​​据​​​​​​​包​​​​​​​分​​​​​​​配​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​,管​​​​​​​理​​​​​​​员​​​​​​​必​​​​​​​须​​​​​​​使​​​​​​​用​​​​​​​ iptables。​​​​​​​
This section illustrates how to bundle HTTP and HTTPS as an example; however, FTP is another commonly clustered multi-port protocol. If an LVS is used for FTP services, refer to 第 3.5 节 “配​​​​​​​置​​​​​​​ FTP” for configuration details.
在​​​​​​​使​​​​​​​用​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​时​​​​​​​要​​​​​​​记​​​​​​​住​​​​​​​的​​​​​​​最​​​​​​​基​​​​​​​本​​​​​​​规​​​​​​​则​​​​​​​就​​​​​​​是​​​​​​​在​​​​​​​ Piranha Configuration Tool使​​​​​​​用​​​​​​​的​​​​​​​每​​​​​​​一​​​​​​​个​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​都​​​​​​​必​​​​​​​须​​​​​​​有​​​​​​​一​​​​​​​个​​​​​​​相​​​​​​​应​​​​​​​的​​​​​​​ iptables 规​​​​​​​则​​​​​​​来​​​​​​​将​​​​​​​标​​​​​​​记​​​​​​​分​​​​​​​配​​​​​​​给​​​​​​​网​​​​​​​络​​​​​​​数​​​​​​​据​​​​​​​包​​​​​​​。​​​​​​​
在​​​​​​​创​​​​​​​建​​​​​​​网​​​​​​​络​​​​​​​数​​​​​​​据​​​​​​​包​​​​​​​过​​​​​​​滤​​​​​​​器​​​​​​​规​​​​​​​则​​​​​​​前​​​​​​​,请​​​​​​​确​​​​​​​定​​​​​​​没​​​​​​​有​​​​​​​规​​​​​​​则​​​​​​​在​​​​​​​运​​​​​​​行​​​​​​​。​​​​​​​要​​​​​​​做​​​​​​​到​​​​​​​这​​​​​​​一​​​​​​​点​​​​​​​,请​​​​​​​在​​​​​​​ shell 提​​​​​​​示​​​​​​​符​​​​​​​后​​​​​​​以​​​​​​​根​​​​​​​用​​​​​​​户​​​​​​​身​​​​​​​份​​​​​​​登​​​​​​​录​​​​​​​,并​​​​​​​输​​​​​​​入​​​​​​​:
/sbin/service iptables status
如​​​​​​​果​​​​​​​没​​​​​​​有​​​​​​​运​​​​​​​行​​​​​​​ iptables,提​​​​​​​示​​​​​​​符​​​​​​​会​​​​​​​马​​​​​​​上​​​​​​​重​​​​​​​新​​​​​​​出​​​​​​​现​​​​​​​。​​​​​​​
如​​​​​​​果​​​​​​​激​​​​​​​活​​​​​​​了​​​​​​​ iptables,它​​​​​​​会​​​​​​​显​​​​​​​示​​​​​​​一​​​​​​​组​​​​​​​规​​​​​​​则​​​​​​​。​​​​​​​如​​​​​​​果​​​​​​​显​​​​​​​示​​​​​​​了​​​​​​​规​​​​​​​则​​​​​​​,请​​​​​​​输​​​​​​​入​​​​​​​以​​​​​​​下​​​​​​​命​​​​​​​令​​​​​​​:
/sbin/service iptables stop
如​​​​​​​果​​​​​​​正​​​​​​​在​​​​​​​运​​​​​​​行​​​​​​​的​​​​​​​规​​​​​​​则​​​​​​​很​​​​​​​重​​​​​​​要​​​​​​​,请​​​​​​​检​​​​​​​查​​​​​​​ /etc/sysconfig/iptables 中​​​​​​​的​​​​​​​内​​​​​​​容​​​​​​​并​​​​​​​在​​​​​​​操​​​​​​​作​​​​​​​前​​​​​​​将​​​​​​​有​​​​​​​保​​​​​​​留​​​​​​​价​​​​​​​值​​​​​​​的​​​​​​​规​​​​​​​则​​​​​​​复​​​​​​​制​​​​​​​到​​​​​​​一​​​​​​​个​​​​​​​安​​​​​​​全​​​​​​​的​​​​​​​地​​​​​​​方​​​​​​​。​​​​​​​
以​​​​​​​下​​​​​​​是​​​​​​​分​​​​​​​配​​​​​​​了​​​​​​​相​​​​​​​同​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​ 80 的​​​​​​​规​​​​​​​则​​​​​​​,它​​​​​​​们​​​​​​​在​​​​​​​端​​​​​​​口​​​​​​​ 80 和​​​​​​​ 443 接​​​​​​​收​​​​​​​目​​​​​​​的​​​​​​​地​​​​​​​址​​​​​​​为​​​​​​​浮​​​​​​​动​​​​​​​ IP 地​​​​​​​址​​​​​​​ n.n.n.n 的​​​​​​​进​​​​​​​入​​​​​​​流​​​​​​​量​​​​​​​。​​​​​​​
/sbin/modprobe ip_tables
/sbin/iptables -t mangle -A PREROUTING -p tcp -d n.n.n.n/32 --dport 80 -j MARK --set-mark 80
/sbin/iptables -t mangle-A PREROUTING -p tcp -d n.n.n.n/32 --dport 443 -j MARK --set-mark 80
For instructions on assigning the VIP to the public network interface, see 第 4.6.1 节 “「​​​​​​​虚​​​​​​​拟​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​」​​​​​​​子​​​​​​​界​​​​​​​面​​​​​​​”. Also note that you must log in as root and load the module for iptables before issuing rules for the first time.
在​​​​​​​以​​​​​​​上​​​​​​​的​​​​​​​ iptables 中​​​​​​​,应​​​​​​​该​​​​​​​使​​​​​​​用​​​​​​​虚​​​​​​​拟​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​的​​​​​​​浮​​​​​​​动​​​​​​​ IP 替​​​​​​​换​​​​​​​您​​​​​​​的​​​​​​​ HTTP 和​​​​​​​ HTTPS n.n.n.n。​​​​​​​这​​​​​​​些​​​​​​​命​​​​​​​令​​​​​​​具​​​​​​​有​​​​​​​为​​​​​​​在​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​标​​​​​​​记​​​​​​​为​​​​​​​ 80 的​​​​​​​适​​​​​​​当​​​​​​​端​​​​​​​口​​​​​​​将​​​​​​​所​​​​​​​有​​​​​​​流​​​​​​​量​​​​​​​分​​​​​​​配​​​​​​​到​​​​​​​ VIP 地​​​​​​​址​​​​​​​的​​​​​​​网​​​​​​​络​​​​​​​效​​​​​​​应​​​​​​​,这​​​​​​​些​​​​​​​流​​​​​​​量​​​​​​​可​​​​​​​依​​​​​​​次​​​​​​​由​​​​​​​ IPVS 识​​​​​​​别​​​​​​​并​​​​​​​进​​​​​​​行​​​​​​​正​​​​​​​确​​​​​​​转​​​​​​​发​​​​​​​。​​​​​​​
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.