#!/bin/bash trap cleanup EXIT cleanup() { ip netns del test ip link del tve0 } ip netns add test || exit 1 ip link add name tve0 type veth peer name tve0x ip link set tve0x netns test ip netns exec test ip link set tve0x name eth0 ip link set tve0 up ip addr add 10.22.0.1/24 dev tve0 ip route add 10.23.0.0/16 via 10.22.0.2 ip netns exec test ip link set eth0 up ip netns exec test ip addr add 10.22.0.2/24 dev eth0 ip netns exec test ip route add default via 10.22.0.1 dev eth0 ip netns exec test sysctl net.ipv4.conf.all.forwarding=1 ip netns exec test ip rule add fwmark 1/1 table 1 ip netns exec test ip route add local default dev lo table 1 sleep 1