This is for "research" not pragmatic purposes -- I want to know how this is supposed to work, since my guess below does not. In other words, I do not want an answer that involves /etc/network/interfaces or anything else distro specific, or NetworkManager.

Please do not close this as a duplicate of a question which provides such answers.

I'm trying to connect two GNU/Linux systems w/ a regular (not cross-over) ethernet cable. Rumor has it that this should not be a problem now-a-days.

What I tried to do is add a private IP for the interface on both machines:

ip addr add dev eth0

And on the other machine. Neither one is attached to a network that could be identified this way.

I then added routes back and forth:

ip route add via

And vice versa. Subsequently, the output of ip addr and ip route seems to be correct (see below). As per John's comment, I also tried this without adding any route; in this case the ping simply times out.

Both machines have iptables wide open; INPUT, OUTPUT, and FORWARD are ACCEPT with no rules.

But this is what happens when I try a ping:

> ping
PING ( 56(84) bytes of data.
From icmp_seq=1 Destination Host Unreachable
From icmp_seq=2 Destination Host Unreachable

Notice it's the local interface ( that returns this.

What additional steps are needed here and/or where have I gone wrong?

The routing table after using ip route ... looks like:

default via dev wlan0 via dev eth0 dev wlan0  proto kernel  scope link  src 

Sans ip route ..., it looks the same but without line 2.

Output from ethtool (both NICs are identical hardware) looks like:

ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                             100baseT/Half 100baseT/Full 
        Link partner advertised pause frame use: Symmetric Receive-only
        Link partner advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbag
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes

The output from ip a for the ethernet NIC looks like:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:f5:4f:7a brd ff:ff:ff:ff:ff:ff
    inet scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ba27:ebff:fef5:4f7a/64 scope link 
       valid_lft forever preferred_lft forever
  • 1
    Why are you adding routes? You shouldn't need routes with the IPs you mention, as they (should be) on the same subnet. What does your routing table on each host look like immediately after adding the IP, and then after adding the route? – John Oct 23 '15 at 12:39
  • Even nowadays not every NIC has autosense, which you need on one side at least. IP doesn't matter, do you have a link? ethtool eth0 shows something like Link detected: yes and show negotiated speeds etc.? How long is the cable - sometimes very short cables do not work well. – frostschutz Oct 23 '15 at 12:45
  • @John I've edited in the routing table below the original post. I tried this without adding the route (or rather, by deleting it and the address and then resetting the address) and the ping just times out. – goldilocks Oct 23 '15 at 12:51
  • @frostschutz I've added the output from ethtool below the original question. – goldilocks Oct 23 '15 at 12:54
  • 1
    I knew why I asked for the ip a output. :) – phk Oct 23 '15 at 15:20

As written in the comments, you need to fix the routing table.

The syntax ip route add X via Y is used for gateway traffic, i.e. if the traffic to X should be sent to the (most time external address) Y. There need to be a extra route how Y could be reached. If Y is your own interface address and you do not solve the problem otherwise, you create a loop and the routing does not work.

What you need is that the traffic to the other host is sent directly via the interface (not via a gateway). There many different possibilities, depending on the netmask you use:

ip r add dev eth0    # only should go via eth0
ip r add dev eth0     # - should go via eth0

The issue here is that by default this:

ip addr add dev eth0

Set a subnet mask of /32, meaning there could not be any other nodes on the subnet, and trying to set a route there with via amounted to nothing.

Using an explicit, saner mask:

ip addr add dev eth0

Solves the problem; alternately see jofel's answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.