Page 1 of 1

PCC specification

Posted: Mon Oct 31, 2011 7:54 am
by salytwo
Hello all,
In some circumstances I found my self need to route files downloads to specific gateway whereas browsing the internet to both gateways how I can alter the following PCC code:

/ip address
add address=192.168.1.21/24 broadcast=192.168.1.255 comment="" disabled=no interface=wlan1 network=192.168.1.0
add address=192.168.2.21/24 broadcast=192.168.2.255 comment="" disabled=no interface=wlan2 network=192.168.2.0
add address=10.10.10.2/24 broadcast=10.10.10.255 comment="" disabled=no interface=lan network=10.10.10.0
/ip firewall mangle
add action=mark-connection chain=input comment="" disabled=no in-interface=wlan1 new-connection-mark=wlan1_conn passthrough=yes    
add action=mark-connection chain=input comment="" disabled=no in-interface=wlan2 new-connection-mark=wlan2_conn passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=wlan1_conn disabled=no new-routing-mark=wlan1 passthrough=yes    
add action=mark-routing chain=output comment="" connection-mark=wlan2_conn disabled=no new-routing-mark=wlan2 passthrough=yes
add action=mark-connection chain=prerouting comment="" disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wlan1_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0  
add action=mark-connection chain=prerouting comment="" disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wlan2_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1
add action=mark-routing chain=prerouting comment="" connection-mark=wlan1_conn disabled=no in-interface=lan new-routing-mark=wlan1 passthrough=yes    
add action=mark-routing chain=prerouting comment="" connection-mark=wlan2_conn disabled=no in-interface=lan new-routing-mark=wlan2 passthrough=yes
/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=wlan1 scope=30 target-scope=10    
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=wlan2 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.1.1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=2 dst-address=0.0.0.0/0 gateway=192.168.2.1 scope=30 target-scope=10
/ip firewall nat
add action=masquerade chain=srcnat comment="" disabled=no out-interface=wlan1
add action=masquerade chain=srcnat comment="" disabled=no out-interface=wlan2
/ip dns set allow-remote-requests=no cache-max-ttl=1w cache-size=2048KiB max-udp-packet-size=512 primary-dns=208.67.222.222 secondary-dns=208.67.220.220
Does this scenario of routing files downloads to one gateway while route browsing the internet to both gateways correct or it is impossible?

thanks a lot

Re: PCC specification

Posted: Mon Oct 31, 2011 2:37 pm
by salytwo
Where are the professionals?

Re: PCC specification

Posted: Mon Oct 31, 2011 3:26 pm
by Feklar
You can't do that. A router has no way of knowing what is being requested when someone does a download via HTTP, it is exactly the same thing as far as a router is concerned, files being requested and downloaded via HTTP. By the time the router could even possibly know what is being requested, NAT has already happened, it cannot change what link it sends traffic over. It would break the connection and make it invalid.

Run a search on the forum, this question comes up fairly regularly and the answer is always the same, not possible.

Re: PCC specification

Posted: Mon Oct 31, 2011 4:50 pm
by salytwo
I feel it will be possible if we use mangle to mark every extension and then using NAT to route it to specific gateway

Re: PCC specification

Posted: Mon Oct 31, 2011 5:28 pm
by Feklar
Nope, that is not the way TCP/IP works. The first 3 packets are handshakes, and NAT has already happened after the first packet, every packet after that must follow that packet out of the same link and IP, otherwise it is an invalid connection. The absolute earliest that that kind of information could be available is the 4th packet, and by then it is far too late.