Weave script calls Go implementation of expose_nat
This commit is contained in:
1 parent
a07e3301b1
commit
e458c11e66
3 files changed
+25
-9
No files matched your search
@@ -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", "<cidr>...")
|
||||||
|
}
|
||||||
|
|
||||||
|
cidrs, err := parseCIDRs(args)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, cidr := range cidrs {
|
||||||
|
if err := weavenet.ExposeNAT(*cidr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@ func init() {
|
|||||||
"list-netdevs": listNetDevs,
|
"list-netdevs": listNetDevs,
|
||||||
"cni-net": cniNet,
|
"cni-net": cniNet,
|
||||||
"cni-ipam": cniIPAM,
|
"cni-ipam": cniIPAM,
|
||||||
|
"expose-nat": exposeNAT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -661,14 +661,6 @@ expose_ip() {
|
|||||||
done
|
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
|
# create veth with ends $1-$2, and then invoke $3..., removing the
|
||||||
# veth on failure. No-op of veth already exists.
|
# veth on failure. No-op of veth already exists.
|
||||||
create_veth() {
|
create_veth() {
|
||||||
@@ -2222,7 +2214,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
create_bridge --without-ethtool
|
create_bridge --without-ethtool
|
||||||
expose_ip
|
expose_ip
|
||||||
expose_nat
|
util_op expose-nat $ALL_CIDRS
|
||||||
show_addrs $ALL_CIDRS
|
show_addrs $ALL_CIDRS
|
||||||
;;
|
;;
|
||||||
hide)
|
hide)
|
||||||
|
|||||||
Reference in new issue
Block a user