diff --git a/prog/weaveutil/expose.go b/prog/weaveutil/expose.go new file mode 100644 index 00000000..758285a7 --- /dev/null +++ b/prog/weaveutil/expose.go @@ -0,0 +1,23 @@ +package main + +import ( + weavenet "github.com/weaveworks/weave/net" +) + +func exposeNAT(args []string) error { + if len(args) < 1 { + cmdUsage("expose-nat", "...") + } + + cidrs, err := parseCIDRs(args) + if err != nil { + return err + } + + for _, cidr := range cidrs { + if err := weavenet.ExposeNAT(*cidr); err != nil { + return err + } + } + return nil +} diff --git a/prog/weaveutil/main.go b/prog/weaveutil/main.go index f8bcc500..b4dabc65 100644 --- a/prog/weaveutil/main.go +++ b/prog/weaveutil/main.go @@ -34,6 +34,7 @@ func init() { "list-netdevs": listNetDevs, "cni-net": cniNet, "cni-ipam": cniIPAM, + "expose-nat": exposeNAT, } } diff --git a/weave b/weave index 8e9247d3..3d24a630 100755 --- a/weave +++ b/weave @@ -661,14 +661,6 @@ expose_ip() { done } -expose_nat() { - for CIDR in $ALL_CIDRS ; do - add_iptables_rule nat WEAVE -s $CIDR -d 224.0.0.0/4 -j RETURN - add_iptables_rule nat WEAVE -d $CIDR ! -s $CIDR -j MASQUERADE - add_iptables_rule nat WEAVE -s $CIDR ! -d $CIDR -j MASQUERADE - done -} - # create veth with ends $1-$2, and then invoke $3..., removing the # veth on failure. No-op of veth already exists. create_veth() { @@ -2222,7 +2214,7 @@ EOF fi create_bridge --without-ethtool expose_ip - expose_nat + util_op expose-nat $ALL_CIDRS show_addrs $ALL_CIDRS ;; hide)