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 <waltd...@waltdnes.org> I don't run "desktop environments"; I run useful applications