conntrack tools可以用来在多主机间同步TCP会话, 时间TCP会话在超时时间内的不丢失漂移,(结合VIP漂移). 对应用程序透明.
测试环境CentOS 6.6 x64
内核
# uname -r
2.6.32-504.8.1.el6.x86_64
依赖包, 模块
# yum install -y libxml2 libxml2-devel
# yum install -y libxml++ libxml++-devel
# yum install -y json-c-devel json-c
# lsmod|grep conn
nf_conntrack_ipv4 9506 1
nf_defrag_ipv4 1483 1 nf_conntrack_ipv4
nf_conntrack 80390 2 nf_conntrack_ipv4,xt_state
# PKG_CONFIG_PATH=/usr/local/lib/pkgconfig; export PKG_CONFIG_PATH
# tar -jxvf libnfnetlink-1.0.1.tar.bz2
# cd libnfnetlink-1.0.1
# ./configure
# make
# make install
# vi /etc/ld.so.conf
添加
/usr/local/lib
# ldconfig
其他安装包如下, 略 :
tar -jxvf libmnl-1.0.3.tar.bz2
tar -jxvf libnetfilter_conntrack-1.0.4.tar.bz2
tar -jxvf libnetfilter_cttimeout-1.0.0.tar.bz2
tar -jxvf libnetfilter_cthelper-1.0.0.tar.bz2
tar -jxvf libnetfilter_queue-1.0.2.tar.bz2
tar -jxvf libnetfilter_acct-1.0.2.tar.bz2
tar -jxvf libnetfilter_log-1.0.1.tar.bz2
tar -jxvf libnftnl-1.0.3.tar.bz2
tar -jxvf conntrack-tools-1.4.2.tar.bz2
# lsmod|grep nf
nf_conntrack_netlink 17040 0
nfnetlink_queue 8111 0
nfnetlink_log 8718 0
nfnetlink 4200 3 nf_conntrack_netlink,nfnetlink_queue,nfnetlink_log
nf_conntrack_ipv4 9506 1
nf_defrag_ipv4 1483 1 nf_conntrack_ipv4
nf_conntrack 80390 3 nf_conntrack_netlink,nf_conntrack_ipv4,xt_state
测试 :
# conntrack -L
udp 17 40 src=192.168.xxx.xxx dst=192.168.xxx.xxx sport=42224 dport=161 src=192.168.xxx.xxx dst=192.168.xxx.xxx sport=161 dport=42224 [ASSURED] mark=0 secmark=0 use=2
unknown 2 575 src=192.168.160.135 dst=224.0.0.1 [UNREPLIED] src=224.0.0.1 dst=192.168.160.135 mark=0 secmark=0 use=2
tcp 6 299 ESTABLISHED src=10.96.0.xxx dst=192.168.xxx.xxx sport=61226 dport=22 src=192.168.xxx.xxx dst=10.96.0.xxxsport=22 dport=61226 [ASSURED] mark=0 secmark=0 use=2
conntrack v1.4.2 (conntrack-tools): 3 flow entries have been shown.
[参考]
1. http://conntrack-tools.netfilter.org/manual.html
2. http://www.netfilter.org/
3. http://conntrack-tools.netfilter.org/conntrackd.html
4. http://conntrack-tools.netfilter.org/conntrack.html
5. http://conntrack-tools.netfilter.org/