Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
persist ip_forward setting across reboots and procps upgrades
Browse files Browse the repository at this point in the history
Signed-off-by: Jesse Alford <[email protected]>
  • Loading branch information
JT Archie authored and anEXPer committed May 24, 2018
1 parent 1e07515 commit 2c6f7b5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions install-pcf/gcp/terraform/nats.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ resource "google_compute_instance" "nat-gateway-pri" {
}

metadata_startup_script = <<EOF
#! /bin/bash
sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
EOF
#!/bin/bash
sudo sysctl -w net.ipv4.ip_forward=1
sudo sh -c 'echo net.ipv4.ip_forward=1 | sudo tee -a /etc/sysctl.conf > /dev/null'
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
EOF
}

// NAT Secondary
Expand All @@ -50,8 +51,9 @@ resource "google_compute_instance" "nat-gateway-sec" {
}

metadata_startup_script = <<EOF
#! /bin/bash
sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
#!/bin/bash
sudo sysctl -w net.ipv4.ip_forward=1
sudo sh -c 'echo net.ipv4.ip_forward=1 | sudo tee -a /etc/sysctl.conf > /dev/null'
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
EOF
}
Expand Down Expand Up @@ -79,8 +81,9 @@ resource "google_compute_instance" "nat-gateway-ter" {
}

metadata_startup_script = <<EOF
#! /bin/bash
sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
#!/bin/bash
sudo sysctl -w net.ipv4.ip_forward=1
sudo sh -c 'echo net.ipv4.ip_forward=1 | sudo tee -a /etc/sysctl.conf > /dev/null'
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
EOF
}
Expand Down

0 comments on commit 2c6f7b5

Please sign in to comment.