Re: routing through a specifc network

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2012-11-15 at 15:05 +0530, PRA wrote:
> 1)  eth0 =  a.b.X.121(gateway a.b.X.1)
> 2)   eth1 = a.b.Y.21 (gateway a.b.Y.1)
> 
> there is a sftp server which is  (  a.b.X.122 ).
> 
> Now when ever  I run sftp command  I need the traffic to be routed 
> through eth1 interface.

You should be able to do this by marking packets and routing with ip
route.

Something like this:

iptables -A OUTPUT -t mangle -p tcp --sport 22 -j MARK --set-mark 1
ip rule add fwmark 1 table table1
ip route add table table1 default dev eth1

I'm not sure, but you might need to SNAT as well:

iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to-source a.b.Y.21

Of course, that will route any SSH connection as such, not just SFTP.

Andy


--
To unsubscribe from this list: send the line "unsubscribe lartc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux