Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option -a/--address does not work. #250

Open
bd46 opened this issue Mar 31, 2018 · 27 comments
Open

Option -a/--address does not work. #250

bd46 opened this issue Mar 31, 2018 · 27 comments

Comments

@bd46
Copy link

bd46 commented Mar 31, 2018

Option "-a|--address" does not work in package "mtr-tiny" (build without X11) on Debian Linux, version 0.92-1. Running under strace shows that program does NOT call bind(2).

Breif examination of source code from Github reveals that -a parameter value is assigned to ctl->InterfaceAddress, then is validated in net.c::net_validate_interface_address(), and never used later. Probably some piece of code was lost.

In previous mtr versions option "-a" worked as expected.

@bd46
Copy link
Author

bd46 commented Mar 31, 2018

After bug submission I found the same bug as #232, sorry for duplicaion. Testcase is quite simple: multihomed host (several interfaces with different addresses), mtr sent packets via default route regardless of -a option.

@rkandilarov
Copy link

rkandilarov commented Aug 2, 2018

Just to confirm that I also came in practice to the same bug -a source_IP not working with ICMP, it sends the packets with the proper source_IP but trough the default interface (gateway) not the one associated with the provided source IP. With --tcp it works as expected.
Ubuntu 18.04

mtr --version 
mtr 0.92

@rewolff
Copy link
Collaborator

rewolff commented Aug 3, 2018

Test case. Normal PC, ifconfig eth0:1 <a second IP addres>
Now ping -I <second ip adress> a host and see that the second IP address is being used.
Now mtr -a <second ip address> that host and see that the second IP address is being used.

The -I on "ping" hints at using an INTERFACE as the source, but I don't think that can be done with the networking-interface on Unix-like machines. the -a option on mtr explains better what it does: The source address is set. The kernel then often decides to use the interface that you meant to use, but if it doesn't... well mtr can't do much about that.

When mtr submits packet FROM your second interface IP address, TO "random IP on the internet", you still expect the routing tables to work and tell that packet where to go. As an example: If you ping-or-mtr a host not on your local network, you expect the kernel to look up how to reach that host and often then use the default route to try to reach that host, right?

@bd46
Copy link
Author

bd46 commented Aug 3, 2018 via email

@rkandilarov
Copy link

@rewolff , on the same machine ping -I source_IP provides the expected result - it works!
As I said in the previous post, the bug is when the source_IP is not on the interface of default gw for that scope. We have tested it even without any network namespaces and VRFs or ip rules...

@cerberek
Copy link

I have same issue with mtr package in version 0.92-2 on Debian buster.

@rewolff
Copy link
Collaborator

rewolff commented Jan 15, 2020

I have simple machines. If any of you can provide me a "howto reproduce" that I can run to reproduce this, then the chances that I can look into it improve dramatically.

@bd46
Copy link
Author

bd46 commented Jan 15, 2020 via email

@davidjmemmett
Copy link

Hi,

This issue is still present in latest release 0.93. Neither -I or -a change the source address of a packet.

Cheers,
David

@totoCZ
Copy link

totoCZ commented Sep 24, 2020

A raw socket can be bound to a specific local address using the bind(2) call. If it isn't bound, all packets with the specified IP protocol are received. In addition, a RAW socket can be bound to a specific network device using SO_BINDTODEVICE; see socket(7).

One way of fixing it. One small problem is, you need to find out the device name first.

@bd46
Copy link
Author

bd46 commented Sep 24, 2020 via email

@totoCZ
Copy link

totoCZ commented Sep 24, 2020

Please check commit totoCZ@19a1fba
I rewrote the v4 sockets to get rid of IPPROTO_RAW.

cc @rewolff i'll do a pull request if it's okay.

@rewolff
Copy link
Collaborator

rewolff commented Sep 25, 2020

The "HDR_INCL" define has completely vanished. Could it be that this is going to be a problem on some machines that you did not test?

@totoCZ
Copy link

totoCZ commented Sep 25, 2020 via email

@douniwan5788
Copy link

sigh…… still broken in 0.93

@tapionx
Copy link

tapionx commented Sep 17, 2022

any updates on this?

@bitroniq
Copy link

I was able to reproduce it using

# dpkg -l | grep mtr
ii  mtr-tiny                              0.93-1 

on Ubuntu 20.04

@bitroniq
Copy link

mtr-tiny 0.93-1 on Ubuntu 20.04 also doesn't work properly using

mtr -I <IFACE> 1.1.1.1
It ignores both -I and -a

@shakibamoshiri
Copy link

mtr 0.95 on Arch
does not work properly

@nickyang777
Copy link

nickyang777 commented Sep 9, 2023

The configuration of my environment is as follows:
[root@mtr ~]# mtr --version
mtr 0.95

[root@mtr ~]# ip rule show
0: from all lookup local
32765: from 99.99.23.6 lookup net_252
32766: from all lookup main
32767: from all lookup default

[root@mtr ~]# ip route show
default via 192.168.0.0 dev eth0 proto dhcp metric 100
99.99.23.0/24 dev eth1 proto kernel scope link src 99.99.23.6
192.168.0.0/16 dev eth0 proto kernel scope link src 192.168.. metric 100

[root@mtr ~]# ip route show table net_252
default dev eth1 scope link

[root@mtr ~]# mtr -r -n -a 99.99.23.6 1.1.1.1

Use tcpdump to capture packets. It is found that packets are not sent from eth1 but from eth0.
[root@mtr ~]# tcpdump -n -i eth0 icmp
dropped privs to tcpdump
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
11:21:34.060252 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33000, length 44
11:21:34.160450 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33001, length 44
11:21:34.260649 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33002, length 44
11:21:34.360844 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33003, length 44
11:21:34.461050 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33004, length 44
11:21:34.561246 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33005, length 44
11:21:34.661405 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33006, length 44
11:21:34.761648 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33007, length 44
11:21:34.861836 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33008, length 44
11:21:34.962096 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33009, length 44
11:21:35.062263 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33010, length 44
11:21:35.162424 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33011, length 44
11:21:35.262651 IP 99.99.23.6 > 1.1.1.1: ICMP echo request, id 7550, seq 33012, length 44

Do you have any plans to repair it?

@Amoled
Copy link

Amoled commented Nov 20, 2023

I have the same problem, it looks like no one is going to solve it ....

@matt-kimball
Copy link
Contributor

My impression was that 7a03200 fixed this issue. Instead of reporting issues about the mtr included with your distro of choice, perhaps some of the people submitting complaints to this thread could try the latest from master and comment on whether or not it is indeed fixed when building from that commit, or more recent.

@bd46
Copy link
Author

bd46 commented Nov 21, 2023 via email

@davidjmemmett
Copy link

That fix was committed on 5th August 2022, however the last release of mtr was v0.95 on 11th January 2022; therefore, the suggested fix has not made its way into any release as far as I can see.

@putnam
Copy link

putnam commented Jan 5, 2024

Why not cut a release? It's been 2 years since 0.95. (Same problem with 0.95 in current OPNsense)

@xqzr
Copy link

xqzr commented Feb 7, 2024

-a or -I and -M work

@robert-scheck
Copy link
Contributor

robert-scheck commented Mar 13, 2024

Based on my tests --address and --interface in MTR 0.95 do not work (anymore) when used with source/policy based routing, such as two internet upstreams ("two default gateways"). For me it starts working for both when switching from ICMP to TCP using --tcp.

Edit: MTR 0.95 with commit 74d312d (from #484) additionally applied works for me in the above scenario on Linux (without the workaround to switch from ICMP to TCP).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests