-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemplate.nacl
57 lines (50 loc) · 1.09 KB
/
template.nacl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Variables to modify
gw.left.net: {{.GwLeftNet}}
gw.left.netmask: {{.GwLeftNetmask}}
left.address: {{.LeftAddress}}
gw.right.net: {{.GwRightNet}}
gw.right.netmask: {{.GwRightNetmask}}
right.address: {{.RightAddress}}
LEFTPORT: {{.LeftPort}}
NEXTHOPADDRESS: {{.NextHopAddress}}
NEXTHOPPORT: {{.NextHopPort}}
Iface mgmt {
index: 0,
config: dhcp
}
Iface left {
index: 1,
netmask: gw.left.netmask,
prerouting: dnat
}
Iface right {
index: 2,
netmask: gw.right.netmask,
postrouting: snat
}
Gateway gw {
left: {
iface: left
},
right: {
iface: right
}
}
Nat::IP dnat {
Nat::TCP {
if (ip.daddr == left.address) {
if (tcp.dport == LEFTPORT) {
log("dnat activated, by: ", ip.daddr, ":", tcp.dport, "\n")
dnat(NEXTHOPADDRESS, NEXTHOPPORT)
}
}
}
}
Nat::IP snat {
Nat::TCP {
if (ip.daddr == NEXTHOPADDRESS and tcp.dport == NEXTHOPPORT) {
log("snat activated, sending: ", ip.daddr, ":", tcp.dport, "\n")
snat(right.address)
}
}
}