Community discussions

MikroTik App
 
mmbabji
just joined
Topic Author
Posts: 17
Joined: Tue May 10, 2022 2:05 pm

tracerout shows both the WANs GateWays in my routerOS(load balancer)

Wed Aug 30, 2023 10:14 am

hi
my routerOS(having laadbalancer PCC with two WANs) .
When I do the traceroute, I observe the request is passing through BOTH the IPS's Gateways every time!
for every connection request isn't it supposed to pass through only one ISP for each request !!
here is the output i observed.

USER-MG:~$ traceroute google.com
traceroute to google.com (142.250.196.46), 30 hops max, 60 byte packets
1 _gateway (192.168.1.1) 7.657 ms 7.623 ms 7.609 ms
2 gw (103.211.39.1) 7.603 ms 7.591 ms 7.578 ms
3 * broadband.actcorp.in (183.83.249.10) 21.240 ms *
4 broadband.actcorp.in (183.82.14.78) 21.224 ms 21.211 ms 103.10.134.157 (103.10.134.157) 7.503 ms
5 72.14.203.80 (72.14.203.80) 21.206 ms 21.195 ms 72.14.223.26 (72.14.223.26) 21.148 ms
6 * * *
7 maa03s45-in-f14.1e100.net (142.250.196.46) 17.342 ms 142.251.55.232 (142.251.55.232) 17.301 ms 142.251.49.218 (142.251.49.218) 19.971 ms
USER-MG:~$ traceroute google.com
traceroute to google.com (142.250.193.142), 30 hops max, 60 byte packets
1 _gateway (192.168.1.1) 7.713 ms 7.672 ms 7.657 ms
2 183.82.96.1.actcorp.in (183.82.96.1) 8.521 ms login.bharatfiber.net (103.211.39.1) 7.734 ms 183.82.96.1.actcorp.in (183.82.96.1) 8.498 ms
3 broadband.actcorp.in (183.83.249.10) 8.513 ms 8.500 ms 103.211.36.29 (103.211.36.29) 7.598 ms
4 103.10.134.157 (103.10.134.157) 7.573 ms broadband.actcorp.in (183.82.14.78) 21.077 ms 103.10.134.157 (103.10.134.157) 7.551 ms
5 72.14.223.26 (72.14.223.26) 21.056 ms 72.14.203.80 (72.14.203.80) 21.075 ms 21.064 ms
6 * * *
7 209.85.248.210 (209.85.248.210) 18.246 ms 142.251.55.68 (142.251.55.68) 18.234 ms 142.251.55.30 (142.251.55.30) 18.223 ms
8 108.170.253.122 (108.170.253.122) 18.207 ms 108.170.253.120 (108.170.253.120) 18.199 ms 21.909 ms
9 74.125.242.129 (74.125.242.129) 21.713 ms 21.699 ms maa05s25-in-f14.1e100.net (142.250.193.142) 21.685 ms
USER-MG:~$

can someone explain to me how the routing is served?
or is there any configuration change I need to make?
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19395
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: tracerout shows both the WANs GateWays in my routerOS(load balancer)

Thu Aug 31, 2023 12:07 am

More interested in seeing if the config is proper
/export file=anynameyouwish ( minus router serial number, any public WANIP information, or long dhcp lease lists etc..)
 
mmbabji
just joined
Topic Author
Posts: 17
Joined: Tue May 10, 2022 2:05 pm

Re: tracerout shows both the WANs GateWays in my routerOS(load balancer)

Thu Aug 31, 2023 9:36 am

hay Anav,
happy to hear from you again.
can you please share your email id, we can get in touch there.
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: tracerout shows both the WANs GateWays in my routerOS(load balancer)

Thu Aug 31, 2023 11:13 am

my routerOS(having laadbalancer PCC with two WANs) .
When I do the traceroute, I observe the request is passing through BOTH the IPS's Gateways every time!
To understand why this happens you have to understand how traceroute works and how PCC works. tcpdump/wireshark are of great help here:

tcpdump: listening on ens18, link-type EN10MB (Ethernet), snapshot length 262144 bytes
09:43:16.962520 IP (tos 0x0, ttl 1, id 6671, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.36798 > 8.8.4.4.33434: UDP, length 32
09:43:16.962592 IP (tos 0x0, ttl 1, id 40445, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.57691 > 8.8.4.4.33435: UDP, length 32
09:43:16.962647 IP (tos 0x0, ttl 1, id 17784, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.59973 > 8.8.4.4.33436: UDP, length 32

09:43:16.962775 IP (tos 0x0, ttl 2, id 55591, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.45197 > 8.8.4.4.33437: UDP, length 32
09:43:16.962833 IP (tos 0x0, ttl 2, id 19635, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.42987 > 8.8.4.4.33438: UDP, length 32
09:43:16.962888 IP (tos 0x0, ttl 2, id 28234, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.36226 > 8.8.4.4.33439: UDP, length 32

09:43:16.962944 IP (tos 0x0, ttl 3, id 3898, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.44173 > 8.8.4.4.33440: UDP, length 32
09:43:16.962998 IP (tos 0x0, ttl 3, id 54001, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.34568 > 8.8.4.4.33441: UDP, length 32
09:43:16.963120 IP (tos 0x0, ttl 3, id 6320, offset 0, flags [none], proto UDP (17), length 60)
192.168.5.60.54378 > 8.8.4.4.33442: UDP, length 32


As you can see, for each TTL value, the stock Linux traceroute with no special options (just traceroute 8.8.4.4) sends 3 UDP packets with distinct random source and destination ports. So unless your PCC is set to calculate the hash from IP addresses alone, i.e. not to include any of the ports into the calculation, the chance that the result of the hashing and division will be the same for all 3 probe packets is very low. Hence you get both the network paths. And I do admit the presentation could be improved, i.e. results from the same TTL should be numbered with the same TTL value in the output.

Mikrotik's own /tool traceroute works differently, and so does a Windows tracert - Mikrotik sends a single ping request per TTL unless told otherwise, and Windows can only send a single ping request per TTL and you cannot change that using command line parameters. So from a certain perspective, they both give you an incomplete information. The Mikrotik one can even mislead you completely, because if you ask it to use UDP, it uses a distinct source port number for each TTL value, but always the same one for a given TTL value for each pass. So you may see the first hop to be gateway 1 and the second hop to be the "gateway of gateway 2" because the PCC may send the packets with TTL 2 via gateway 2 - not due to the TTL value itself but due to the source port that the traceroute systematically uses for it.

Also, loosely related to the topic: taking ports into account in the PCC calculation may bite your back if your LAN clients access paranoid web sites (typically banking ones) - such sites often like to redirect the client's "application session" between multiple servers, but drop the application session if each of the TCP sessions arrives from another address. If you want to be safe from this point of view, you have to let the PCC calculate the hash only from the source address, so that connections from the same client device would always arrive to all the servers in the internet from the same public address.
 
mmbabji
just joined
Topic Author
Posts: 17
Joined: Tue May 10, 2022 2:05 pm

Re: tracerout shows both the WANs GateWays in my routerOS(load balancer)

Sun Sep 03, 2023 11:25 am

hi Sindy
thanks for explaining in detail.
in the final part you said. ""you have to let the PCC calculate the hash only from the source address, so that connections from the same client device would always arrive to all the servers in the internet from the same public address.""

how do i resolve it ?
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: tracerout shows both the WANs GateWays in my routerOS(load balancer)

Sun Sep 03, 2023 11:28 am

per-connection-classifier=src-address:d/r
 
User avatar
spippan
Member
Member
Posts: 334
Joined: Wed Nov 12, 2014 1:00 pm
Location: Austria

Re: tracerout shows both the WANs GateWays in my routerOS(load balancer)

Sun Sep 03, 2023 4:23 pm

...
Also, loosely related to the topic: taking ports into account in the PCC calculation may bite your back if your LAN clients access paranoid web sites (typically banking ones) - such sites often like to redirect the client's "application session" between multiple servers, but drop the application session if each of the TCP sessions arrives from another address. If you want to be safe from this point of view, you have to let the PCC calculate the hash only from the source address, so that connections from the same client device would always arrive to all the servers in the internet from the same public address.
thank you for reminding! golden.
had such a problem at a friend's setup and totally forgot about that fact 😅🙈
cheers
 
mmbabji
just joined
Topic Author
Posts: 17
Joined: Tue May 10, 2022 2:05 pm

Re: tracerout shows both the WANs GateWays in my routerOS(load balancer)

Mon Sep 04, 2023 4:37 am

/ip firewall mangle
add action=accept chain=prerouting dst-address-list=WAN_Subnet
add action=mark-routing chain=prerouting new-routing-mark=TO_WAN1 \
passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0 \
src-address-list=LAN_USERS src-address-type=!local
add action=mark-routing chain=prerouting new-routing-mark=TO_WAN2 \
passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1 \
src-address-list=LAN_USERS src-address-type=!local
/ip firewall nat
add action=masquerade chain=srcnat src-address-list=LAN_USERS
/ip route
add check-gateway=ping distance=1 gateway=XXX routing-mark=TO_WAN1
add check-gateway=ping distance=1 gateway=YYY routing-mark=TO_WAN2
add check-gateway=ping distance=1 gateway=XXX
add check-gateway=ping distance=2 gateway=YYY



Above is my config,
can you please check the above, let me know what are changes to apply, esp the last two lines ?

Who is online

Users browsing this forum: No registered users and 2 guests