Home configure-ec2-instance-as-nat
Post
Cancel

configure-ec2-instance-as-nat

run this script;

1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/eth0/send_redirects
/sbin/iptables -t nat -A POSTROUTING -o eth0 -s 0.0.0.0/0 -j MASQUERADE
/sbin/iptables-save > /etc/sysconfig/iptables
mkdir -p /etc/sysctl.d/
cat <<EOF > /etc/sysctl.d/nat.conf
net.ipv4.ip_forward = 1
net.ipv4.conf.eth0.send_redirects = 0
EOF

echo "now add the route into the route table, Destination 0.0.0.0/0 Target (this instance) and also disable Source/Dest check on that(this) same instance"
This post is licensed under CC BY 4.0 by the author.