Without using raw sockets, is there a way on Linux to force a network packet to be physically sent to a gateway first, even if the destination address is one bound to a local interface?
My system has a single active interface, eno1
, which is assigned an IPv4 of 192.168.1.1
with a /20
mask. The gateway has address 192.168.0.1
. I have tried adding a route using ip route add 192.168.1.0/24 via 192.168.0.1
, which has the highest routing specificity for 192.168.1.1
. But calling traceroute 192.168.1.1
still just shows a single hop, indicating it didn't go anywhere. I would expect it to show a first hop of 192.168.0.1
, followed by 192.168.1.1
. Additional evidence for the route not being followed is that sending packets with SO_TIMESTAMPING
results in missing hardware timestamps, indicating the packet wasn't actually put onto the wire.
In case this is an XY problem, I'm trying to build a ping-like measurement tool that measures round-trip latency and packet loss to my ISP's CMTS, but the router there uses rate-limiting on ICMP responses, so I can't measure the latency as frequently as I'd like. Additionally, pings from local devices on my network count against the rate limit, leading to spurious dropped packets (though I suppose I could block forwarding packets with the CMTS as the destination or those with TTL=1). Note that while I'm testing this locally on a system on my private network using my own router as the first hop, in reality I'll be running this on the router itself, replacing the .1.1
address with my public IPv4 address, and the .0.1
address with the upstream router address of the CMTS.
My thought was to send out a packet to the upstream router with a destination of my own public IP, which would hopefully result in it being sent right back to my own router, having traversed each leg once, but appearing to the ISP as generic forwarded traffic rather than something the CMTS responds to directly.
Ideally the solution can be configured once as super-user, then used by userspace jobs, i.e. not require running the tool as super-user (hence the desire to avoid raw-sockets).