Linux Packet Forwarding

Can linux forward packets back through the same interface they came?  If so, how can this be accomplished with routes?  Thanks.
MainStaySolutionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

easyDKCommented:
May be helpfull to get at least part of topology, but generally said, it is possible to route thru the same interface. If we do have two networks directly connected:
route add -net xx.xx.xx.0 netmask y.y.y.0 dev eth0
route add -net aa.aa.aa.0 netmask b.b.b.0 dev eth0

If there's gateway to one of the networks on the way, use
route add -net xx.xx.xx.0 netmask y.y.y.0 gw zz.zz.zz.zz

Don't forget to switch on packet forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ravenplCommented:
Yes it can, use normal routing rules.
But mind, that if the connection gets SNATed or DNATed on the router as well - both actions are required SNAT and DNAT.
0
ravenplCommented:
Oh, one more thing, linux by default does not route such packets, but sends redirect to the sending device (so it knows there shorter path). To disable this
for f in /proc/sys/net/ipv4/conf/*/send_redirects; do echo 0 > $f; done
0
MainStaySolutionsAuthor Commented:
Thank you for the quick response.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Security

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.