Community discussions

MikroTik App
 
1littlewisp
newbie
Topic Author
Posts: 36
Joined: Wed Jun 10, 2009 6:23 pm

[SOLVED] Policy Based Routing test with ipchicken.com

Sun Oct 16, 2011 4:26 am

So I've got a location with two gateways. I want to route traffic to a certain destination through only one of the gateways. I'm testing this with ipchicken.com because it should be a good indication of whether I've got it working or not. Here's the setup that's not working:
/ip firewall mangle
add action=mark-routing chain=prerouting content=ipchicken.com disabled=no \
    dst-port=80 new-routing-mark=ipchx passthrough=yes protocol=tcp
/ip route rule
add action=lookup disabled=no routing-mark=ipchx src-address=10.0.0.0/24 \
    table=ipchx
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=10.0.24.1 \
    routing-mark=ipchx scope=30 target-scope=10
I thought that would make anything coming from the 10.0.0.0/24 network with the routing mark ipchx go through the 10.0.24.1 gateway. The mangle rule is getting hit but I've still got the ip of my primary gateway. help?
Last edited by 1littlewisp on Thu Oct 27, 2011 7:10 pm, edited 1 time in total.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Policy Based Routing test with ipchicken.com

Sun Oct 16, 2011 5:15 am

You can't do layer 7 filters for routing decisions that include NAT.

NAT happens on the first packet of a connection, and is set after that. You can't change your mind later and NAT to something else - even if the router would allow you to do that the other end of the connection would ignore anything coming from the changed IP address since it can't know those packets are part of the same connection.

'ipchicken.com' would only show up in the HTTP request (if a host header is used), which is the fourth packet of the connection, after the TCP three way handshake.

So in short: what you're trying to do is impossible. You can only make routing decisions based on properties the first packet of the connection has. If you really need to make routing decisions based on layer 7 information you will need to insert a transparent proxy like Squid to make such decisions. The built in proxy can't do this for you, either.
 
1littlewisp
newbie
Topic Author
Posts: 36
Joined: Wed Jun 10, 2009 6:23 pm

Re: Policy Based Routing test with ipchicken.com

Tue Oct 18, 2011 6:25 pm

Thanks, Fewi. I think you have helped me a few times in the past as well. I believe I may be able to trick the system into appearing to work by creating a destination address list. Mwahahaha!

It's not perfect, but it will help me build a QoS system that otherwise wouldn't have worked.

Who is online

Users browsing this forum: raiser and 95 guests