mirror of
https://github.com/dangeroustech/ZeroTierBridge.git
synced 2025-12-06 00:56:58 +00:00
Init Commit
This commit is contained in:
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
FROM debian:buster as stage
|
||||
ARG PACKAGE_BASEURL=https://download.zerotier.com/debian/buster/pool/main/z/zerotier-one
|
||||
ARG ARCH=amd64
|
||||
ARG VERSION=1.6.5
|
||||
RUN apt-get update -qq && apt-get install -qq --no-install-recommends -y ca-certificates=20200601~deb10u2 curl=7.64.0-4+deb10u2
|
||||
RUN curl -sSL -o zerotier-one.deb "${PACKAGE_BASEURL}/zerotier-one_${VERSION}_${ARCH}.deb"
|
||||
|
||||
FROM debian:buster
|
||||
COPY --from=stage zerotier-one.deb .
|
||||
RUN apt-get update -qq && apt-get install -qq --no-install-recommends -y procps=2:3.3.15-2 iptables=1.8.2-4 \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN dpkg -i zerotier-one.deb && rm -f zerotier-one.deb
|
||||
RUN echo "${VERSION}" >/etc/zerotier-version
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod 755 /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
40
entrypoint.sh
Normal file
40
entrypoint.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
grepzt() {
|
||||
(find /proc -name exe | xargs -I{} readlink {}) 2>/dev/null | grep -q zerotier-one
|
||||
return $?
|
||||
}
|
||||
|
||||
echo "starting zerotier"
|
||||
setsid /usr/sbin/zerotier-one &
|
||||
|
||||
while ! grepzt
|
||||
do
|
||||
echo "zerotier hasn't started, waiting a second"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "joining networks: $ZT_NETWORK"
|
||||
|
||||
echo "joining $ZT_NETWORK"
|
||||
|
||||
while ! zerotier-cli join "$ZT_NETWORK"
|
||||
do
|
||||
echo "joining $ZT_NETWORK failed; trying again in 1s"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
|
||||
### Set IPTables to allow NATting
|
||||
echo "setting up NATting"
|
||||
sysctl -w net.ipv4.ip_forward=1
|
||||
PHY_IFACE=eth0; ZT_IFACE=$(ls /sys/class/net | grep ^zt)
|
||||
|
||||
iptables -t nat -A POSTROUTING -o $PHY_IFACE -j MASQUERADE
|
||||
iptables -A FORWARD -i $PHY_IFACE -o $ZT_IFACE -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
iptables -A FORWARD -i $ZT_IFACE -o $PHY_IFACE -j ACCEPT
|
||||
|
||||
echo "iptables --list-rules"
|
||||
echo "$(ip a)"
|
||||
|
||||
sleep infinity
|
||||
Reference in New Issue
Block a user