Skip to content

Commit af172e0

Browse files
committed
feat: switch to iptables-legacy due to nftables incompatiblility on windows machines
1 parent 51001d8 commit af172e0

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ FROM alpine:3.20.1
33

44
RUN apk --no-cache upgrade \
55
&& apk --no-cache add \
6-
nftables \
6+
# nftables \
7+
iptables iptables-legacy \
78
libcap
89

910
COPY ./entrypoint.sh /

entrypoint.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,34 @@ echo "Docker Host: $docker_host_ip ($docker_host_source)"
6969
PORTS="${PORTS:-"1-65535"}"
7070
PORTS="$(echo ${PORTS//,/ })"
7171

72-
nft add table nat
73-
nft add chain nat prerouting { type nat hook prerouting priority -100 \; }
74-
nft add chain nat postrouting { type nat hook postrouting priority 100 \; }
72+
# nft add table nat
73+
# nft add chain nat prerouting { type nat hook prerouting priority -100 \; }
74+
# nft add chain nat postrouting { type nat hook postrouting priority 100 \; }
7575

7676
echo "Forwarding ports: ${PORTS// /, }"
7777
for forwarding_port in $PORTS
7878
do
7979
docker_container_port="${forwarding_port%%:*}"
8080
docker_host_port="${forwarding_port#*:}"
8181

82-
nft add rule nat prerouting tcp \
83-
dport "${docker_container_port}" dnat to "$docker_host_ip:$docker_host_port"
84-
nft add rule nat prerouting udp \
85-
dport "${docker_container_port}" dnat to "$docker_host_ip:$docker_host_port"
86-
82+
# nft add rule nat prerouting tcp \
83+
# dport "${docker_container_port}" \
84+
# dnat to "$docker_host_ip:$docker_host_port"
85+
iptables-legacy --table nat --insert PREROUTING \
86+
--protocol tcp --destination-port "${docker_container_port/-/:}" \
87+
--jump DNAT --to-destination "$docker_host_ip:$docker_host_port"
88+
89+
# nft add rule nat prerouting udp \
90+
# dport "${docker_container_port}" \
91+
# dnat to "$docker_host_ip:$docker_host_port"
92+
iptables-legacy --table nat --insert PREROUTING \
93+
--protocol udp --destination-port "${docker_container_port/-/:}" \
94+
--jump DNAT --to-destination "$docker_host_ip:$docker_host_port"
8795
done
8896

89-
nft add rule nat postrouting masquerade
97+
# nft add rule nat postrouting masquerade
98+
iptables-legacy --table nat --insert POSTROUTING --jump MASQUERADE
99+
90100

91101
# --- Drop root access and "Ah, ha, ha, ha, stayin' alive" ---------------------
92102

0 commit comments

Comments
 (0)