Logical Topology
Question
- Router has 2 NIC (Public & Private).
- Server only has 1 NIC (Private).
- How to make website in the server publicly accessible?
Answer
- NAT Configuration
- 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