diff --git a/Dockerfile b/Dockerfile index 0a07e3c..4f21e09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ FROM alpine:3.20.1 RUN apk --no-cache upgrade \ && apk --no-cache add \ - nftables \ + # nftables \ + iptables iptables-legacy \ libcap COPY ./entrypoint.sh / diff --git a/entrypoint.sh b/entrypoint.sh index 4353711..eb6be3d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -69,9 +69,9 @@ echo "Docker Host: $docker_host_ip ($docker_host_source)" PORTS="${PORTS:-"1-65535"}" PORTS="$(echo ${PORTS//,/ })" -nft add table nat -nft add chain nat prerouting { type nat hook prerouting priority -100 \; } -nft add chain nat postrouting { type nat hook postrouting priority 100 \; } +# nft add table nat +# nft add chain nat prerouting { type nat hook prerouting priority -100 \; } +# nft add chain nat postrouting { type nat hook postrouting priority 100 \; } echo "Forwarding ports: ${PORTS// /, }" for forwarding_port in $PORTS @@ -79,14 +79,24 @@ do docker_container_port="${forwarding_port%%:*}" docker_host_port="${forwarding_port#*:}" - nft add rule nat prerouting tcp \ - dport "${docker_container_port}" dnat to "$docker_host_ip:$docker_host_port" - nft add rule nat prerouting udp \ - dport "${docker_container_port}" dnat to "$docker_host_ip:$docker_host_port" - + # nft add rule nat prerouting tcp \ + # dport "${docker_container_port}" \ + # dnat to "$docker_host_ip:$docker_host_port" + iptables-legacy --table nat --insert PREROUTING \ + --protocol tcp --destination-port "${docker_container_port/-/:}" \ + --jump DNAT --to-destination "$docker_host_ip:$docker_host_port" + + # nft add rule nat prerouting udp \ + # dport "${docker_container_port}" \ + # dnat to "$docker_host_ip:$docker_host_port" + iptables-legacy --table nat --insert PREROUTING \ + --protocol udp --destination-port "${docker_container_port/-/:}" \ + --jump DNAT --to-destination "$docker_host_ip:$docker_host_port" done -nft add rule nat postrouting masquerade +# nft add rule nat postrouting masquerade +iptables-legacy --table nat --insert POSTROUTING --jump MASQUERADE + # --- Drop root access and "Ah, ha, ha, ha, stayin' alive" ---------------------