-3

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 ..

0

This makes no sense to me... but...

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 ..

the box does not control what nic network traffic comes from, it arrives on the nic then the box process' it... so any attempt to mask which nic the traffic arrived from is a task in vein...

you can however tell the box which nic to send traffic out on (providing you're not sending your traffic out to a tcp connection established via another nic)... ie if the traffic originated from the box in question...

to do this;

/etc/sysconfig/network-scripts/route-eth0

default via 10.10.0.1 dev eth1

iptables is not for moving traffic between nics, and use DNAT / SNAT, not MASQUERADE for static ip.

please re-structure or clarify your question, as it seems unclear...

  • Sorry men its not working , and with iptables we can move traffic to particular nics . I have written my query in simple english . Let me explain you clearly here, i want all outbond traffic from eth1 , where my default is eth0. and box can control traffic with nics , dont know but its a basics men. – Vinood NK Maheshwari Nov 9 '16 at 7:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.