Re: [gentoo-user] [OT] Redirecting traffic for a TCP port to another gateway

2017-03-28 Thread Walter Dnes
On Tue, Mar 28, 2017 at 09:26:05PM +0200, Dan Johansson wrote

> Host 192.168.1.100/24 has a default-gateway of 192.168.1.1
> Now I want to send all traffic from this host to destination-tcp-port 80 
> to gateway 192.168.2.1 instead (the host has a second interface with the 
> address 192.168.2.100/24 as well).
> I only want the traffic to port 80 to go thru this GW (and then to its 
> final destination).
> And port 80 is just an example, it could be port 12345 as well.
> 
> Is this possible? If yes, any suggestion on how to do it?

  Use the FORWARD table (yes, it's built-in).  You'll need to divert
those packets from that source with "--dport 80" (i.e. destination port
80) from regular output to the built-in FORWARD table.

  iptables -A OUTPUT --source 192.168.1.100/24 --dport 80 -j FORWARD

  Step 2) I'm not familiar with the FORWARD table (never used it), but I
assume that you can specify stuff in it about where to forward.

-- 
Walter Dnes 
I don't run "desktop environments"; I run useful applications



Re: [gentoo-user] [OT] Redirecting traffic for a TCP port to another gateway

2017-03-28 Thread J. Roeleveld
On March 28, 2017 9:26:05 PM GMT+02:00, Dan Johansson  
wrote:
>Slight Off-topic, but at least the host are Gentoo.
>
>Is it possible, using iptables or something equivalent, to redirect 
>traffic to some specific TCP ports to another gateway than the 
>default-gateway?
>
>Eg.
>
>Host 192.168.1.100/24 has a default-gateway of 192.168.1.1
>Now I want to send all traffic from this host to destination-tcp-port
>80 
>to gateway 192.168.2.1 instead (the host has a second interface with
>the 
>address 192.168.2.100/24 as well).
>I only want the traffic to port 80 to go thru this GW (and then to its 
>final destination).
>And port 80 is just an example, it could be port 12345 as well.
>
>Is this possible? If yes, any suggestion on how to do it?
>
>Regards,

A quick google led to:

http://unix.stackexchange.com/questions/85932/how-can-i-redirect-outbound-traffic-to-port-80-using-iptables-locally

I am not certain this will correctly work or not. If the other server has a 
proxy server running, you might need to change its configuration accordingly.

--
Joost
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.



Re: [gentoo-user] [OT] Redirecting traffic for a TCP port to another gateway

2017-03-28 Thread Alarig Le Lay
On mar. 28 mars 21:26:05 2017, Dan Johansson wrote:
> Slight Off-topic, but at least the host are Gentoo.
> 
> Is it possible, using iptables or something equivalent, to redirect traffic
> to some specific TCP ports to another gateway than the default-gateway?
> 
> Eg.
> 
> Host 192.168.1.100/24 has a default-gateway of 192.168.1.1
> Now I want to send all traffic from this host to destination-tcp-port 80 to
> gateway 192.168.2.1 instead (the host has a second interface with the
> address 192.168.2.100/24 as well).
> I only want the traffic to port 80 to go thru this GW (and then to its final
> destination).
> And port 80 is just an example, it could be port 12345 as well.
> 
> Is this possible? If yes, any suggestion on how to do it?
> 
> Regards,

Hi,

Why do you don’t put another server on the desired network?

-- 
alarig


signature.asc
Description: PGP signature