Skip to main content
Version: BSP 7.x.y

Network Connectivity Troubleshooting (Linux)

Introduction​

This article describes how to diagnose network connectivity failures on a Toradex Linux Board Support Package (BSP) device. It covers Internet Protocol (IP) routing, Dynamic Host Configuration Protocol (DHCP) leases, Domain Name System (DNS) resolution, and Address Resolution Protocol (ARP) entries. It also provides a reference for the diagnostic tools.

The examples assume that the network interface works at the hardware level: a cable is connected and the physical layer transceiver (PHY) negotiates a link. If an interface on a custom carrier board cannot establish a link with a working cable, see Ethernet PHY Bring-up Troubleshooting (Linux).

For persistent configuration with connman, systemd-networkd, or NetworkManager, see Ethernet/Network (Linux). This article is about diagnosis, not initial setup.

This article complies with the Typographic Conventions for the Toradex Documentation.

info

Interface names (end0, end1, usb0, mlan0, and so on) depend on the board, peripheral, and udev naming rules. Run ip link show on your device to identify its interface names before using the examples.

Checking Basic IP Connectivity​

First, verify name resolution. A failed name lookup typically appears as follows:

# ping www.google.com
ping: bad address 'www.google.com'

A bad address error means name resolution failed before a packet was sent. Try a bare IP address to rule out DNS as a variable:

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network is unreachable

Network is unreachable means the kernel has no route for that destination. Check the routing table:

# ip route show
192.168.11.0/24 dev usb0 proto kernel scope link src 192.168.11.1

With no default route, the device can only reach hosts on 192.168.11.0/24. It has no way to reach a DNS server or any host outside that segment.

No Interfaces UP​

Check if there are any interfaces UP:

# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: end1: <NO-CARRIER,BROADCAST,MULTICAST,DYNAMIC,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 00:14:2d:f8:0d:df brd ff:ff:ff:ff:ff:ff
3: end0: <NO-CARRIER,BROADCAST,MULTICAST,DYNAMIC,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 00:14:2d:e8:0d:df brd ff:ff:ff:ff:ff:ff
6: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 36:85:dc:41:a0:d9 brd ff:ff:ff:ff:ff:ff
7: mlan0: <BROADCAST,MULTICAST,DYNAMIC> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 10:68:38:da:c0:8b brd ff:ff:ff:ff:ff:ff

In this case both Ethernet interfaces show NO-CARRIER, meaning no link partner is detected on either one. Before going further:

After connecting a cable, the link comes up:

# ip link show
3: end0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:14:2d:e8:0d:df brd ff:ff:ff:ff:ff:ff

ethtool confirms the negotiated link parameters (see ethtool for the full field reference):

# ethtool end0
Settings for end0:
Speed: 1000Mb/s
Duplex: Full
Auto-negotiation: on
Link detected: yes

A Gigabit full-duplex link with autonegotiation on is a healthy layer 1/2 result. Modern Ethernet PHYs auto-negotiate cable pairs, so a crossover cable usually isn't required to connect directly to a PC.

Recognizing a Failed DHCP Lease​

Check the interfaces received an IP address from the DHCP server:

# ip addr show
3: end0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:14:2d:e8:0d:df brd ff:ff:ff:ff:ff:ff
inet 169.254.226.171/16 brd 169.254.255.255 scope global end0
valid_lft forever preferred_lft forever
inet6 fe80::214:2dff:fee8:ddf/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever

RFC 3927 reserves 169.254.0.0/16 for IPv4 link-local addresses. Some network managers assign an address from this block after DHCP requests receive no response. RFC 3927 defines link-local addressing but does not require this DHCP fallback behavior.

A 169.254.x.x address can indicate that DHCP failed. Confirm the network manager's configuration and logs before concluding that a DHCP client ran.

Whether a DHCP client runs automatically depends on what's managing the interface:

  • With connman or NetworkManager running, DHCP starts automatically on an interface that comes up.
  • With no network management daemon running, no DHCP client starts, and the interface gets no address at all.

Before assuming the client is at fault, confirm a server is reachable. A DHCP client discovers servers by broadcast, so under normal conditions the server has to sit on the same network segment as the client, or a relay agent has to forward the requests to it.

To rule out the network manager as a variable while testing manually, stop it and bring the link up manually:

# systemctl stop connman

# ip link show end0
3: end0: <BROADCAST,MULTICAST,DYNAMIC> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 00:14:2d:e8:0d:df brd ff:ff:ff:ff:ff:ff

# ip link set end0 up

# ip addr show end0
3: end0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:14:2d:e8:0d:df brd ff:ff:ff:ff:ff:ff
inet6 fe80::214:2dff:fee8:ddf/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever

For the supported way to configure DHCP or a static address persistently, see Ethernet/Network (Linux). The rest of this section uses ip directly, which is useful for a quick, non-persistent test but doesn't survive a reboot.

Testing with a Static Address​

If DHCP isn't answering, assign a static address in the network you expect to test against:

# ip addr add 192.168.50.50 dev end0

# ip addr show end0
3: end0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP
link/ether 00:14:2d:e8:0d:df brd ff:ff:ff:ff:ff:ff
inet 192.168.50.50/32 scope global end0
valid_lft forever preferred_lft forever

Without an explicit prefix length, ip addr add assigns a /32 (host-only) address, so the kernel still has no route to the rest of 192.168.50.0/24:

# ping 192.168.50.1
PING 192.168.50.1 (192.168.50.1): 56 data bytes
ping: sendto: Network is unreachable

# ip route show
192.168.11.0/24 dev usb0 proto kernel scope link src 192.168.11.1

Assign the IP address with the correct prefix so the kernel automatically creates the corresponding on-link route:

# ip addr add 192.168.50.50/24 dev end0

If the address is already assigned, add a route for the segment explicitly instead:

# ip route add 192.168.50.0/24 dev end0

# ip route show
192.168.11.0/24 dev usb0 proto kernel scope link src 192.168.11.1
192.168.50.0/24 dev end0 scope link

Distinguishing a Routing Problem from a Physical One​

With the route in place, a ping to a host on the same segment can still fail differently:

# ping 192.168.50.1
PING 192.168.50.1 (192.168.50.1): 56 data bytes
--- 192.168.50.1 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

Network is unreachable and 100% packet loss mean different things:

SymptomMeaning
Network is unreachableThe kernel has no route for the destination. A layer 3 (routing) problem.
100% packet lossThe kernel sent the packet, but nothing came back. Check layer 1/2 (cabling, switch ports) on the entire path before assuming a routing or configuration problem.
tip

When no router is involved (both ends on the same segment), rule out cabling and switch connectivity across the full physical path before looking at configuration again.

In this case, the switch's uplink cable had been disconnected for the DHCP test earlier. With the physical connection restored, the same ping succeeds:

# ping 192.168.50.1
PING 192.168.50.1 (192.168.50.1): 56 data bytes
64 bytes from 192.168.50.1: seq=0 ttl=64 time=0.699 ms
64 bytes from 192.168.50.1: seq=1 ttl=64 time=0.443 ms
--- 192.168.50.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.443/0.571/0.699 ms

DNS Resolution​

With a working local address, name resolution can still fail:

# wget www.google.com
wget: bad address 'www.google.com'

# cat /etc/resolv.conf
# Generated by Connection Manager

An /etc/resolv.conf without a nameserver entry means DNS has no server to ask. Setting one directly is useful as a quick, temporary test:

# echo "nameserver 8.8.8.8" > /etc/resolv.conf

# cat /etc/resolv.conf
nameserver 8.8.8.8
info

This edit isn't persistent: a network manager can regenerate /etc/resolv.conf on its own. Configure DNS through connman, systemd-networkd, or NetworkManager for anything permanent. Refer to Ethernet/Network (Linux) for more information.

A configured resolver doesn't guarantee DNS works: the resolver itself still needs a route to the name server.

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network is unreachable

The Default Route​

Check for the default gateway route:

# ip route show
192.168.11.0/24 dev usb0 proto kernel scope link src 192.168.11.1
192.168.50.0/24 dev end0 scope link

The device only has routes for two local segments. Reaching 8.8.8.8, or anything else outside those segments, requires a default route to a gateway:

# ip route add default via 192.168.50.1 dev end0

# ip route show
default via 192.168.50.1 dev end0
192.168.11.0/24 dev usb0 proto kernel scope link src 192.168.11.1
192.168.50.0/24 dev end0 scope link

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=115 time=12.891 ms
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 12.891/12.891/12.891 ms

# wget www.google.com
Connecting to www.google.com (142.251.153.119:80)
saving to 'index.html'
index.html 100% |*******************************| 15521 0:00:00 ETA
'index.html' saved

With a default route, the device send packets for destinations without a more specific route to 192.168.50.1. The default keyword is an alias for 0.0.0.0/0, which matches every IPv4 destination.

The host at 192.168.50.1 acts as a gateway: a router that forwards packets toward their destination. Use traceroute to inspect the intermediate hops:

# traceroute -n 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 46 byte packets
1 192.168.50.1 0.426 ms 0.254 ms 0.343 ms
2 192.168.1.1 0.593 ms 0.540 ms 0.517 ms
3 10.85.161.108 3.524 ms 3.776 ms 3.334 ms
4 * * *
5 10.10.1.153 3.867 ms 3.350 ms 3.979 ms
6 10.200.0.52 11.269 ms 10.200.0.210 12.971 ms 10.200.0.52 11.275 ms
7 * * *
8 * * *
9 8.8.8.8 13.267 ms 13.579 ms 12.495 ms

A route to a single host isn't the same as a default route. Adding a host-specific route for the name server alone makes that one address reachable and nothing else:

# ip route add 8.8.8.8/32 via 192.168.50.1 dev end0

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=115 time=13.241 ms
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss

# wget www.google.com
Connecting to www.google.com (142.251.150.119:80)
wget: can't connect to remote host (142.251.150.119): Network is unreachable

Name resolution now works because the device can reach the name server. The resolved web server is on a different network, so the connection still fails until a default route is configured.

Layer 2 vs. Layer 3: ARP​

Reaching another host on the same network segment, including a gateway, requires resolving its IP address to a Media Access Control (MAC) address using ARP (RFC 826). The host sends an ARP request to the Layer 2 broadcast address (ff:ff:ff:ff:ff:ff), and the host that owns the requested IP address responds with a unicast ARP reply.

If a host never answers, ping fails and the ARP table shows an incomplete entry:

# ping 192.168.50.2
PING 192.168.50.2 (192.168.50.2): 56 data bytes
--- 192.168.50.2 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.50.2 (incomplete) end0

ARP resolves the destination MAC address before the first Internet Control Message Protocol (ICMP) echo request.

In this capture, the device uses 192.168.50.21, and a peer at 192.168.50.2 pings it. The peer sends the ARP request, and the device replies. This illustrates the same address resolution process in the opposite direction from the failed ping:

# tcpdump -ni end0
13:36:03.985402 ARP, Request who-has 192.168.50.21 tell 192.168.50.2, length 46
13:36:03.985471 ARP, Reply 192.168.50.21 is-at 00:14:2d:e8:0d:df, length 28
13:36:03.986684 IP 192.168.50.2 > 192.168.50.21: ICMP echo request, id 60615, seq 1, length 64
13:36:03.986731 IP 192.168.50.21 > 192.168.50.2: ICMP echo reply, id 60615, seq 1, length 64

Once a host answers, arp -n shows a resolved MAC address instead of (incomplete), and both local and remote pings succeed:

# ping 192.168.50.2
PING 192.168.50.2 (192.168.50.2): 56 data bytes
64 bytes from 192.168.50.2: seq=0 ttl=64 time=200.922 ms
--- 192.168.50.2 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss

# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.50.1 ether a0:36:9f:0f:84:6a C end0
192.168.50.2 ether 8c:e9:ee:b9:ee:89 C end0

Reaching a remote IP address, such as 8.8.8.8, also requires ARP. The device must resolve the gateway's IP address to a MAC address on the local network segment.

The Network Filters the Device's Traffic​

Some issues occur only on managed or enterprise networks. In these cases, the link is up, the IP configuration is valid, and transmit (TX) packet counters increase, but no response is received. For example:

# ip route show dev end0
192.168.1.81 via 192.168.50.1
192.168.50.0/24 proto kernel scope link src 192.168.50.47
192.168.50.1 scope link

# ip -s link show end0
2: end0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
RX: bytes packets errors dropped missed mcast
136942 682 0 0 0 0
TX: bytes packets errors dropped carrier collsns
163813 917 0 6 0 0

# ping -I 192.168.50.47 192.168.50.1
PING 192.168.50.1 (192.168.50.1) from 192.168.50.47: 56 data bytes
--- 192.168.50.1 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

# ip -s link show end0
2: end0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
RX: bytes packets errors dropped missed mcast
136942 682 0 0 0 0
TX: bytes packets errors dropped carrier collsns
163939 920 0 6 0 0

The TX packet count rises by exactly the three pings sent, while the receive (RX) count remains unchanged. The device is transmitting onto the segment and nothing is answering.

Some switches drop traffic from unknown or unregistered MAC addresses on a port (port security), and some DHCP servers refuse to answer unrecognized clients. Testing with a statically assigned IP address can work around this temporarily, but it risks an address conflict on a network you don't fully control.

The most reliable way to rule out IT-managed network behavior is to remove the managed network from the test entirely.

Connect the device directly to the test PC or through an isolated switch that is not part of the corporate network. A direct connection is preferable whenever practical.

warning

Don't connect a switch to an enterprise network port for testing. Many managed networks flag and shut down ports that suddenly see traffic from an unrecognized switch or a burst of new MAC addresses.

General Debugging Tips​

  • Simplify the setup: connect the device directly to a PC when possible. A direct connection provides a controlled, symmetric endpoint with the same debugging tools available on both sides of the link.

  • Use a known-good cable. Test it between two devices that are already known to work, or use a cable tester, before ruling the cable out.

  • If the link comes up but data still doesn't move reliably, try forcing a lower speed at one or both ends to isolate whether the problem is specific to the negotiated speed:

    # ethtool -s end0 speed 100

    ethtool -s also accepts duplex and autoneg parameters; see ethtool(8) for the full syntax.

  • Test both ends of a link when possible. An RX/TX asymmetry, a duplex mismatch, or a Reduced Gigabit Media Independent Interface (RGMII) phy-mode mismatch can produce similar symptoms when observed from only one endpoint.

Tool Reference​

ethtool​

ethtool queries and controls a network device through the MAC driver's ethtool interface. It's not a way to bypass the driver: what it reports depends on what the driver implements. For supported drivers it can also reach the PHY indirectly, through the driver, for example to run a cable test.

# ethtool end0
FieldDiagnostic information
Link detectedWhether the PHY detects an active link with a link partner.
Speed / DuplexThe negotiated link speed and duplex mode, which may differ from the configured preferences.
Auto-negotiationWhether auto-negotiation is enabled, not whether negotiation completed successfully.
Advertised link modesThe link modes advertised by the local interface.
Link partner advertised link modesThe link modes advertised by the link partner, typically a switch. This can help identify switch port configuration mismatches.

Force autonegotiation to restart:

# ethtool -r end0

Run a cable diagnostic, if the driver supports it:

# ethtool --cable-test usb0
netlink error: Operation not supported
# ethtool --cable-test end0
Cable test started for device end0.
Cable test completed for device end0.
Pair A code OK
Pair B code Open Circuit
Pair B, fault length: 0.00m
Pair C code Open Circuit
Pair C, fault length: 0.40m
Pair D code OK

Read hardware counters, also driver-dependent:

# ethtool -S end0
CounterMeaning
rx_crc_errorsFrames arrived with a bad Cyclic Redundancy Check (CRC). This points to the cable, connector, or the far end's transmit timing.
rx_undersize / rx_fragmentUsually collisions or a link partner transmitting incorrectly.
rx_oversize / rx_jabberUsually a Maximum Transmission Unit (MTU) mismatch or a broken partner.
tx_collision and late-collision countersLate collisions are a classic symptom of a duplex mismatch between link partners.
tx_carrier_errorThe PHY lost carrier during transmit.

RX-side error counters generally indicate issues originating from the link partner or the physical link, while TX-side counters generally indicate issues in the local transmit path. Compare the counters at both ends of the link to identify where the issue originates.

tcpdump​

Capture traffic on a local interface and save it for offline analysis in Wireshark:

# tcpdump -ni end0 -w /tmp/capture.pcap

To inspect traffic in real time, capture and print packets directly to the terminal:

# tcpdump -ni end0

iptables​

Linux includes a netfilter-based firewall, controlled with iptables. The default filter table has three built-in chains:

# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
  • INPUT filters packets destined for this host.
  • OUTPUT filters packets originating from this host.
  • FORWARD filters packets routed through the host to another destination.

When debugging a device that might have firewall rules interfering with a connection, check what's configured first. If there are rules and you need to rule them out temporarily, reset every table to a permissive baseline:

# iptables -P INPUT ACCEPT
# iptables -P FORWARD ACCEPT
# iptables -P OUTPUT ACCEPT
# iptables -F
# iptables -X
# iptables -Z
# iptables -t nat -F
# iptables -t nat -X
# iptables -t mangle -F
# iptables -t mangle -X
# iptables -t raw -F
# iptables -t raw -X
warning

This removes every firewall rule on the device. Only do this temporarily on a device you can restore afterward, and never on a device that relies on those rules for protection in production.

ip, ifconfig, and netstat​

  • ip manages links, IP addresses, and routing tables, and is used throughout this article.
  • ifconfig is an older alternative to ip for basic interface and address configuration.
  • netstat shows active sockets: what's listening, what's connected, and which protocols are in use.
# netstat -nap | head -30
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/init
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 357/systemd-resolve
udp 0 0 192.168.50.21:53940 192.168.1.81:53 ESTABLISHED 464/connmand

ip neigh shows the ARP table that arp -n prints, and ss replaces netstat for socket listings. Both arp and netstat come from the older net-tools package; prefer the iproute2 equivalents in new scripts.

Wireless Networks​

Routing, DNS, and ARP diagnostics apply to both wired and wireless interfaces. For a wireless interface, first confirm that it has associated with an access point. Then use the same IP connectivity checks.

For setting up a Wi-Fi connection in the first place, see How to Connect to a Wi-Fi Network. Once connected, the interface shows a normal UP link:

connmanctl> connect wifi_106838dac08b_4f70656e577274_managed_psk
Connected wifi_106838dac08b_4f70656e577274_managed_psk

# ip link show mlan0
7: mlan0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
link/ether 10:68:38:da:c0:8b brd ff:ff:ff:ff:ff:ff

UP,LOWER_UP and state UP indicate that the interface is administratively up and that carrier is present.

The mode DORMANT field is normal for a wireless interface and does not indicate a fault. It reflects the RFC 2863 operational state reported by the driver to user space while association and key exchange complete. Wireless drivers commonly leave an associated interface in this state.

Additional Resources​

Send Feedback!