IPVS full NAT support + netfilter 'ipvs' match support
Subsystems (5)
v2 cover IPVS full NAT support + netfilter 'ipvs' match support
The following series implements full NAT support for IPVS. The approach is via a minimal change to IPVS (make friends with nf_conntrack) and adding a netfilter matcher, kernel- and user-space part, i.e. xt_ipvs and libxt_ipvs.
Example usage:
% ipvsadm -A -t 192.168.100.30:80 -s rr
% ipvsadm -a -t 192.168.100.30:80 -r 192.168.10.20:80 -m
# ...
# Source NAT for VIP 192.168.100.30:80
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \
Quoted 1 line
--vport 80 -j SNAT --to-source 192.168.10.10
or SNAT-ing only a specific real server:
% iptables -t nat -A POSTROUTING --dst 192.168.11.20 \
Quoted 1 line
-m ipvs --vaddr 192.168.100.30/32 -j SNAT --to-source 192.168.10.10
First of all, thanks for all the feedback. This is the changelog for v2:
- Make ip_vs_ftp work again. Setup nf_conntrack expectations for related data connections (based on Julian's patch see
http://www.ssi.bg/~ja/nfct/) and let nf_conntrack/nf_nat do the packet mangling and the TCP sequence adjusting.
This change rises the question how to deal with ip_vs_sync? Does it work together with conntrackd? Wild idea: what about getting rid of ip_vs_sync and piggy packing all on nf_conntrack and use conntrackd?
Any comments on this?
- xt_ipvs: add new rule '--vportctl port' to match the VIP port of the controlling connection, e.g. port 21 for FTP. Can be used to match a related data connection for FTP:
# SNAT FTP control connection % iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \ > --vport 21 -j SNAT --to-source 192.168.10.10 # SNAT FTP passive data connection % iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \ > --vportctl 21 -j SNAT --to-source 192.168.10.10
- xt_ipvs: use 'par->family' instead of 'skb->protocol'
- xt_ipvs: add ipvs_mt_check and restrict to NFPROTO_IPV4 and NFPROTO_IPV6
- Call nf_conntrack_alter_reply(), so helper lookup is performed based on the changed tuple.
Changes to the linux kernel (rebased to next-20090925):
Hannes Eder (3):
netfilter: xt_ipvs (netfilter matcher for IPVS)
IPVS: make friends with nf_conntrack
IPVS: make FTP work with full NAT support
include/linux/netfilter/xt_ipvs.h | 25 +++++ include/net/ip_vs.h | 2 net/netfilter/Kconfig | 9 ++ net/netfilter/Makefile | 1 net/netfilter/ipvs/Kconfig | 4 - net/netfilter/ipvs/ip_vs_app.c | 43 --------- net/netfilter/ipvs/ip_vs_core.c | 37 ------- net/netfilter/ipvs/ip_vs_ftp.c | 178 ++++++++++++++++++++++++++++++++--- net/netfilter/ipvs/ip_vs_proto.c | 1 net/netfilter/ipvs/ip_vs_xmit.c | 30 ++++++ net/netfilter/xt_ipvs.c | 187 +++++++++++++++++++++++++++++++++++++ 11 files changed, 418 insertions(+), 99 deletions(-) create mode 100644 include/linux/netfilter/xt_ipvs.h create mode 100644 net/netfilter/xt_ipvs.c
Changes to iptables (relative to 1.4.5):
Hannes Eder (1):
libxt_ipvs: user-space lib for netfilter matcher xt_ipvs
configure.ac | 11 + extensions/libxt_ipvs.c | 365 +++++++++++++++++++++++++++++++++++++ extensions/libxt_ipvs.man | 24 ++ include/linux/netfilter/xt_ipvs.h | 25 +++ 4 files changed, 422 insertions(+), 3 deletions(-) create mode 100644 extensions/libxt_ipvs.c create mode 100644 extensions/libxt_ipvs.man create mode 100644 include/linux/netfilter/xt_ipvs.h
PATCH v2 1/4 netfilter: xt_ipvs (netfilter matcher for IPVS)
This implements the kernel-space side of the netfilter matcher xt_ipvs.
include/linux/netfilter/xt_ipvs.h | 25 +++++ net/netfilter/Kconfig | 9 ++ net/netfilter/Makefile | 1 net/netfilter/ipvs/ip_vs_proto.c | 1 net/netfilter/xt_ipvs.c | 187 +++++++++++++++++++++++++++++++++++++ 5 files changed, 223 insertions(+), 0 deletions(-) create mode 100644 include/linux/netfilter/xt_ipvs.h create mode 100644 net/netfilter/xt_ipvs.c
include/linux/netfilter/xt_ipvs.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef _XT_IPVS_H +#define _XT_IPVS_H 1 + +#define XT_IPVS_IPVS_PROPERTY (1 << 0)/* all other options imply this one */ +#define XT_IPVS_PROTO (1 << 1) +#define XT_IPVS_VADDR (1 << 2) +#define XT_IPVS_VPORT (1 << 3) +#define XT_IPVS_DIR (1 << 4) +#define XT_IPVS_METHOD (1 << 5) +#define XT_IPVS_VPORTCTL (1 << 6) +#define XT_IPVS_MASK ((1 << 7) - 1) +#define XT_IPVS_ONCE_MASK (XT_IPVS_MASK & ~XT_IPVS_IPVS_PROPERTY) + +struct xt_ipvs_mtinfo { +union nf_inet_addr vaddr, vmask; +__be16 vport; +__u16 l4proto; +__u16 fwd_method; +__be16 vportctl; + +__u8 invert; +__u8 bitmask; +}; + +#endif /* _XT_IPVS_H */
net/netfilter/Kconfig +9 -0
@@ -678,6 +678,15 @@ config NETFILTER_XT_MATCH_IPRANGE If unsure, say M. +config NETFILTER_XT_MATCH_IPVS + tristate '"ipvs" match support' + depends on IP_VS + depends on NETFILTER_ADVANCED + help + This option allows you to match against IPVS properties of a packet. + + If unsure, say N. + config NETFILTER_XT_MATCH_LENGTH tristate '"length" match support' depends on NETFILTER_ADVANCED
net/netfilter/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o obj-$(CONFIG_NETFILTER_XT_MATCH_IPRANGE) += xt_iprange.o +obj-$(CONFIG_NETFILTER_XT_MATCH_IPVS) += xt_ipvs.o obj-$(CONFIG_NETFILTER_XT_MATCH_LENGTH) += xt_length.o obj-$(CONFIG_NETFILTER_XT_MATCH_LIMIT) += xt_limit.o obj-$(CONFIG_NETFILTER_XT_MATCH_MAC) += xt_mac.o
net/netfilter/ipvs/ip_vs_proto.c +1 -0
@@ -97,6 +97,7 @@ struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto)return NULL ; } +EXPORT_SYMBOL (ip_vs_proto_get);/*
net/netfilter/xt_ipvs.c new file +187 -0
187 lines not on this page · raw message
PATCH v2 2/4 IPVS: make friends with nf_conntrack
In reply to Hannes EderUpdate the nf_conntrack tuple in reply direction, as we will see traffic from the real server (RIP) to the client (CIP). Once this is done we can use netfilters SNAT in POSTROUTING, especially with xt_ipvs, to do source NAT, e.g.:
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 --vport 80 \
Quoted 1 line
-j SNAT --to-source 192.168.10.10
net/netfilter/ipvs/Kconfig | 2 +- net/netfilter/ipvs/ip_vs_core.c | 36 ------------------------------------ net/netfilter/ipvs/ip_vs_xmit.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 37 deletions(-)
net/netfilter/ipvs/Kconfig +1 -1
@@ -3,7 +3,7 @@ # menuconfig IP_VS tristate "IP virtual server support" - depends on NET && INET && NETFILTER + depends on NET && INET && NETFILTER && NF_CONNTRACK ---help--- IP Virtual Server support will let you build a high-performance virtual server based on cluster of two or more real servers. This
net/netfilter/ipvs/ip_vs_core.c +0 -36
@@ -521,26 +521,6 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,return NF_DROP ; } - -/* -* It is hooked before NF_IP_PRI_NAT_SRC at the NF_INET_POST_ROUTING -* chain, and is used for VS/NAT. -* It detects packets for VS/NAT connections and sends the packets -* immediately. This can avoid that iptable_nat mangles the packets -* for VS/NAT. -*/ -static unsigned int ip_vs_post_routing (unsigned int hooknum, -struct sk_buff *skb, -const struct net_device *in, -const struct net_device *out, -int (*okfn)(struct sk_buff *)) -{ -if (!skb->ipvs_property) -return NF_ACCEPT ; -/* The packet was sent from IPVS, exit this chain */ -return NF_STOP ; -} -__sum16 ip_vs_checksum_complete (struct sk_buff *skb,int offset) {return csum_fold (skb_checksum (skb, offset, skb->len - offset,0 ));
@@ -1442,14 +1422,6 @@ static struct nf_hook_ops ip_vs_ops[] __read_mostly = { .hooknum = NF_INET_FORWARD, .priority = 99, }, -/* Before the netfilter connection tracking, exit from POST_ROUTING */ - { - .hook = ip_vs_post_routing, - .owner = THIS_MODULE, - .pf = PF_INET, - .hooknum = NF_INET_POST_ROUTING, - .priority = NF_IP_PRI_NAT_SRC-1, - },#ifdef CONFIG_IP_VS_IPV6 /* After packet filtering, forward packet through VS/DR, VS/TUN, * or VS/NAT(change destination), so that filtering rules can be
@@ -1478,14 +1450,6 @@ static struct nf_hook_ops ip_vs_ops[] __read_mostly = { .hooknum = NF_INET_FORWARD, .priority = 99, }, -/* Before the netfilter connection tracking, exit from POST_ROUTING */ - { - .hook = ip_vs_post_routing, - .owner = THIS_MODULE, - .pf = PF_INET6, - .hooknum = NF_INET_POST_ROUTING, - .priority = NF_IP6_PRI_NAT_SRC-1, - },#endif };
net/netfilter/ipvs/ip_vs_xmit.c +30 -0
@@ -27,6 +27,7 @@#include <net/ip6_route.h> #include <linux/icmpv6.h> #include <linux/netfilter.h> +#include <net/netfilter/nf_conntrack.h> #include <linux/netfilter_ipv4.h> #include <net/ip_vs.h>
@@ -347,6 +348,31 @@ ip_vs_bypass_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, }#endif +static void +ip_vs_update_conntrack (struct sk_buff *skb,struct ip_vs_conn *cp) +{ +struct nf_conn *ct = (struct nf_conn *)skb->nfct; +struct nf_conntrack_tuple new_tuple; + +if (ct ==NULL || ct == &nf_conntrack_untracked || +nf_ct_is_confirmed (ct)) +return ; + +/* +* The connection is not yet in the hashtable, so we update it. +* CIP->VIP will remain the same, so leave the tuple in +* IP_CT_DIR_ORIGINAL untouched. When the reply comes back from the +* real-server we will see RIP->DIP. +*/ + new_tuple = ct->tuplehash[IP_CT_DIR_REPLY ].tuple; + new_tuple.src.u3 = cp->daddr; +/* +* This will also take care of UDP and other protocols. +*/ + new_tuple.src.u.tcp.port = cp->dport; +nf_conntrack_alter_reply (ct, &new_tuple); +} +/* * NAT transmitter (only for outside-to-inside nat forwarding) * Not used for related ICMP
@@ -402,6 +428,8 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,IP_VS_DBG_PKT (10 , pp, skb,0 ,"After DNAT" ); +ip_vs_update_conntrack (skb, cp); +/* FIXME: when application helper enlarges the packet and the length is larger than the MTU of outgoing device, there will be still MTU problem. */
@@ -478,6 +506,8 @@ ip_vs_nat_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,IP_VS_DBG_PKT (10 , pp, skb,0 ,"After DNAT" ); +ip_vs_update_conntrack (skb, cp); +/* FIXME: when application helper enlarges the packet and the length is larger than the MTU of outgoing device, there will be still MTU problem. */
PATCH v2 3/4 IPVS: make FTP work with full NAT support
In reply to Hannes EderUse nf_conntrack/nf_nat code to do the packet mangling and the TCP sequence adjusting. The function 'ip_vs_skb_replace' is now dead code, so it is removed.
To SNAT FTP, use something like:
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \
Quoted 1 line
--vport 21 -j SNAT --to-source 192.168.10.10
and for the data connections in passive mode:
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \
Quoted 1 line
--vportctl 21 -j SNAT --to-source 192.168.10.10
using '-m state --state RELATED' would also works.
Make sure the kernel modules ip_vs_ftp, nf_conntrack_ftp, and nf_nat_ftp are loaded.
include/net/ip_vs.h | 2 net/netfilter/ipvs/Kconfig | 2 net/netfilter/ipvs/ip_vs_app.c | 43 --------- net/netfilter/ipvs/ip_vs_core.c | 1 net/netfilter/ipvs/ip_vs_ftp.c | 178 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 164 insertions(+), 62 deletions(-)
include/net/ip_vs.h +0 -2
@@ -724,8 +724,6 @@ extern void ip_vs_app_inc_put(struct ip_vs_app *inc);extern int ip_vs_app_pkt_out (struct ip_vs_conn *,struct sk_buff *skb);extern int ip_vs_app_pkt_in (struct ip_vs_conn *,struct sk_buff *skb); -extern int ip_vs_skb_replace (struct sk_buff *skb,gfp_t pri, -char *o_buf,int o_len,char *n_buf,int n_len);extern int ip_vs_app_init (void );extern void ip_vs_app_cleanup (void );
net/netfilter/ipvs/Kconfig +1 -1
@@ -226,7 +226,7 @@ comment 'IPVS application helper' config IP_VS_FTP tristate "FTP protocol helper" - depends on IP_VS_PROTO_TCP + depends on IP_VS_PROTO_TCP && NF_NAT ---help--- FTP is a protocol that transfers IP address and/or port number in the payload. In the virtual server via Network Address Translation,
net/netfilter/ipvs/ip_vs_app.c +0 -43
49 lines not on this page · raw message
net/netfilter/ipvs/ip_vs_core.c +0 -1
@@ -52,7 +52,6 @@EXPORT_SYMBOL (register_ip_vs_scheduler);EXPORT_SYMBOL (unregister_ip_vs_scheduler); -EXPORT_SYMBOL (ip_vs_skb_replace);EXPORT_SYMBOL (ip_vs_proto_name);EXPORT_SYMBOL (ip_vs_conn_new);EXPORT_SYMBOL (ip_vs_conn_in_get);
net/netfilter/ipvs/ip_vs_ftp.c +163 -15
231 lines not on this page · raw message
PATCH v2 4/4 libxt_ipvs: user-space lib for netfilter matcher xt_ipvs
In reply to Hannes EderThe user-space library for the netfilter matcher xt_ipvs.
configure.ac | 11 + extensions/libxt_ipvs.c | 365 +++++++++++++++++++++++++++++++++++++ extensions/libxt_ipvs.man | 24 ++ include/linux/netfilter/xt_ipvs.h | 25 +++ 4 files changed, 422 insertions(+), 3 deletions(-) create mode 100644 extensions/libxt_ipvs.c create mode 100644 extensions/libxt_ipvs.man create mode 100644 include/linux/netfilter/xt_ipvs.h
configure.ac +8 -3
@@ -1,4 +1,3 @@ - AC_INIT([iptables], [1.4.5]) # See libtool.info "Libtool's versioning system"
@@ -47,12 +46,18 @@ AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH], [Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]), [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) -AC_CHECK_HEADER([linux/dccp.h]) - blacklist_modules=""; + +AC_CHECK_HEADER([linux/dccp.h]) if test "$ac_cv_header_linux_dccp_h" != "yes"; then blacklist_modules="$blacklist_modules dccp"; fi; + +AC_CHECK_HEADER([linux/ip_vs.h]) +if test "$ac_cv_header_linux_ip_vs_h" != "yes"; then + blacklist_modules="$blacklist_modules ipvs"; +fi; + AC_SUBST([blacklist_modules]) AM_CONDITIONAL([ENABLE_STATIC], [test "$enable_static" = "yes"])
extensions/libxt_ipvs.c new file +365 -0
365 lines not on this page · raw message
extensions/libxt_ipvs.man new file +24 -0
@@ -0,0 +1,24 @@ +Match IPVS connection properties. +.TP +[\fB!\fR] \fB\-\-ipvs\fP +packet belongs to an IPVS connection +.TP +Any of the following options implies \-\-ipvs (even negated) +.TP +[\fB!\fR] \fB\-\-vproto\fP \fIprotocol\fP +VIP protocol to match; by number or name, e.g. "tcp" +.TP +[\fB!\fR] \fB\-\-vaddr\fP \fIaddress\fP[\fB/\fP\fImask\fP] +VIP address to match +.TP +[\fB!\fR] \fB\-\-vport\fP \fIport\fP +VIP port to match; by number or name, e.g. "http" +.TP +\fB\-\-vdir\fP {\fBORIGINAL\fP|\fBREPLY\fP} +flow direction of packet +.TP +[\fB!\fR] \fB\-\-vmethod\fP {\fBGATE\fP|\fBIPIP\fP|\fBMASQ\fP} +IPVS forwarding method used +.TP +[\fB!\fR] \fB\-\-vportctl\fP \fIport\fP +VIP port of the controlling connection to match, e.g. 21 for FTP
include/linux/netfilter/xt_ipvs.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef _XT_IPVS_H +#define _XT_IPVS_H 1 + +#define XT_IPVS_IPVS_PROPERTY (1 << 0)/* all other options imply this one */ +#define XT_IPVS_PROTO (1 << 1) +#define XT_IPVS_VADDR (1 << 2) +#define XT_IPVS_VPORT (1 << 3) +#define XT_IPVS_DIR (1 << 4) +#define XT_IPVS_METHOD (1 << 5) +#define XT_IPVS_VPORTCTL (1 << 6) +#define XT_IPVS_MASK ((1 << 7) - 1) +#define XT_IPVS_ONCE_MASK (XT_IPVS_MASK & ~XT_IPVS_IPVS_PROPERTY) + +struct xt_ipvs_mtinfo { +union nf_inet_addr vaddr, vmask; +__be16 vport; +__u16 l4proto; +__u16 fwd_method; +__be16 vportctl; + +__u8 invert; +__u8 bitmask; +}; + +#endif /* _XT_IPVS_H */
Simon Horman
maintainerQuoted 4 lines · Hannes Eder
The following series implements full NAT support for IPVS. The approach is via a minimal change to IPVS (make friends with
nf_conntrack) and adding a netfilter matcher, kernel- and user-space part, i.e.xt_ipvsandlibxt_ipvs.
Its a bit late in the day for me to review the code, but I have a few quick comments.
Quoted 7 lines
Example usage:
% ipvsadm -A -t 192.168.100.30:80 -s rr
% ipvsadm -a -t 192.168.100.30:80 -r 192.168.10.20:80 -m# ...
Quoted 8 lines
# Source NAT for VIP 192.168.100.30:80
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \Quoted 1 line
--vport 80 -j SNAT --to-source 192.168.10.10
or SNAT-ing only a specific real server:
% iptables -t nat -A POSTROUTING --dst 192.168.11.20 \
Quoted 1 line
-m ipvs --vaddr 192.168.100.30/32 -j SNAT --to-source 192.168.10.10
If the iptables rule is not in place does LVS just use its old NAT behaviour?
Quoted 7 lines
First of all, thanks for all the feedback. This is the changelog for v2:
- Make
ip_vs_ftpwork again. Setupnf_conntrackexpectations for related data connections (based on Julian's patch see
http://www.ssi.bg/~ja/nfct/) and let nf_conntrack/nf_nat do the packet mangling and the TCP sequence adjusting.
Quoted 5 lines
This change rises the question how to deal with
ip_vs_sync? Does it work together with conntrackd? Wild idea: what about getting rid ofip_vs_syncand piggy packing all onnf_conntrackand use conntrackd?Any comments on this?
That sounds like a reasonable suggestion.
I think that ip_vs_sync came along before conntrackd and no one has given much thought to merging the functionality.
Quoted 56 lines
-
xt_ipvs: add new rule '--vportctl port' to match the VIP port of the controlling connection, e.g. port 21 for FTP. Can be used to match a related data connection for FTP:# SNAT FTP control connection % iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \ > --vport 21 -j SNAT --to-source 192.168.10.10 # SNAT FTP passive data connection % iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \ > --vportctl 21 -j SNAT --to-source 192.168.10.10-
xt_ipvs: use 'par->family' instead of 'skb->protocol'-
xt_ipvs: addipvs_mt_checkand restrict toNFPROTO_IPV4andNFPROTO_IPV6- Call
nf_conntrack_alter_reply(), so helper lookup is performed based on the changed tuple.Changes to the linux kernel (rebased to next-20090925):
Hannes Eder (3):
netfilter:xt_ipvs(netfilter matcher for IPVS)
IPVS: make friends withnf_conntrack
IPVS: make FTP work with full NAT supportinclude/linux/netfilter/xt_ipvs.h | 25 +++++ include/net/ip_vs.h | 2 net/netfilter/Kconfig | 9 ++ net/netfilter/Makefile | 1 net/netfilter/ipvs/Kconfig | 4 - net/netfilter/ipvs/ip_vs_app.c | 43 --------- net/netfilter/ipvs/ip_vs_core.c | 37 ------- net/netfilter/ipvs/ip_vs_ftp.c | 178 ++++++++++++++++++++++++++++++++--- net/netfilter/ipvs/ip_vs_proto.c | 1 net/netfilter/ipvs/ip_vs_xmit.c | 30 ++++++ net/netfilter/xt_ipvs.c | 187 +++++++++++++++++++++++++++++++++++++ 11 files changed, 418 insertions(+), 99 deletions(-) create mode 100644 include/linux/netfilter/xt_ipvs.h create mode 100644 net/netfilter/xt_ipvs.cChanges to iptables (relative to 1.4.5):
Hannes Eder (1):
libxt_ipvs: user-space lib for netfilter matcherxt_ipvsconfigure.ac | 11 + extensions/libxt_ipvs.c | 365 +++++++++++++++++++++++++++++++++++++ extensions/libxt_ipvs.man | 24 ++ include/linux/netfilter/xt_ipvs.h | 25 +++ 4 files changed, 422 insertions(+), 3 deletions(-) create mode 100644 extensions/libxt_ipvs.c create mode 100644 extensions/libxt_ipvs.man create mode 100644 include/linux/netfilter/xt_ipvs.h
Quoted 20 lines · Simon Horman
Quoted 4 lines · Hannes Eder
The following series implements full NAT support for IPVS. The approach is via a minimal change to IPVS (make friends with
nf_conntrack) and adding a netfilter matcher, kernel- and user-space part, i.e.xt_ipvsandlibxt_ipvs.Its a bit late in the day for me to review the code, but I have a few quick comments.
Quoted 11 lines
Example usage:
% ipvsadm -A -t 192.168.100.30:80 -s rr
% ipvsadm -a -t 192.168.100.30:80 -r 192.168.10.20:80 -m# ...# Source NAT for VIP 192.168.100.30:80
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \Quoted 1 line
--vport 80 -j SNAT --to-source 192.168.10.10
Quoted 7 lines
Quoted 4 lines
or SNAT-ing only a specific real server:
% iptables -t nat -A POSTROUTING --dst 192.168.11.20 \
Quoted 1 line
-m ipvs --vaddr 192.168.100.30/32 -j SNAT --to-source 192.168.10.10
If the iptables rule is not in place does LVS just use its old NAT behaviour?
Yes, without iptables rules LVS NAT does DNAT.
Quoted 11 lines
Quoted 11 lines
First of all, thanks for all the feedback. This is the changelog for v2:
- Make
ip_vs_ftpwork again. Setupnf_conntrackexpectations for related data connections (based on Julian's patch see
http://www.ssi.bg/~ja/nfct/) and let nf_conntrack/nf_nat do the packet mangling and the TCP sequence adjusting.This change rises the question how to deal with
ip_vs_sync? Does it work together with conntrackd? Wild idea: what about getting rid ofip_vs_syncand piggy packing all onnf_conntrackand use conntrackd?
Quoted 6 lines
Quoted 1 line
Any comments on this?
That sounds like a reasonable suggestion.
I think that
ip_vs_synccame along before conntrackd and no one has given much thought to merging the functionality.
Okay, I'll dig further in this direction.
Cheers,
-Hannes
Simon Horman
maintainerQuoted 23 lines · Hannes Eder
Quoted 22 lines · Simon Horman
Quoted 4 lines · Hannes Eder
The following series implements full NAT support for IPVS. The approach is via a minimal change to IPVS (make friends with
nf_conntrack) and adding a netfilter matcher, kernel- and user-space part, i.e.xt_ipvsandlibxt_ipvs.Its a bit late in the day for me to review the code, but I have a few quick comments.
Quoted 13 lines
Example usage:
% ipvsadm -A -t 192.168.100.30:80 -s rr
% ipvsadm -a -t 192.168.100.30:80 -r 192.168.10.20:80 -m# ...# Source NAT for VIP 192.168.100.30:80
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \Quoted 1 line
--vport 80 -j SNAT --to-source 192.168.10.10
or SNAT-ing only a specific real server:
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
% iptables -t nat -A POSTROUTING --dst 192.168.11.20 \
Quoted 1 line
-m ipvs --vaddr 192.168.100.30/32 -j SNAT --to-source 192.168.10.10
If the iptables rule is not in place does LVS just use its old NAT behaviour?
Yes, without iptables rules LVS NAT does DNAT.
Great.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
First of all, thanks for all the feedback. This is the changelog for v2:
- Make
ip_vs_ftpwork again. Setupnf_conntrackexpectations for related data connections (based on Julian's patch see
http://www.ssi.bg/~ja/nfct/) and let nf_conntrack/nf_nat do the packet mangling and the TCP sequence adjusting.This change rises the question how to deal with
ip_vs_sync? Does it work together with conntrackd? Wild idea: what about getting rid ofip_vs_syncand piggy packing all onnf_conntrackand use conntrackd?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Any comments on this?
That sounds like a reasonable suggestion.
I think that
ip_vs_synccame along before conntrackd and no one has given much thought to merging the functionality.Okay, I'll dig further in this direction.
Assuming the technical side is clean, I suspect the major problem will be how to migrate users away from ip_vs_sync.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines · Simon Horman
Quoted 4 lines · Hannes Eder
The following series implements full NAT support for IPVS. The approach is via a minimal change to IPVS (make friends with
nf_conntrack) and adding a netfilter matcher, kernel- and user-space part, i.e.xt_ipvsandlibxt_ipvs.Its a bit late in the day for me to review the code, but I have a few quick comments.
Quoted 11 lines
Example usage:
% ipvsadm -A -t 192.168.100.30:80 -s rr
% ipvsadm -a -t 192.168.100.30:80 -r 192.168.10.20:80 -m# ...# Source NAT for VIP 192.168.100.30:80
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \Quoted 1 line
--vport 80 -j SNAT --to-source 192.168.10.10
Quoted 7 lines
Quoted 4 lines
or SNAT-ing only a specific real server:
% iptables -t nat -A POSTROUTING --dst 192.168.11.20 \
Quoted 1 line
-m ipvs --vaddr 192.168.100.30/32 -j SNAT --to-source 192.168.10.10
If the iptables rule is not in place does LVS just use its old NAT behaviour?
Yes, without iptables rules LVS NAT does DNAT.
Quoted 11 lines
Quoted 11 lines
First of all, thanks for all the feedback. This is the changelog for v2:
- Make
ip_vs_ftpwork again. Setupnf_conntrackexpectations for related data connections (based on Julian's patch see
http://www.ssi.bg/~ja/nfct/) and let nf_conntrack/nf_nat do the packet mangling and the TCP sequence adjusting.This change rises the question how to deal with
ip_vs_sync? Does it work together with conntrackd? Wild idea: what about getting rid ofip_vs_syncand piggy packing all onnf_conntrackand use conntrackd?
Quoted 6 lines
Quoted 1 line
Any comments on this?
That sounds like a reasonable suggestion.
I think that
ip_vs_synccame along before conntrackd and no one has given much thought to merging the functionality.
Okay, I'll dig further in this direction.
Cheers,
-Hannes
Quoted 20 lines · Simon Horman
Quoted 4 lines · Hannes Eder
The following series implements full NAT support for IPVS. The approach is via a minimal change to IPVS (make friends with
nf_conntrack) and adding a netfilter matcher, kernel- and user-space part, i.e.xt_ipvsandlibxt_ipvs.Its a bit late in the day for me to review the code, but I have a few quick comments.
Quoted 11 lines
Example usage:
% ipvsadm -A -t 192.168.100.30:80 -s rr
% ipvsadm -a -t 192.168.100.30:80 -r 192.168.10.20:80 -m# ...# Source NAT for VIP 192.168.100.30:80
% iptables -t nat -A POSTROUTING -m ipvs --vaddr 192.168.100.30/32 \Quoted 1 line
--vport 80 -j SNAT --to-source 192.168.10.10
Quoted 7 lines
Quoted 4 lines
or SNAT-ing only a specific real server:
% iptables -t nat -A POSTROUTING --dst 192.168.11.20 \
Quoted 1 line
-m ipvs --vaddr 192.168.100.30/32 -j SNAT --to-source 192.168.10.10
If the iptables rule is not in place does LVS just use its old NAT behaviour?
Yes, without iptables rules LVS NAT does DNAT.
Quoted 11 lines
Quoted 11 lines
First of all, thanks for all the feedback. This is the changelog for v2:
- Make
ip_vs_ftpwork again. Setupnf_conntrackexpectations for related data connections (based on Julian's patch see
http://www.ssi.bg/~ja/nfct/) and let nf_conntrack/nf_nat do the packet mangling and the TCP sequence adjusting.This change rises the question how to deal with
ip_vs_sync? Does it work together with conntrackd? Wild idea: what about getting rid ofip_vs_syncand piggy packing all onnf_conntrackand use conntrackd?
Quoted 6 lines
Quoted 1 line
Any comments on this?
That sounds like a reasonable suggestion.
I think that
ip_vs_synccame along before conntrackd and no one has given much thought to merging the functionality.
Okay, I'll dig further in this direction.
Cheers,
-Hannes
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html