2

How can we get the Apache instance in a private subnet to work?

Configuration
Public subnet with 1 NAT instance
Private subnet with 1 App instance

Details
1. Masquerading is turned on NAT on via

    iptables -t nat -A POSTROUTING -j MASQUERADE

2. PREROUTING is enabled via
iptables -t nat -A PREROUTING -p tcp --port 80 -j DNAT --to-destination 10.0.10.102:80
3. Port forwarding is enabled in /proc/sys/net/ipv4/ip_forward
4. Security group for both NAT & App (Would never keep these in production but purely to show all ports are open)

    Inbound All Traffic 0.0.0.0/0
    Outbound All Traffic 0.0.0.0/0

5. Network ACLs

    Inbound All Ports 0.0.0.0/0
    Outbound All Ports 0.0.0.0/0

6. Ping & wget work for external requests

    ping google.com
    wget google.com

7. Apache is listening on the App instance in the private subnet.

    netstat -tulpn
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp6       0      0 :::80                   :::*                    LISTEN      -

Apache Traffic
Public Requests to the Apache server on the private subnet does not work.

wget http://127.0.0.0.1/index.html   => success
# public IP requests
wget http://xxx.x.x.x/index.html   => failure
Connecting to xxx.x.x.x:80...      => hangs

From the NAT host terminal

sudo tcpdump -i any -n port 80
sudo: unable to resolve host ip-10-0-0-71
15:22:17.668089 IP 10.0.10.102.54033 > X.X.X.X.80: Flags [S], seq 848018267, win 26883, options [mss 8961,sackOK,TS val 19553465 ecr 0,nop,wscale 7], length 0
15:22:17.668111 IP 10.0.0.71.54033 > X.X.X.X.80: Flags [S], seq 848018267, win 26883, options [mss 8961,sackOK,TS val 19553465 ecr 0,nop,wscale 7], length 0

What do we need to do so Apache will work from the private subnet?

  • Is this AWS? If so, did you verify that forwarding is enabled in the kernel and that source/destination checking is disabled? – EEAA Oct 2 '14 at 17:56
  • Are you masquerading on the NAT instance? This post might be useful serverfault.com/questions/570386/… – Andrew Oct 2 '14 at 19:08
  • @EEAA yes this is AWS. Source/destination checking is disabled. Forwarding is enabled in /proc/sys/net/ipv4/ip_forward. Is there somewhere else to check on the forwarding? – csi Oct 3 '14 at 0:35
  • @Andrew iptables -t nat -A POSTROUTING -j MASQUERADE. Ping does not work. wget does though. – csi Oct 3 '14 at 1:26
  • 2
    Do you have the needed rules on the NAT device in the filter table's FORWARD chain and the nat table's PREROUTING chain? – Mark Wagner Oct 8 '14 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.