We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 93917e5 commit 1518e88Copy full SHA for 1518e88
cns/common/utils.go
@@ -0,0 +1,29 @@
1
+package common
2
+
3
+import (
4
+ "fmt"
5
+ "os/exec"
6
7
+ "github.com/Azure/azure-container-networking/log"
8
+)
9
10
+func ExecuteShellCommand(command string) error {
11
+ log.Printf("[Azure-CNS] %s", command)
12
+ cmd := exec.Command("sh", "-c", command)
13
+ err := cmd.Start()
14
+ if err != nil {
15
+ return err
16
+ }
17
+ return cmd.Wait()
18
+}
19
20
+func SetOutboundSNAT(subnet string) error {
21
+ cmd := fmt.Sprintf("iptables -t nat -A POSTROUTING -m iprange ! --dst-range 168.63.129.16 -m addrtype ! --dst-type local ! -d %v -j MASQUERADE",
22
+ subnet)
23
+ err := ExecuteShellCommand(cmd)
24
25
+ log.Printf("SNAT Iptable rule was not set")
26
27
28
+ return nil
29
0 commit comments