Nmap Development mailing list archives
[PATCH 1/2] nping: bind to interface on Linux for IPv4 send-ip
From: ValdikSS via dev <dev () nmap org>
Date: Fri, 21 Jun 2024 15:46:47 +0300
Linux RAW sockets need to be bound to interface, if the interface is
L3 tunnel (OpenVPN TUN for example).
Otherwise the packet goes via default route, regardless of
`--interface` or `--source-ip` options.
---
nping/ProbeMode.cc | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/nping/ProbeMode.cc b/nping/ProbeMode.cc
index 199329b40..382b330c4 100644
--- a/nping/ProbeMode.cc
+++ b/nping/ProbeMode.cc
@@ -807,6 +807,15 @@ int ProbeMode::fillPacketTCP(NpingTarget *target, u16 port, u8 *buff, int buffle
}else{
t.setSum();
}
+
+ /* Bind IPv4 socket to a specific network interface */
+ if ( o.issetDevice() ) {
+ if (socket_bindtodevice(rawfd, o.getDevice()))
+ {
+ nping_warning(QT_2, "Error binding IPv4 socket to device %s", o.getDevice() );
+ }
+ }
+
/* Store result in user supplied buffer */
*filledlen = i.dumpToBinaryBuffer(buff, bufflen);
--
2.45.2
_______________________________________________
Sent through the dev mailing list
https://nmap.org/mailman/listinfo/dev
Archived at https://seclists.org/nmap-dev/
Current thread:
- [PATCH 1/2] nping: bind to interface on Linux for IPv4 send-ip ValdikSS via dev (Jun 21)
- [PATCH 2/2] nping: use socket_bindtodevice nbase function for IPv6 interface binding ValdikSS via dev (Jun 21)
