Skip to content

Instantly share code, notes, and snippets.

@perbu
Created November 24, 2017 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perbu/dac51ae342063058571c25801c213c1a to your computer and use it in GitHub Desktop.
Save perbu/dac51ae342063058571c25801c213c1a to your computer and use it in GitHub Desktop.
Iface eth0 dhcp
eth0.index: 0
Iface k1 {
address: 10.0.1.1,
netmask: 255.255.255.0,
index: 2,
prerouting: [ fw, mydnat ]
}
Iface k2 {
address: 10.0.2.1,
netmask: 255.255.255.0,
index: 1,
prerouting: [ deny ],
postrouting: [ mysnat ]
}
Gateway gw {
r1: {
net: 10.0.1.0,
netmask: 255.255.255.0,
iface: k1
},
r2: {
net: 10.0.2.0,
netmask: 255.255.255.0,
iface: k2
}
}
TARGET: 10.0.2.10
TPORT: 5001
Filter::IP deny {
if (ct.state == established) {
accept
}
drop
}
Filter::IP fw {
if (ct.state == established) {
accept
}
Filter::TCP {
if (ip.daddr == k1.address and tcp.dport == TPORT) {
accept
}
} // end TCP
drop
} // End of fw
Nat::IP mydnat {
Nat::TCP {
if (ip.daddr == k1.address and tcp.dport == TPORT ) {
dnat(TARGET)
}
}
}
Nat::IP mysnat {
Nat::TCP {
if (ip.daddr == TARGET and tcp.dport == TPORT ) {
snat(k2.address)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment