Skip to content

Instantly share code, notes, and snippets.

@xkou
Last active September 30, 2016 05:33
Show Gist options
  • Save xkou/8614222 to your computer and use it in GitHub Desktop.
Save xkou/8614222 to your computer and use it in GitHub Desktop.
_setip(){
eth=eth0
id=$1
ip link add link $eth name vlan$id address 00:aa:bb:cc:dd:0$id type macvlan
ifconfig vlan$id 10.1.1.8$id up
ip route add default dev vlan$id table tab$id
ip rule add from 10.1.1.8$id lookup tab$id
# route del -net 0.0.0.0 netmask 0.0.0.0 dev vlan$id
route del -net 1.0.0.0 netmask 255.0.0.0 dev vlan$id
}
for i in `seq 1 9`; do
_setip $i
done
cat /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
21 tab1
22 tab2
23 tab3
24 tab4
25 tab5
26 tab6
27 tab7
28 tab8
29 tab9
run(){
ID=$1
CID=$(docker run -d -w /home p1 ./privoxy --no-daemon )
sleep 1
echo $CID $ID 10.1.1.8$ID
#/home/xuke/pipework/pipework eth0 -i eth2 $CID 10.1.1.8$ID/16
#/home/xuke/pipework/pipework --direct-phys eth0 $CID 10.1.1.8/16
/home/xuke/pipework/pipework vlan$ID $CID 10.1.1.8$ID/24@10.1.1.1
sleep 1
}
for i in `seq 1 2`; do
run $i
done
#docker run -d -p 8118:8118 shinobit/privoxy /usr/local/bin/startprivoxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment