mirror of
https://github.com/thelittlerocket/docker-zerotier.git
synced 2024-09-20 06:46:02 +08:00
route file option added
This commit is contained in:
parent
9a03876495
commit
373f0f03ca
|
@ -40,7 +40,8 @@ You can choose working mode on the web page. If you turn on bridge (mode) on the
|
|||
Check my Github page for an example docker-compose.yml file.
|
||||
|
||||
- modify the `NETWORK_ID`
|
||||
- modify the `ROUTES` and use `<Remote Network>,<Zerotier node IP>;<another network>,<another Zerotier node IP>` if you would like to use Site-to-Site function between the networks. But do not forget to add the routes to your router too!
|
||||
- modify the `ROUTES` and use `<Remote Network>,<Zerotier node IP>;<another network>,<another Zerotier node IP>;...` if you would like to use Site-to-Site function between the networks. But do not forget to add the routes to your router too (because DHCP clients on LAN use default routes)!
|
||||
- You can use `config/route.list` files for route rules too. Check the example file for format.
|
||||
|
||||
```
|
||||
docker-compose up -d
|
||||
|
|
5
config/route.list
Normal file
5
config/route.list
Normal file
|
@ -0,0 +1,5 @@
|
|||
# format examples:
|
||||
# space separated
|
||||
# 192.168.0.0/16 10.144.25.133
|
||||
# comma separated
|
||||
# 10.1.0.0/24,10.144.33.242
|
|
@ -6,6 +6,8 @@ services:
|
|||
environment:
|
||||
- NETWORK_ID=9b............34
|
||||
# - ROUTES=10.10.12.0/23,10.147.20.115;10.10.14.0/23,10.147.20.220
|
||||
volumes:
|
||||
- './config/route.list:/config/route.list:ro'
|
||||
network_mode: host
|
||||
privileged: true
|
||||
restart: always
|
||||
|
|
|
@ -16,7 +16,10 @@ do
|
|||
sleep 5
|
||||
done
|
||||
|
||||
#
|
||||
# add route rules
|
||||
# from variable
|
||||
#
|
||||
if [ ! -z $ROUTES ]
|
||||
then
|
||||
for routeline in $( echo $ROUTES | sed "s@;@\n@g" )
|
||||
|
@ -32,5 +35,31 @@ then
|
|||
ip route
|
||||
fi
|
||||
|
||||
#
|
||||
# add route rules
|
||||
# from file
|
||||
#
|
||||
if [ -e /config/route.list ]
|
||||
then
|
||||
echo "Route file found: /config/route.list"
|
||||
cat config/route.list | while read line
|
||||
do
|
||||
for routeline in "$( echo $line | grep -iv '^#' )"
|
||||
do
|
||||
# if empty line found - skip this loop
|
||||
[ -z "$routeline" ] && { continue; }
|
||||
|
||||
ADDR="$( echo $routeline | cut -f1 -d',' | cut -f1 -d' ' )"
|
||||
GW="$( echo $routeline | cut -f2 -d',' | cut -f2 -d' ' )"
|
||||
if [ ! -z $ADDR ] && [ ! -z $GW ]
|
||||
then
|
||||
echo "adding route ... $ADDR via $GW"
|
||||
ip route add "$ADDR" via "$GW"
|
||||
fi
|
||||
done
|
||||
done
|
||||
ip route
|
||||
fi
|
||||
|
||||
# something that keep the container running
|
||||
tail -f /dev/null
|
||||
|
|
Loading…
Reference in a new issue