Browse Source

update script

pull/15/head
Jason 4 years ago
parent
commit
81fe99945f
  1. 5
      Dockerfile
  2. 11
      tun2socks.sh

5
Dockerfile

@ -21,8 +21,9 @@ RUN apk add --update --no-cache iproute2 \
ENV TUN tun0
ENV ETH eth0
ENV ETHGW=
ENV TUNGW=
ENV ETHADDR=
ENV TUNADDR=
ENV TUNMASK=
ENV PROXY=
ENV LOGLEVEL=
ENV EXCLUDED=

11
tun2socks.sh

@ -2,8 +2,9 @@
TUN="${TUN:-tun0}"
ETH="${ETH:-eth0}"
ETHGW="${ETHGW:-172.16.1.1}"
TUNGW="${TUNGW:-198.18.0.1}"
ETHADDR="${ETHADDR:-172.16.1.1}"
TUNADDR="${TUNADDR:-198.18.0.1}"
TUNMASK="${TUNMASK:-255.254.0.0}"
PROXY="${PROXY:-172.16.1.2:1080}"
LOGLEVEL="${LOGLEVEL:-warning}"
EXCLUDED="${EXCLUDED:-172.16.1.2/32}"
@ -15,17 +16,17 @@ HOSTS="${HOSTS:-localhost=127.0.0.1}"
# create tun device
ip tuntap add mode tun dev "$TUN"
ip addr add "$TUNGW"/24 dev "$TUN"
ip addr add "$TUNADDR"/"$TUNMASK" dev "$TUN"
ip link set dev "$TUN" up
# change default gateway
ip route del default > /dev/null
ip route add default via "$TUNGW" dev "$TUN"
ip route add default via "$TUNADDR" dev "$TUN"
# add to ip route
for ip in $(echo "$EXCLUDED" | tr ',' '\n')
do
ip route add "$ip" via "$ETHGW"
ip route add "$ip" via "$ETHADDR"
done
if [ -n "$EXTRACMD" ]; then

Loading…
Cancel
Save