Community discussions

MikroTik App
 
galkoav
just joined
Topic Author
Posts: 1
Joined: Fri Oct 08, 2021 10:17 am

Bug with routing, if use same ip

Fri Oct 08, 2021 10:35 am

For mikrotik hEx, a configuration has been created that allows one control device to interact with 4 devices with the same IP (see diagram).
When testing this configuration, an error was found in packet processing. When sending a packet with the same parameters (the same src ip, src port, dst ip, dst port), marking packets by the interface name does not work correctly, so srcnat does not work correctly.

We have created rules to mark from which interface the packet was received, and substitute the corresponding src ip for it. This rule works correctly as long as different src ports are used, but if the same is used (while the other parameters of the src ip, src port, dst ip packet are also the same), the srcnat rules begin to behave as if all packets are marked with the same mark.

You can use the netcat program to reproduce the error. First, you need to assemble a test bench: one computer needs to be plugged into the eth5 port and set the ip address (192.168.2.1), the next one must be plugged into the eth1 port and set the ip address (192.168.11.1), the next one must be plugged into the eth2 port and set the ip address (192.168.11.1).
On a computer connected to eth5, start listening

nc -kluvw 0 192.168.2.1 52101 | hexdump

On a computer connected to eth1, start sending data

echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | nc -uw 0 -p49101 192.168.11.1 52101

On a computer connected to eth2, start sending data

echo zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz | nc -uw 0 -p 49101 192.168.11.1 52101

When sending packets from both computers at the same time, you can see that srcnat spoofs ip incorrectly - packets from different computers have the same src ip.

Для mikrotik hEx создана кофигурация, позволяющая одному управляющему устройству взаимодействовать с 4 устройствами с одинаковыми IP(изображена на схеме). При тестированнии такой кофигурации обнаружилась ошибка в обработке пакетов.
При отправке пакета с одинаковыми параметрами(одинаковый src ip, src port, dst ip, dst port ) маркировка пакетов по по имени интерфейса неправильно работает, соответственно не правильно работает srcnat.

У нас созданны правила помечать с какого интерфейса получен пакет, и подставлять ему соответствующий src ip. Это правило корректно работает пока используются разные src port, но если используется одинаковый(при это остальные параметры пакета src ip, src port, dst ip тоже совпадают) правила srcnat начинают вести себя так как будто все пакеты маркированы одинаковой отметкой.

Для воспроизведения ошибки можно использовать программу netcat. Для начала нужно собрать тестовый стенд: один компьютер нужно включить в порт eth5 и установить ip адресс(192.168.2.1), следующий нужно включить в порт eth1 и установить ip адресс(192.168.11.1), следующий нужно включить в порт eth2 и установить ip адресс(192.168.11.1).


На компьютере подлкюченном к eth5 запускаем прослушивание

nc -kluvw 0 192.168.2.1 52101 | hexdump

На компьютере подлкюченном к eth1 запускаем отправку даных

echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| nc -uw 0 -p49101 192.168.11.1 52101

На компьютере подлкюченном к eth2 запускаем отправку даных

echo zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz| nc -uw 0 -p 49101 192.168.11.1 52101

При одновременной отправке пакетов с обоих компьютеров, види что srcnat подменяет ip неправильно - у пакетов с разных компьютеров одинаковый src ip.
screen.png
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: No registered users and 14 guests