diff --git a/network/init.sh b/network/init.sh index c0dbb58e3219551b47824566fe94066d2dcf494d..8078563d5abf667b59ead33f92a3f890d4c7779d 100755 --- a/network/init.sh +++ b/network/init.sh @@ -44,4 +44,6 @@ confln cdwifi-autologin.service /lib/systemd/system/ cr confln blatto-daemon.py /usr/bin/net-blatto-daemon c init-service net-blatto-daemon root /usr/bin/net-blatto-daemon "" "ExecReload=/bin/kill -HUP \$MAINPID" +confln namespaces /etc/net/ cr + install_ok diff --git a/network/namespaces b/network/namespaces new file mode 100755 index 0000000000000000000000000000000000000000..f73d5388df11f4268ba9c0772116bac5e5a9ade4 --- /dev/null +++ b/network/namespaces @@ -0,0 +1,34 @@ +#!/bin/sh +set -o xtrace + + +ipv4_prefix=10.39 + +add_netns() +{ + name=$1 + ipv4_subnet=$2 + route_rule=$3 + ip netns add $name + ip link add ve2$name type veth peer name vp2${name} + ip link set vp2${name} netns $name + ip addr add $ipv4_prefix.$ipv4_subnet.1/24 dev ve2$name + ip route add $ipv4_prefix.$ipv4_subnet.0/24 dev ve2$name table 39 + ip -n $name addr add $ipv4_prefix.$ipv4_subnet.10/24 dev vp2${name} + ip link set ve2$name up + ip -n $name link set vp2${name} up + ip netns exec $name ip link set dev lo up + ip netns exec $name ip route add default via $ipv4_prefix.$ipv4_subnet.1 + ip-man replace_rule --iif ve2$name --priority_base 100 $route_rule +} + +add_netns 2direct 0 254 +add_netns 2bl-mn 2 122 +add_netns 2bl-awn 3 123 +add_netns 2bl-mul 4 124 + +add_netns 2untr 6 6 +add_netns 2untr-bl 61 6121 +add_netns 2untr-bl-mn 62 6122 +add_netns 2untr-bl-awn 63 6123 +add_netns 2untr-bl-mul 64 6124