Logical Topology



Question
  1. Router has 2 NIC (Public & Private).
  2. Server only has 1 NIC (Private).
  3. How to make website in the server publicly accessible?
Answer
  1. NAT Configuration
  2. Port forwading 80 to 8080
Enable IP forwarding (Server)

vim /etc/sysctl.conf
net.ipv4.ip_forward = 1 #default is 0

vim /proc/sys/net/ipv4/ip_forward
1 #default is 0

Allow NAT (Router)

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

Configure port forwarding (Router)

iptables -t nat -A PREROUTING -p tcp --dport 8080 -d 43.245.x.x -j DNAT --to-destination 192.168.9.42:80