You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 20, 2024. It is now read-only.
The current snat.sh script doesn't work on Amazon Linux 2023.
Here's my first attempt at an alternative script for Amazon Linux 2023
#!/bin/bash -x# wait for ens6while! ip link show dev ens6;do
sleep 1
done# NAT Instance Setup# https://docs.aws.amazon.com/vpc/latest/userguide/VPC_NAT_Instance.html#NATInstance# enable IP forwarding and NAT on ens6
sysctl -q -w net.ipv4.ip_forward=1
sysctl -q -w net.ipv4.conf.ens6.send_redirects=0
/sbin/iptables -t nat -A POSTROUTING -o ens6 -j MASQUERADE
service iptables save
# switch the default route to ens6
GATEWAY=$(ip route | awk '/default/ { print $3 }')
ip route add $GATEWAY dev ens6
ip route add default via $GATEWAY
ip route del default dev ens5
# wait for network connection
curl --retry 10 http://www.example.com
# re-establish connections
systemctl restart amazon-ssm-agent
There's a couple of areas which could use improvement such as:
Don't hardcode ens5 and ens6
Persist the routes after a reboot
If there is anyone else interested in having this module work with Amazon Linux 2023 comment here and i'll submit a PR.