33 lines
760 B
Bash
33 lines
760 B
Bash
#!/usr/bin/env bash
|
|
ip link add veth-inner type veth peer name veth-outer
|
|
ip link set dev veth-outer netns default
|
|
ip link set dev veth-inner master mynet0
|
|
|
|
ip link set dev veth-inner up
|
|
ip link set dev mynet0 up
|
|
ip link set dev veth-inner up
|
|
|
|
wg setconf vpn /snacks/wireguard/wg.conf
|
|
ip link set dev vpn up
|
|
ip addr flush dev vpn
|
|
ip route flush dev vpn
|
|
|
|
echo ${VPN_IPV4_ADDRESS}
|
|
echo ${VPN_IPV6_ADDRESS}
|
|
|
|
ip addr add ${VPN_IPV4_ADDRESS} dev vpn
|
|
ip addr add ${VPN_IPV6_ADDRESS} dev vpn
|
|
|
|
if [ -z ${OUTER_ROUTE_V4+x} ]
|
|
then
|
|
ip -4 route add "${OUTER_ROUTE_V4}" via "${OUTER_GATEWAY_V4}"
|
|
fi
|
|
|
|
if [ -z ${OUTER_ROUTE_V6+x} ]
|
|
then
|
|
ip -6 route add "${OUTER_ROUTE_V6}" via "${OUTER_GATEWAY_V6}"
|
|
fi
|
|
|
|
ip -4 route add default dev vpn
|
|
ip -6 route add default dev vpn
|