0

I have a single device which I have configured with a static IP address (192.168.1.16) and it is wired directly to the 4th port (enp4s0) on my Ubuntu Linux PC. The m/c is also connected to my LAN via the 3rd port (enp3s0). My LAN uses DHCP to dish out IP's on my 192.168.1.1/24 network.

So now I want to be able to ping my device on 192.168.1.19 via enp4s0 so I used this command to add a route to it via a single IP address :

sudo ip route add 192.168.1.19/32 dev enp4s0

Unfortunately the ping fails:

$ ping 192.168.1.19
PING 192.168.1.19 (192.168.1.19) 56(84) bytes of data.
From 192.168.1.168 icmp_seq=1 Destination Host Unreachable
From 192.168.1.168 icmp_seq=2 Destination Host Unreachable
From 192.168.1.168 icmp_seq=3 Destination Host Unreachable

Looking at some status I see it says the link is down:

$ ip route
default via 192.168.1.1 dev enp3s0 proto dhcp metric 101
default via 10.136.209.45 dev wwan0 proto static metric 700
10.136.209.40/29 dev wwan0 proto kernel scope link src 10.136.209.44 metric 700
169.254.0.0/16 dev enp3s0 scope link metric 1000
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
192.168.1.0/24 dev enp3s0 proto kernel scope link src 192.168.1.168 metric 101
192.168.1.19 dev enp4s0 scope link linkdown

$ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 78:d0:04:31:91:bd brd ff:ff:ff:ff:ff:ff
3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 78:d0:04:31:91:be brd ff:ff:ff:ff:ff:ff
4: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 78:d0:04:31:91:bf brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.168/24 brd 192.168.1.255 scope global dynamic noprefixroute enp3s0
       valid_lft 85575sec preferred_lft 85575sec
    inet6 fe80::1191:4ec4:6844:2273/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
5: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 78:d0:04:31:91:c0 brd ff:ff:ff:ff:ff:ff
6: wwan0: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether e6:83:24:bc:f6:81 brd ff:ff:ff:ff:ff:ff
    inet 10.136.209.44/29 brd 10.136.209.47 scope global noprefixroute wwan0
       valid_lft forever preferred_lft forever
7: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:f1:f6:93:0b brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:f1ff:fef6:930b/64 scope link
       valid_lft forever preferred_lft forever
9: veth36abd25@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
    link/ether ae:27:23:82:70:6a brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::ac27:23ff:fe82:706a/64 scope link
       valid_lft forever preferred_lft forever

Am I missing something else I need to do to be able to reach the device at 192.168.1.19 ?


Update:

After trying some swapping around of the cables I have discovered that the connectors are not in a logical order ! Instead of being 1,2,3,4 they are in fact 1,4,3,2.

So what I thought was enp4s0 is in fact en2s0. Having got past this confusion there now appears to be another issue as demonstrated here :

$ sudo ip route add 192.168.1.19/32 dev enp2s0
$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         setup.ubnt.com  0.0.0.0         UG    102    0        0 enp3s0
default         _gateway        0.0.0.0         UG    700    0        0 wwan0
10.63.138.32    0.0.0.0         255.255.255.248 U     700    0        0 wwan0
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 enp3s0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.1.0     0.0.0.0         255.255.255.0   U     102    0        0 enp3s0
eZ80Acclaim     0.0.0.0         255.255.255.255 UH    0      0        0 enp2s0
$ ping 192.168.1.19
PING 192.168.1.19 (192.168.1.19) 56(84) bytes of data.
64 bytes from 192.168.1.19: icmp_seq=1 ttl=250 time=1.01 ms
64 bytes from 192.168.1.19: icmp_seq=2 ttl=250 time=1.06 ms
64 bytes from 192.168.1.19: icmp_seq=3 ttl=250 time=1.18 ms
64 bytes from 192.168.1.19: icmp_seq=4 ttl=250 time=1.27 ms
64 bytes from 192.168.1.19: icmp_seq=5 ttl=250 time=1.18 ms
64 bytes from 192.168.1.19: icmp_seq=6 ttl=250 time=1.04 ms
64 bytes from 192.168.1.19: icmp_seq=7 ttl=250 time=1.17 ms
64 bytes from 192.168.1.19: icmp_seq=8 ttl=250 time=1.18 ms
64 bytes from 192.168.1.19: icmp_seq=9 ttl=250 time=1.05 ms
64 bytes from 192.168.1.19: icmp_seq=10 ttl=250 time=1.17 ms
64 bytes from 192.168.1.19: icmp_seq=11 ttl=250 time=1.43 ms
64 bytes from 192.168.1.19: icmp_seq=12 ttl=250 time=0.941 ms
From 192.168.1.168 icmp_seq=13 Destination Host Unreachable
From 192.168.1.168 icmp_seq=14 Destination Host Unreachable
From 192.168.1.168 icmp_seq=15 Destination Host Unreachable
^C
--- 192.168.1.19 ping statistics ---
18 packets transmitted, 12 received, +3 errors, 33.3333% packet loss, time 17129ms
rtt min/avg/max/mdev = 0.941/1.139/1.433/0.124 ms, pipe 4
$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         setup.ubnt.com  0.0.0.0         UG    102    0        0 enp3s0
default         _gateway        0.0.0.0         UG    700    0        0 wwan0
10.63.138.32    0.0.0.0         255.255.255.248 U     700    0        0 wwan0
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 enp3s0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.1.0     0.0.0.0         255.255.255.0   U     102    0        0 enp3s0
$

As you can see the route is added to the route table and pinging the device works. However after a few seconds the destination becomes unreachable. Looking at the route table again I see the route has been remove !!

So the question is now 'who' removed the route and why ?

4
  • 2
    Not considering possible other problems (I didn't understand everything, especially the reference to "m/c"): "NO-CARRIER" and "linkdown" mean there won't be communication possible using enp4s0: something missing? Even an Ethernet cable?
    – A.B
    Commented Apr 17 at 13:51
  • m/c - abbreviation of machine Commented Apr 17 at 14:30
  • linkdown - 192.168.1.19 dev enp4s0 scope link linkdown Commented Apr 17 at 14:31
  • The cable is M12 to RJ45, definitely present and brand new. Might try swapping cables and ports around to check there is no dead hardware though. Commented Apr 17 at 14:35

2 Answers 2

0

If your network card is not connected (as it seems) you have to ignore the carrier status.

See this other question for details

0

I think I found the answer to the static routes being dropped. It seems that NetworkManger (nmcli) does not like me adding a route directly, and so it kills them in the background.

I got some inspiration here on how to add a static route for my device using nmcli instead. So I have used this command to add the route I need.

$ sudo nmcli con add type ethernet con-name "static-ip" ifname enp2s0 ipv4.method manual ipv4.addresses 192.168.1.19/32 gw4 0.0.0.0

I am not so sure I understand exactly all its doing but it seems to work and now I can ping my device at 192.168.1.19 all the time. Even better the change is persistent over reboots and I also seem to be able to ping the device from my laptop on the same 192.168.1.0/24 network.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .