ecki / net-tools Goto Github PK
View Code? Open in Web Editor NEWLinux base networking tools
License: GNU General Public License v2.0
Linux base networking tools
License: GNU General Public License v2.0
README Information about the net-tools package NET-TOOLS A collection of programs that form the base set of the NET-3 networking distribution for the Linux operating system. This package includes the important tools for controlling the network subsystem of the Linux kernel. This includes arp, hostname, ifconfig, netstat, rarp and route. Additionally, this package contains utilities relating to particular network hardware types (plipconfig, slattach, mii-tool) and advanced aspects of IP configuration (iptunnel, ipmaddr). Please include the output of "program --version" when reporting bugs. Contents: README This file. INSTALLING Installation instructions. COPYING Your free copy of the GNU General Public License. TODO Some things that need to be done. The Homepage (including Git repository, release downloads, bug tracker and mailing list) is hosted by SourceForge.net. Please consider joining the project if you want to contribute: https://sourceforge.net/projects/net-tools/ Notes ----- This is net-tools 3.14. These have largely been tested against Linux kernels 2.6+. They might work against older ones if anyone actually still cares about those anymore. They have largely been tested against recent glibc versions, but should work on any POSIX compliant C library. If you notice portability issues, please flie a bug for us (or even send a patch!). The NLS support by Arnaldo Carvalho de Melo <[email protected]> uses GNU gettext. Translations to Brazilian Portuguese (pt_BR), German (de), Estonian (ee), Czech (cz), and French (fr) are available. Others are welcome! route/netstat -r do not yet support different address families cleanly. IPX/DDP/AX25 people, please feel free to add the code. Mike Frysinger [email protected] Phil Blundell [email protected] Bernd Eckenfels [email protected]
I ran example/lib/scan/mdns_scan.dart and got the following error:
C:/a_dev/flutter-sdk/bin/cache/dart-sdk/bin/dart.exe --enable-asserts C:\Users\xmlspyspring\IdeaProjects\network_tools\example\lib\scan\mdns_scan.dart
Unhandled exception:
SocketException: Failed to create datagram socket (OS Error: 在其上下文中,该请求的地址无效。---> In its context, the requested address is invalid
, errno = 10049), address = , port = 5353
#0 _NativeSocket.bindDatagram (dart:io-patch/socket_patch.dart:1051:7)
<asynchronous suspension>
#1 _RawDatagramSocket.bind.<anonymous closure> (dart:io-patch/socket_patch.dart:2558:15)
<asynchronous suspension>
#2 MDnsClient.start (package:multicast_dns/multicast_dns.dart:135:40)
<asynchronous suspension>
#3 MdnsScannerServiceImpl.findingMdnsWithAddress (package:network_tools/src/services/impls/mdns_scanner_service_impl.dart:73:5)
<asynchronous suspension>
Process finished with exit code 255
My Environment: windows 10 chinese
PS C:\Users\xmlspyspring\IdeaProjects\network_tools> dart --version
Dart SDK version: 3.3.1 (stable) (Wed Mar 6 13:09:19 2024 +0000) on "windows_x64"
Debian: https://salsa.debian.org/debian/net-tools/-/tree/debian/sid/debian/patches
( git clone https://salsa.debian.org/debian/net-tools.git net-tools-debian )
@NightTsarina @utkarsh2102
SuSE: https://build.opensuse.org/package/show/openSUSE%3AFactory/net-tools
@lnussel @dirkmueller
PLD: https://git.pld-linux.org/?p=packages/net-tools.git;a=tree
( git clone git://git.pld-linux.org/packages/net-tools.git net-tools-pld )
@arekm
Fedora: https://src.fedoraproject.org/rpms/net-tools/tree/rawhide
( git clone https://src.fedoraproject.org/rpms/net-tools.git net-tools-fedora )
@mruprich
Compare the kernel output:
root@aarch64-1:~# cat /sys/module/igb/drivers/pci\:igb/0002\:01\:00.0/resource
0x0000001030000000 0x00000010300fffff 0x0000000000040200
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000001030200000 0x0000001030203fff 0x0000000000040200
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000001030100000 0x00000010301fffff 0x0000000000046200
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
to our current net-tools
package:
root@aarch64-1:~# setarch linux32 chroot x ifconfig enP2p1s0
enP2p1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 140.211.9.227 netmask 255.255.255.0 broadcast 140.211.9.255
inet6 2605:bc80:3010:104::8cd3:9e3 prefixlen 64 scopeid 0x0<global>
inet6 fe80::21b:21ff:fedc:4eb3 prefixlen 64 scopeid 0x20<link>
ether 00:1b:21:dc:4e:b3 txqueuelen 1000 (Ethernet)
RX packets 12089330 bytes 7057828892 (6.5 GiB)
RX errors 0 dropped 534 overruns 532 frame 0
TX packets 958695 bytes 84581028 (80.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0x30000000-300fffff
to the Toybox output:
root@aarch64-1:~# ./toybox-aarch64 ifconfig enP2p1s0
enP2p1s0 Link encap:Ethernet HWaddr 00:1b:21:dc:4e:b3 Driver igb
inet addr:140.211.9.227 Bcast:140.211.9.255 Mask:255.255.255.0
inet6 addr: 2605:bc80:3010:104::8cd3:9e3/64 Scope: Global
inet6 addr: fe80::21b:21ff:fedc:4eb3/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12089535 errors:0 dropped:534 overruns:532 frame:0
TX packets:958733 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7057846040 TX bytes:84587448
Memory:1030000000-10300fffff
It seems the net-tools
version prints only 8 characters, or 32 bits.
See also:
I am building an alpine based docker image, in which I have installed "net-tools" using apk add --no-cache --update net-tools
But when I run the docker image the output in the console is netstat: command not found
Oddly enough when I install anything (any apk i.e. nano, htop etc.) the "netstat" begins to produce output.
For example, After deploying the container, if I run: apk add --no-cache --update htop
The netstat
starts working. Until this, the output was netstat: command not found
I have found the REASON for this issue is, the "netstat" is not present /bin
directory until another program is installed!
As soon as another program gets installed, the "netstat" somehow appears in the /bin
directory!
This is very strange!
Why wouldn't "netstat" be present in the /bin
directory until another program is installed?
I am using alpine:latest
as base image.
Can anyone look into this? Many thanks in advance.
In ifconfig:
We can use parameters to print values instead of printing usage msg.
eg:
-> ifconfig enp4s0 mtu
prints usage msg.
Change to:
-> ifconfig enp4s0 mtu
1500.
>./netstat -g46
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 burning-barricade:32900 ec2-3-68-18-70.eu:https ESTABLISHED
tcp 0 0 burning-barricade:60010 ec2-3-67-131-16.e:https ESTABLISHED
tcp 25 0 burning-barricade:34626 server-18-66-248-:https CLOSE_WAIT
tcp 0 0 burning-barricade:51954 93.243.107.34.bc.:https ESTABLISHED
tcp 25 0 burning-barricade:34634 server-18-66-248-:https CLOSE_WAIT
tcp 0 0 burning-barricade:38354 40.99.204.114:imaps ESTABLISHED
tcp 0 0 burning-barricade:32912 ec2-3-68-18-70.eu:https ESTABLISHED
tcp 0 0 burning-barricade:53502 ec2-52-3-167-79.c:https ESTABLISHED
tcp 0 0 burning-barricade:32898 ec2-3-68-18-70.eu:https ESTABLISHED
tcp 0 0 burning-barricade:55342 46.101.105.92:https ESTABLISHED
tcp 0 0 burning-barricade:43164 lb-140-82-112-25-:https ESTABLISHED
tcp 0 0 burning-barricade:41790 cdn-185-199-110-1:https ESTABLISHED
tcp 0 0 burning-barricade:32920 ec2-3-68-18-70.eu:https ESTABLISHED
tcp 0 0 burning-barricade:58844 wa-in-f109.1e100.:imaps ESTABLISHED
udp 0 0 burning-barricad:bootpc _gateway:bootps ESTABLISHED
IPv6/IPv4 Group Memberships
Interface RefCnt Group
--------------- ------ ---------------------
lo 1 239.255.255.250
lo 1 mdns.mcast.net
lo 1 all-systems.mcast.net
enp2s0f0 1 all-systems.mcast.net
enp5s0 1 all-systems.mcast.net
enp7s0f3u1u4c2 1 all-systems.mcast.net
wlp3s0 1 239.255.255.250
wlp3s0 1 224.0.0.252
wlp3s0 1 mdns.mcast.net
wlp3s0 1 all-systems.mcast.net
virbr0 1 239.255.255.250
virbr0 1 mdns.mcast.net
virbr0 1 all-systems.mcast.net
virbr0 1 224.0.0.106
docker0 1 239.255.255.250
docker0 1 224.0.0.252
docker0 1 mdns.mcast.net
docker0 1 all-systems.mcast.net
docker0 1 224.0.0.106
veth80b67b4 1 all-systems.mcast.net
lo 1 ff02::fb
lo 1 ff02::1
lo 1 ff01::1
enp2s0f0 1 ff02::1
enp2s0f0 1 ff01::1
enp5s0 1 ff02::1
enp5s0 1 ff01::1
Is that behaviour deliberate or a bug?
Enviroment:
# mii-tool -V
net-tools 2.10-alpha
David Hinds based on Donald Becker's mii-diag
0001:2c:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 128 bytes
Interrupt: pin D routed to IRQ 277
NUMA node: 0
Region 0: Memory at f0e1c60000 (32-bit, non-prefetchable) [size=128K]
Region 2: I/O ports at f600003060 [disabled] [size=32]
Region 3: Memory at f0e1c8c000 (32-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: igb
Module Size Used by
mii 9065 0
ntfs 272491 0
ipv6 494101 48
megaraid_sas 171353 0
Whether mii exists or not, the result is the same.
phenomenon
# mii-tool -v enP1p44s0f3
enP1p44s0f3: negotiated, link ok
product info: vendor 00:55:00, model 59 rev 1
basic mode: autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising: flow-control
link partner: 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
# mii-tool -F 100baseTx-HD enP1p44s0f3
SIOCSMIIREG on enP1p44s0f3 failed: Operation not supported
##############################################################
# ethtool enP1p44s0f3
Settings for enP1p44s0f3:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 1000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
# ethtool -s enP1p44s0f3 autoneg off speed 100 duplex half
# ethtool enP1p44s0f3
Settings for enP1p44s0f3:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: Symmetric
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 100Mb/s
Duplex: Half
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
MDI-X: off (auto)
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
my opinion
man page
DIAGNOSTICS
SIOCGMIIPHY on 'eth?' failed: Operation not supported
The interface in question does not support MII queries. Most likely, it does not have MII transceivers, at all.
I ran the following code and got the following error:
code:
import 'package:network_tools/network_tools.dart';
import '../example_utils.dart';
Future<void> main() async {
enableExampleLogging();
await configureNetworkTools('build');
String subnet = '192.168.1'; //Default network id for home networks
final interface = await NetInterface.localInterface();
// final netId = interface?.networkId;
// if (netId != null) {
// subnet = netId;
// examplesLogger.fine('subnet id $subnet');
// }
// [New] Scan for a single open port in a subnet
// You can set [firstHostId] and scan will start from this host in the network.
// Similarly set [lastHostId] and scan will end at this host in the network.
final stream2 = HostScannerService.instance.scanDevicesForSinglePort(
subnet,
53,
progressCallback: (progress) {
examplesLogger.finer('Progress for port discovery on host : $progress');
},
);
stream2.listen(
(ActiveHost activeHost) {
examplesLogger
.fine('[scanDevicesForSinglePort]: Found device : $activeHost');
final OpenPort deviceWithOpenPort = activeHost.openPorts[0];
if (deviceWithOpenPort.isOpen) {
examplesLogger.fine(
'[scanDevicesForSinglePort]: Found open port: ${deviceWithOpenPort.port} on ${activeHost.address}',
);
}
},
onDone: () {
examplesLogger.fine('Port Scan completed');
},
); // Don't forget to cancel the stream when not in use.
// String target = '192.168.1.1';
// final addr = interface?.ipAddress;
// if (addr != null) {
// target = addr;
// examplesLogger.fine("Target is $target");
// }
// PortScannerService.instance.scanPortsForSingleDevice(
// target,
// // Scan will start from this port.
// // startPort: 1,
// endPort: 9400,
// progressCallback: (progress) {
// examplesLogger.finer('Progress for port discovery : $progress');
// },
// ).listen(
// (activeHost) {
// final OpenPort deviceWithOpenPort = activeHost.openPorts[0];
//
// if (deviceWithOpenPort.isOpen) {
// examplesLogger.fine(
// 'Found open port: ${deviceWithOpenPort.port} on device $target',
// );
// }
// },
// onDone: () {
// examplesLogger.fine('Port Scan from 1 to 9400 completed');
// },
// );
}
Error:
C:/a_dev/flutter-sdk/bin/cache/dart-sdk/bin/dart.exe --enable-asserts C:\Users\xmlspyspring\IdeaProjects\network_tools\example\lib\scan\port_scan.dart
2024-03-25 18:36:59.261617: FINE: network_tools_examples: [scanDevicesForSinglePort]: Found device : Address: 192.168.1.1, HostId: 1, Time: nullms, port: 53
2024-03-25 18:36:59.264387: FINE: network_tools_examples: [scanDevicesForSinglePort]: Found open port: 53 on 192.168.1.1
Unhandled exception:
FormatException: Missing extension byte (at offset 3)
#0 _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1845:7)
#1 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:304:28)
#2 _Utf8ConversionSink.add (dart:convert/string_conversion.dart:300:5)
#3 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:69:18)
#4 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#9 _StreamController._add (dart:async/stream_controller.dart:658:7)
#10 _StreamController.add (dart:async/stream_controller.dart:606:5)
#11 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#12 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#13 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#14 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#15 _StreamController._add (dart:async/stream_controller.dart:658:7)
#16 _StreamController.add (dart:async/stream_controller.dart:606:5)
#17 _Socket._onData (dart:io-patch/socket_patch.dart:2447:41)
#18 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#19 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#20 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#21 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#22 _StreamController._add (dart:async/stream_controller.dart:658:7)
#23 _StreamController.add (dart:async/stream_controller.dart:606:5)
#24 new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1936:33)
#25 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1379:14)
#26 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#27 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#28 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#29 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
Process finished with exit code 255
At first I thought it was a codepage problem, but I still reported this error after changing the code below:
In file lib/src/services/impls/host_scanner_service_impl.dart Line 110
change
Ping(host, count: 1, timeout: timeoutInSeconds)
to
Ping(host, count: 1, timeout: timeoutInSeconds,forceCodepage: true)
When running a docker in privileged and host network mode, netstat is not able to populate the PIDs/Process Names of the host.
Example:
prash@prash-laptop:~/ $ docker run --privileged=true --net=host -ti alpine sh
/ # apk add net-tools
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/2) Installing mii-tool (1.60_git20140218-r2)
(2/2) Installing net-tools (1.60_git20140218-r2)
Executing busybox-1.28.4-r1.trigger
OK: 5 MiB in 15 packages
/ # netstat -apnt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.1.1:53 0.0.0.0: LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 192.168.1.88:53454 216.58.197.37:443 ESTABLISHED -
tcp 0 0 192.168.1.88:44128 74.125.200.188:5228 ESTABLISHED -**
Since docker has the option to run in network host mode , the flows of the host are visible. Although the process names and PIDs are not getting populated.This is because /proc of the docker does not match the host. Hence netstat is not able to get process information.
Now a days a lot of linux tools try to be container(lxc/docker) compliant . A common approach for many tools is to mount the procfs of the host inside the docker like /hostfs/proc and then pass this PATH to the linux tool as an argument/env variable etc (Ref : https://github.com/influxdata/telegraf/blob/master/docs/FAQ.md)
It would be great if netstat too supports this feature so that any monitoring application which runs inside a container can be used to monitor host traffic/processes etc.
I ran the following code and got the following error:
code:
import 'package:network_tools/network_tools.dart';
import '../example_utils.dart';
Future<void> main() async {
enableExampleLogging();
await configureNetworkTools('build');
const String subnet = '192.168.1'; //Default network id for home networks
// final interface = await NetInterface.localInterface();
// final netId = interface?.networkId;
// if (netId != null) {
// subnet = netId;
// }
// or You can also get address using network_info_plus package
// final String? address = await (NetworkInfo().getWifiIP());
examplesLogger.fine("Starting scan on subnet $subnet");
// You can set [firstHostId] and scan will start from this host in the network.
// Similarly set [lastHostId] and scan will end at this host in the network.
final stream = HostScannerService.instance.getAllPingableDevicesAsync(
subnet,
// firstHostId: 1,
// lastHostId: 254,
progressCallback: (progress) {
examplesLogger.finer('Progress for host discovery : $progress');
},
);
stream.listen(
(host) async {
//Same host can be emitted multiple times
//Use Set<ActiveHost> instead of List<ActiveHost>
examplesLogger.fine('Found device: ${await host.toStringFull()}');
},
onDone: () {
examplesLogger.fine('Scan completed');
},
); // Don't forget to cancel the stream when not in use.
}
console output:
C:/a_dev/flutter-sdk/bin/cache/dart-sdk/bin/dart.exe --enable-asserts C:\Users\xmlspyspring\IdeaProjects\look_net_cli\bin\look_net_cli.dart
Positional arguments: []
2024-03-25 15:29:02.881110: FINE: network_tools: Downloading mac-vendors-export.csv from network_tools
Unhandled exception:
ClientException with SocketException: Failed host lookup: 'raw.githubusercontent.com' (OS Error: 请求的名称有效,但是找不到请求的类型的数据。
, errno = 11004), uri=https://raw.githubusercontent.com/osociety/network_tools/main/lib/assets/mac-vendors-export.csv
#0 IOClient.send (package:http/src/io_client.dart:154:7)
<asynchronous suspension>
#1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:32)
<asynchronous suspension>
#2 _withClient (package:http/http.dart:167:12)
<asynchronous suspension>
#3 VendorTable._fetchVendorTable (package:network_tools/src/device_info/vendor_table.dart:42:24)
<asynchronous suspension>
#4 VendorTable.createVendorTableMap (package:network_tools/src/device_info/vendor_table.dart:31:25)
<asynchronous suspension>
#5 configureNetworkTools (package:network_tools/src/configure_dart_native.dart:37:3)
<asynchronous suspension>
#6 main (file:///C:/Users/xmlspyspring/IdeaProjects/look_net_cli/bin/look_net_cli.dart:87:3)
<asynchronous suspension>
Process finished with exit code 255
My Environment: windows 10 chinese
PS C:\Users\xmlspyspring\IdeaProjects\network_tools> dart --version
Dart SDK version: 3.3.1 (stable) (Wed Mar 6 13:09:19 2024 +0000) on "windows_x64"
I have solved this problem:
In file lib/src/services/impls/host_scanner_service_impl.dart Line 110
change
Ping(host, count: 1, timeout: timeoutInSeconds)
to
Ping(host, count: 1, timeout: timeoutInSeconds,forceCodepage: true
then run and get:
C:/a_dev/flutter-sdk/bin/cache/dart-sdk/bin/dart.exe --enable-asserts C:\Users\xmlspyspring\IdeaProjects\network_tools\example\lib\scan\host_scan.dart
2024-03-25 18:22:47.681016: FINE: network_tools_examples: Starting scan on subnet 192.168.1
2024-03-25 18:22:54.382557: FINE: network_tools_examples: Found device: Address: 192.168.1.1, MAC: null, HostId: 1, Vendor: null Time: 1ms, DeviceName: Generic Device, HostName: null, MdnsInfo: null
2024-03-25 18:22:58.921379: FINE: network_tools_examples: Found device: Address: 192.168.1.2, MAC: null, HostId: 2, Vendor: null Time: 46ms, DeviceName: Generic Device, HostName: null, MdnsInfo: null
2024-03-25 18:23:03.459363: FINE: network_tools_examples: Found device: Address: 192.168.1.4, MAC: null, HostId: 4, Vendor: null Time: 229ms, DeviceName: Generic Device, HostName: null, MdnsInfo: null
2024-03-25 18:23:03.469368: FINE: network_tools_examples: Found device: Address: 192.168.1.5, MAC: null, HostId: 5, Vendor: null Time: 1ms, DeviceName: host.docker.internal, HostName: host.docker.internal, MdnsInfo: null
2024-03-25 18:23:19.845421: FINE: network_tools_examples: Scan completed
Too little information obtained, many are null. I want to get more information, especially the mac address.
From the man page, it says that:
Recv-Q
: Established: The count of bytes not copied by the user program connected to this socket. Listening: Since Kernel 2.6.18 this column contains the current syn backlog.
But according to the source code of current version of Linux kernel, when the state of socket is TCP_LISTEN, the value of rx_queue
equals to sk_ack_backlog
, which represents the length of accept queue instead of the length of syn backlog. So I think the explanation of Recv-Q
from man page is wrong.
Hi everyone,
I wanted to point out something on netstat -i
output:
$ netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
lo 65536 2 0 0 0 2 0 0 0 LRU
When I'm debugging network issues I want to have all information about a network card.
I mean all relevant timers to see if something wrong is going on.
I don't see any RX-FRAME or TX-FRAME field, I need to add -e
option.
Can I make a PR to have an output like this:
$ netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-FRAME RX-OVR TX-OK TX-ERR TX-DRP TX-FRAME TX-OVR Flg
lo 65536 2 0 0 0 0 2 0 0 0 0 LRU
Thanks for your kind advice about it.
Regards,
[tkloczko@devel-g2v net-tools-2.10]$ grep SEL config.status
bool 'SELinux support' HAVE_SELINUX y
and linking fails on
/usr/bin/gcc -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Wall -fno-strict-aliasing -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I. -I/home/tkloczko/rpmbuild/BUILD/net-tools-2.10/include -Ilib -c statistics.c
/usr/bin/gcc -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Wall -fno-strict-aliasing -Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,--build-id=sha1 -Llib -o netstat netstat.o statistics.o -lnet-tools
lib/netrom.c: In function 'NETROM_sprint':
lib/netrom.c:82:1: warning: function may return address of local variable [-Wreturn-local-addr]
82 | }
| ^
lib/netrom.c:78:10: note: declared here
78 | char buf[64];
| ^
/usr/bin/ld: /tmp/cci1FStg.lto.o: in function `prg_cache_load':
/home/tkloczko/rpmbuild/BUILD/net-tools-2.10/netstat.c:476: undefined reference to `getpidcon'
/usr/bin/ld: /home/tkloczko/rpmbuild/BUILD/net-tools-2.10/netstat.c:480: undefined reference to `freecon'
/usr/bin/ld: /home/tkloczko/rpmbuild/BUILD/net-tools-2.10/netstat.c:480: undefined reference to `freecon'
/usr/bin/ld: /home/tkloczko/rpmbuild/BUILD/net-tools-2.10/netstat.c:480: undefined reference to `freecon'
/usr/bin/ld: /tmp/cci1FStg.lto.o: in function `main':
/home/tkloczko/rpmbuild/BUILD/net-tools-2.10/netstat.c:2189: undefined reference to `is_selinux_enabled'
In the following special scenarios, the ip command denies the following second route addition, but route does not。
Example:
$ip -6 route add 2409:8080:5a0a:60c7::7/128 via 2409:8080:5a0a:60c7::7 dev eth2
$ip -6 route add 2409:8080:5a0a:60c7::8/128 via 2409:8080:5a0a:60c7::7 dev eth2
RTNETLINK answers: No route to host
$ route -A inet6 add 2409:8080:5a0a:60c7::8/128 gw 2409:8080:5a0a:60c7::7 dev eth2
$
$ route -6n
Kernel IPv6 routing table
Destination Next Hop Flag Met Ref Use If
2409:8080:5a0a:60c7::7/128 2409:8080:5a0a:60c7::7 UG 1024 2 0 eth2
2409:8080:5a0a:60c7::8/128 2409:8080:5a0a:60c7::7 UGH 1 1 0 eth2
2409:8080:5a0a:60c7::/120 :: U 102 1 0 eth2
Can route command be the same with ip command?
Passing option "--tcpip" is interpreted as "--tcp" with numeric argument "ip".
This leads to the confusing error message
netstat.c: Internal Error longopts 1 range.
This seems to come from the case 1
of options processing though I don't understand why getopts_long would return 1.
Why would I pass "--tcpip"?
While the --help
output says
={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw}
{-x|--unix} --ax25 --ipx --netrom
The man page of net-tools says:
address_family_options: [-4|--inet] [-6|--inet6] [--protocol={inet,inet6,unix,ipx,ax25,netrom,ddp,bluetooth, ... } ] [--unix|-x] [--inet|--ip|--tcpip] [--ax25] [--x25] [--rose] [--ash] [--bluetooth] [--ipx] [--netrom] [--ddp|--appletalk] [--econet|--ec]
But the above line seems to be out-of-date! Again, --help
lists only the following:
=Use '-6|-4' or '-A ' or '--'; default: inet
List of possible address families (which support routing):
inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)
netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)
x25 (CCITT X.25)
And the use of --protocol
is also gone.
It looks like the man page needs cleanup.
Gentoo (and other musl distributions) are carrying a patch to fix headers in order to build with musl libc, eg. https://gitweb.gentoo.org/proj/musl.git/tree/sys-apps/net-tools/files/net-tools-fix-headers-r1.patch .
So given the command netstat -r6C
executes the function rprint_cache6 which tries to open the file
/proc/net/ndisc
. This file does not exist on my machine, nor on machines of some friends. Under which circumstances does this file exist? I can't find any information about it in the linux kernel, so I wonder about this code path.
Can someone provide some information about that? Is that legacy compatibility? Code does not provide enough information or documentation to understand.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.