Last active
September 16, 2017 02:53
-
-
Save khibino/4568b3e014e2ffde01407aedbe993385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto lxc-br | |
iface lxc-br inet static | |
address 172.23.0.1/16 | |
## OUI of PEGATRON CORPORATION is 60:02:92 | |
## lower two bits of first octet is | |
## Global - 0 / Local - 1 bit and Individual - 0 / Group - 1 bit, | |
## so 60 + 2 + 0 == 62 | |
bridge_ports none | |
bridge_hw 62:02:92:11:11:01 | |
bridge_maxwait 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
lxc.network.type = veth | |
lxc.network.flags = up | |
lxc.network.link = lxc-br | |
# the ip may be set to 0.0.0.0/24 or skip this line | |
# if you like to use a dhcp client inside the container | |
lxc.network.ipv4 = 172.23.0.10/16 | |
lxc.network.ipv4.gateway = 172.23.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cmd="$1" | |
host_if="$2" | |
if [ x"$cmd" = x ]; then | |
cat<<EOF | |
Usage: $0 {start|stop} [NAT_INTERFACE] | |
$0 show | |
EOF | |
exit 0 | |
fi | |
start() { | |
/sbin/iptables -t nat -A POSTROUTING -o ${host_if} -j MASQUERADE | |
/sbin/sysctl -w net.ipv4.ip_forward=1 | |
} | |
stop() { | |
/sbin/sysctl -w net.ipv4.ip_forward=0 | |
/sbin/iptables -t nat -D POSTROUTING -o ${host_if} -j MASQUERADE | |
} | |
set -x | |
case $cmd in | |
show) | |
/sbin/sysctl net.ipv4.ip_forward | |
/sbin/iptables -t nat -L -v | |
;; | |
start|stop) | |
if [ x"$host_if" = x ]; then | |
for i in eth0 ; do | |
host_if=$i | |
$cmd | |
done | |
else | |
$cmd | |
fi | |
;; | |
*) | |
echo "Unknown command: $cmd" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment