In my AWS AMI Centos server i have deployed VPC with 2 subnet eth0 10.0.0.1 with internet gateway and eth1 10.10.0.1with NAT Gateway via Public ip, my problem is i have given my NAT gateway Public ip to client to interact or we can push data with that subnet. there are several client which connect to same server and i don’t want to add route to define from which subnet that ip shd push data , i want to change my default or say all my outgoing traffic from eth1 subnet. .. So far i have tried iptables and changing gateway in network script for full details check below .
/etc/sysctl.conf net.ipv4.ip_forward =1 sysctl net.ipv4.ip_forward = 1 sudo iptables -t nat -A POSTROUTING --out-interface eth1 -j MASQUERADE sudo iptables -A FORWARD --in-interface eth0 -j ACCEPT
with this i m not able to ping or telnet to client ip bec client has open its connection for eth1 subnet but when i forward traffic from eth0 to eth1 it doesnt changed source address it take eth0 subnet ip which is unknown to client network.
Even tried to change default eth1
**/etc/sysconfig/network GATEWAY=x.x.x.x GATEWAYDEV=eth1**
here all traffic blocks even incoming traffic also changes to eth1.
My requirement is my incoming traffic comes from eth0 subnet 10.0.0.1 and my outgoing traffic with eth1 subnet 10.10.0.1. adding route will make my process more hectic i want some thing automated adding one command or script which does it all ..