Last active
August 29, 2015 14:17
-
-
Save rogerbush8/048d17eec71da6a09fbf to your computer and use it in GitHub Desktop.
configure-linux-as-nat-rhel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script configures a linux box as a NAT router (PAT), suitable for use | |
# for AWS instances in a VPC Private Subnet to communicate with the Internet | |
# | |
# To setup a NAT: | |
# # Create an AWS instance in Public Subnet | |
# # Disable src./dest. check (networking menu in UI) | |
# | |
# To install, login to instance: | |
# sudo su - | |
# curl http://gist.github.com/.../raw/... | bash -s | |
# | |
cd /root | |
yum -y update | |
yum -y update aws* | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment