Skip to content

Commit

Permalink
Extract ipv4 address only when starting docker in gVisor.
Browse files Browse the repository at this point in the history
The address will be used to set up filter rules.

PiperOrigin-RevId: 697883823
  • Loading branch information
milantracy authored and gvisor-bot committed Nov 19, 2024
1 parent 6953ca0 commit 6666e9f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion images/basic/docker/start-dockerd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
set -xe -o pipefail

dev=$(ip route show default | sed 's/.*\sdev\s\(\S*\)\s.*$/\1/')
addr=$(ip addr show dev "$dev" | grep inet | sed 's/^\s*inet\s\(\S*\)\/.*$/\1/')
addr=$(ip addr show dev "$dev" | grep -w inet | sed 's/^\s*inet\s\(\S*\)\/.*$/\1/')

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables-legacy -t nat -A POSTROUTING -o "$dev" -j SNAT --to-source "$addr" -p tcp
Expand Down

0 comments on commit 6666e9f

Please sign in to comment.