This page contains information on Network Interface Card detection.
Overview
Computers are equipped with network interface cards (NICs), which have IPv4 and IPv6 addresses that Swarm detects automatically. However, there are times when they cannot be detected.
Detection Issues
Detection failure can be caused by a system error or a DHCP connection issue, in which the machine did not obtain the IP address from the DHCP server.
How to fix DHCP connection issue:
Maintenance – Check the Network, DHCP, and IP connectivity and make sure that everything is working properly.
Set a manual IP – Assign a manual IP address to the computer. This IP must be unique within the existing network (if it’s local, it should be unique within the local network).
If Swarm still does not locate any NICs, it displays the following message in the http://localhost:1113 Admin panel.
And in the Swarm log displays the following information:
[INFO - app] Running Swarm v2.0.15 7849af98
[WARN - app] Running in fallback mode [NO NICS]
. . . . . . .
In this case, set NICs manually via the swarm.yaml settings file. Currently, Swarm supports only IPv4.
manualNics:
- ip: 1.1.1.2
name: mynic
A full specification is supported as well (MAC + IPv4 + IPv6 + name). However, a brief specification (ip + name) is sufficient:
manualNics:
- mac: 11:12:13:14:15:16
ip4: 1.1.1.44
ip6: 2001:0000:130F:0000:0000:09C0:876A:130B
name: mynic
Detected and manually added NICs are reported in the log file as:
[INFO - app] Detected network interfaces:
Name : docker0
IPv4 : 172.17.0.1
IPv6 : 0:0:0:0:0:0:0:0
MAC : 02:42:b8:e9:48:de
Name* : my_fake_nic_name
IPv4 : 1.1.1.44
IPv6 : 2001:0:130f:0:0:9c0:876a:130b
MAC : 11:12:13:14:15:16
Name* : mynic
IPv4 : 1.1.1.2
Name : tun0
IPv4 : 10.1.0.253
IPv6 : fe80:0:0:0:c760:5177:eed0:9a6d
MAC : 00:00:00:00:00:00
Name : wlp0s20f3
IPv4 : 192.168.100.3
IPv6 : fe80:0:0:0:ca5a:fc1d:acb8:fe53
MAC : 74:13:ea:b8:ce:af
Manually-added NICs have * at the end of their names in the log file.
Technical Details
NICs are detected programmatically and by calling OS commands: ip, ifconfig
on Linux, ifconfig
on MacOS and ipconfig
on Windows. The results from the two methods are merged together and used as the set of determined/detected NICs and their IPs.
The result is logged in detail in the Swarm log.
Example:
[INFO - app] Detected network interfaces:
Name : wlp0s20f3
IPv4 : 192.168.100.3
IPv6 : fe80:0:0:0:ca5a:fc1d:acb8:fe53
MAC : 74:13:ea:b8:ce:af
Name : docker0
IPv4 : 172.17.0.1
IPv6 : 0:0:0:0:0:0:0:0
MAC : 02:42:fb:c1:5a:2b
Name : tun0
IPv4 : 10.1.1.149
IPv6 : fe80:0:0:0:13de:872d:f3ee:6d4a
MAC : 00:00:00:00:00:00
Name* : fake1
IPv4 : 1.1.1.3
Name* : mynic
IPv4 : 1.1.1.2
Name* : fake0
IPv4 : 1.1.1.44
IPv6 : 2001:0:130f:0:0:9c0:876a:130b
MAC : 11:12:13:14:15:16
[DEBUG - app] Library detected 6 NICs (wlp0s20f3; docker0; tun0; fake1; mynic; fake0).
Some were rejected:
*** REJECTED 1 NICs: lo rejected because of loopback
OS commands detected 3 NICs (docker0; tun0; wlp0s20f3).
*** "ifconfig" failed to detect NICs:
DecodeCOE "(stderr) /bin/sh: 1: ifconfig: not found"
"/usr/sbin/ifconfig" NICs detection seen-log:
Some NIC (0:"docker0: flags=4099<UP,BROADCA..."):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(NIC:"docker0",Flags:["UP","BROADCAST","MULTICAST"])
Some IPv4:
~~~~~~~~~
IP:"172.17.0.1"
. . . . . . . .
Reject Autodetected NICs
Some NICs can be rejected, so Swarm ignores them. Swarm does not bind to a specific NIC while it communicates via TCP. By default, Swarm rejects the so-called loopback interface/NIC. Additionally, you can add your own rejection rules in the swarm.yaml settings file using the setting:
rejectNics: [<SOME-CRITERIA>]
Supported criteria are (examples): loopback, nocarrier, p2p, noarp, vm, vpn, tunnel, nogateway, nomac, nomulticast, name:eth12, ipv4:10.0.0.99.
Use commas to separate the items in the list inside brackets. See this article for more information.
Some short notes: noarp
- ARP is not set up, vm
- NIC seems to belong to a virtual machine, nomac
- MAC address is not set up, etc. For instance, name:eth12
will reject NIC with such name, and ipv4:10.0.0.99
will reject NIC with such IP (one of).
Multiple IP Addresses by NIC
Some NICs have multiple IP addresses. Swarm recognizes only 1 IP by NIC, so it has an algorithm that chooses one IP only. By default, Swarm prefers IP marked as Preferred
on Windows. Swarm chooses IP with the largest preferred lifetime (when it is available) and Swarm prefers the first IP when no other available criteria are available.
You can interfere with this: there is a special setting that can be added in the swarm.yaml settings file: nicIpPrio.
It is a map of a list of priorities or sorting tactics (the key is the name of NIC), which are:
index
– Sorts by index in the output of OS commands report.preferred_lft
– Sorts by “preferred lifetime” of IP.unlikely <IPv4>
– Marks the low IP priority. In case of multiple IPs, it is not chosen. Multiple unlikely priorities are allowed. likely <IPv4>
– Marks this IP as a high priority for the specific NIC in case of multiple IPs.
The key of nicIpPrio
setting is a string name of the NIC or * if these priorities should be applied to all/any NIC. Two good empirical rules:
- Complex priority compositions are not recommended.
- Repeated priorities have no effect.
Troubleshooting
- Currently, the OS output command language is English. Local languages can be shown in Windows
ipconfig.
However, they are allowed only in the field values, so it will likely not break the parsing.
Workaround: Create a BAT file calling:
chcp 850
ipconfig /all
With a setting of the codepage using commands like chcp 437 or chcp 850 - see more here.
- Another possible issue is if OS commands used to determine NICs and their IPs cannot be found on the machine. If there are no errors, they were successfully detected programmatically. You can set the exact full path to OS commands in swarm.yaml settings file, as it follows:
Linux | Windows | MacOS |
ifconfigCmdPath ipCmdPath | ipconfigCmdPath | ifconfigCmdPath |
The value of these settings has the same type: it's a full path to the executable command used as ifconfig
(for Linux and MacOS), ipconfig
(for Windows) and ip
(for Linux).
These OS commands must have the expected command line syntax of the original well-known commands and expected output of them, even if they are replaced by something else: a system administrator can wrap them in a Shell script/BAT file, keeping their command line syntax and output as of the original commands. Example for Linux, just as an idea - pay attention that the output of such wrapper-script must be as the output of the original/wrapped command (to suppress output from additional commands):
#!/bin/sh
# some very important commands... 2>&1 >/dev/null
/secret/path/to/ip $*
# and other important commands... 2>&1 >/dev/null
- Another option is to modify the system/global PATH environment variable.
By default, Swarm tries to call them with this syntax:
Linux | Windows | MacOS |
ip -j a /usr/bin/ip -j a ifconfig -a /usr/sbin/ifconfig -a | ipconfig /all | ifconfig -a /sbin/ifconfig -a |