Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Direct ethernet connection [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
AstroFloyd
n00b
n00b


Joined: 18 Oct 2011
Posts: 56

PostPosted: Tue Nov 28, 2017 9:37 am    Post subject: Direct ethernet connection [Solved] Reply with quote

I'm trying to connect a RPi (v3, running Arch) to my Gentoo laptop. I followed Section 5.1 of Home Router to set up and start a dhcp server and connected the Pi through both straight and crossover ethernet cables to my laptop. The Pi uses dhcp and should connect if offered (and I should be able to log in over ssh). However, it doesn't.

Should I have done more to turn my Gentoo laptop into a dhcp server for direct ethernet connections? (I didn't set the IP: advanced router kernel option, for example). Or could my net.eth0 service, which tries to connect through a dhcp client itself, confuse things? Thanks in advance for your help!


Last edited by AstroFloyd on Sun Dec 03, 2017 1:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
massimo
Veteran
Veteran


Joined: 22 Jun 2003
Posts: 1226

PostPosted: Tue Nov 28, 2017 11:02 am    Post subject: Reply with quote

Any logging information, any configuration details anything else you would like to share? Did you try manually configuring the IP addresses accordingly to test connectivity?
_________________
Hello 911? How are you?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Tue Nov 28, 2017 11:35 am    Post subject: Reply with quote

AstroFloyd,

Try the simple approach first. Set up a static IP address both ends.

To make your laptop into a router for the Pi, so the Pi can reach the internet, it will need to do NAT.
That pretty much means you need the whole Home Router on your laptop.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
AstroFloyd
n00b
n00b


Joined: 18 Oct 2011
Posts: 56

PostPosted: Tue Nov 28, 2017 8:15 pm    Post subject: Reply with quote

Hi massimo, NeddySeagoon,

Thanks for your efforts.


The ethernet port of both my Gentoo laptop and Pi is eth0.

Configuration files Gentoo (uncommented lines only):
Code:
# grep -vE '^#|^$' /etc/dnsmasq.conf
interface=eth0
dhcp-range=192.168.2.50,192.168.2.150,12h

# grep eth0 /etc/conf.d/net |grep -v '^#'
config_eth0="192.168.2.1/24 brd 192.168.2.255"


Gentoo /var/log/daemon.log after /etc/init.d/eth0 start
Code:
Nov 28 23:43:37 think ifplugd(eth0)[16003]: ifplugd 0.28 initializing.
Nov 28 23:43:37 think ifplugd(eth0)[16003]: Using interface eth0/53:2F:45:F4:28:13 with driver <e1000e> (version: 3.2.6-k)
Nov 28 23:43:37 think ifplugd(eth0)[16003]: Using detection mode: SIOCETHTOOL
Nov 28 23:43:37 think ifplugd(eth0)[16003]: Initialization complete, link beat not detected.
Nov 28 23:43:37 think /etc/init.d/net.eth0[15631]: WARNING: net.eth0 has started, but is inactive
Nov 28 23:43:39 think ifplugd(eth0)[16003]: Link beat detected.
Nov 28 23:43:40 think ifplugd(eth0)[16003]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.
Nov 28 23:43:41 think avahi-daemon[6291]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.2.1.
Nov 28 23:43:41 think avahi-daemon[6291]: New relevant interface eth0.IPv4 for mDNS.
Nov 28 23:43:41 think avahi-daemon[6291]: Registering new address record for 192.168.2.1 on eth0.IPv4.
Nov 28 23:43:41 think ifplugd(eth0)[16003]: Program executed successfully.


Gentoo /var/log/daemon.log after /etc/init.d/dnsmasq start
Code:
Nov 28 23:47:36 think dnsmasq[16424]: started, version 2.78 cachesize 150
Nov 28 23:47:36 think dnsmasq[16424]: compile time options: IPv6 GNU-getopt DBus i18n no-IDN DHCP DHCPv6 no-scripts no-TFTP no-conntrack ipset no-auth no-DNSSEC loop-detect inotify
Nov 28 23:47:36 think dnsmasq-dhcp[16424]: DHCP, IP range 192.168.2.50 -- 192.168.2.150, lease time 12h
Nov 28 23:47:36 think dnsmasq[16424]: reading /etc/resolv.conf
Nov 28 23:47:36 think dnsmasq[16424]: using nameserver 8.8.8.8#53
Nov 28 23:47:36 think dnsmasq[16424]: using nameserver 8.8.4.4#53
Nov 28 23:47:36 think dnsmasq[16424]: using nameserver 192.168.1.1#53
Nov 28 23:47:36 think dnsmasq[16424]: read /etc/hosts - 32 addresses


Gentoo /var/log/daemon.log after unplugging and plugging in the Pi
Code:
Nov 28 23:49:53 think ifplugd(eth0)[16003]: Link beat lost.
Nov 28 23:49:59 think ifplugd(eth0)[16003]: Executing '/etc/ifplugd/ifplugd.action eth0 down'.
Nov 28 23:49:59 think avahi-daemon[6291]: Withdrawing address record for 192.168.2.1 on eth0.
Nov 28 23:49:59 think avahi-daemon[6291]: Leaving mDNS multicast group on interface eth0.IPv4 with address 192.168.2.1.
Nov 28 23:49:59 think avahi-daemon[6291]: Interface eth0.IPv4 no longer relevant for mDNS.
Nov 28 23:50:00 think ifplugd(eth0)[16003]: client: RTNETLINK answers: No such file or directory
Nov 28 23:50:00 think ifplugd(eth0)[16003]: client: Error talking to the kernel
Nov 28 23:50:00 think ifplugd(eth0)[16003]: Program executed successfully.
Nov 28 23:50:03 think ifplugd(eth0)[16003]: Link beat detected.
Nov 28 23:50:04 think ifplugd(eth0)[16003]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.
Nov 28 23:50:04 think avahi-daemon[6291]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.2.1.
Nov 28 23:50:04 think avahi-daemon[6291]: New relevant interface eth0.IPv4 for mDNS.
Nov 28 23:50:04 think avahi-daemon[6291]: Registering new address record for 192.168.2.1 on eth0.IPv4.
Nov 28 23:50:04 think ifplugd(eth0)[16003]: Program executed successfully.


Gentoo ifconfig eth0 when the Pi is plugged in
Code:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.1  netmask 255.255.255.0  broadcast 192.168.2.255
        ether 53:2f:45:f4:28:13  txqueuelen 1000  (Ethernet)
        RX packets 193  bytes 64710 (63.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3348  bytes 392779 (383.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf2400000-f2420000 


Gentoo dmesg when plopping out and in the ethernet cable:
Code:
[Nov28 08:55] e1000e: eth0 NIC Link is Down
[  +8.992337] e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: Rx


nmap on Gentoo:
Code:
# nmap -sP 192.168.2.*
Starting Nmap 7.40 ( https://nmap.org ) at 2017-11-28 21:20 CET
Nmap scan report for 192.168.2.1
Host is up.
Nmap done: 256 IP addresses (1 host up) scanned in 10.48 seconds


Gentoo emerge --info

I find no logging when I plug in the Pi. Should something appear in daemon.log?

The Pi connects using cables to routers at home and work using dhcp without problem and I think it is working fine. I'd rather not tamper with it at the moment. I am currently not interested in connecting the Pi to the internet through my laptop.

Pi ifconfig eth0 when plugged in:
Code:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 f8e0::efbf:ab72:4d3e:ef5a  prefixlen 64  scopeid 0x20<link>
        ether 8b:eb:a5:72:ed:43  txqueuelen 1000  (Ethernet)
        RX packets 1020  bytes 46920 (45.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 247  bytes 47368 (46.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Tue Nov 28, 2017 8:29 pm    Post subject: Reply with quote

AstroFloyd,

It looks like dhcpcd or whatever Arch uses has not run on the Pi.

Baby steps.

Your Gentoo eth0 is
Code:
 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.1  netmask 255.255.255.0  broadcast 192.168.2.255


and in assigns IPs in the range
Code:
dhcp-range=192.168.2.50,192.168.2.150
to things that ask.
For this test we need to avoid that range.

Bring up the Gentoo end of the link - check for the IP.
At the Pi end, run
Code:
dhcpcd eth0
and check for an IP address. If that worked, you should be able to run ssh over the link.

If there is no IP address on the Pi, run
Code:
ifconfig eth0 192.168.2.5
Avoid the dynamically assigned range.
Again, you should be able to ssh over the link.

If the second case works but not the first one, you have problems with your Gentoo dhcpd.
Neither setup alone will get the Pi on the internet but step one is getting the laptop/Pi link working.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Wed Nov 29, 2017 1:06 am    Post subject: Reply with quote

It's ok for dhcp to fail to gave your PI an address, but it's not the case:
Code:
         inet6 f8e0::efbf:ab72:4d3e:ef5a  prefixlen 64  scopeid 0x20<link>

Your PI get an inet6 address, which mean an inet6 dhcpd has answer to it (which should not because you are using dhcp net4 on gentoo and you were saying the PI was connected directly with the gentoo host with a cross cable).
If your PI and gentoo are connected to a router, all you need to do to prevent the PI from using internet is removing the default gateway routing from it (and making sure it is not set as DMZ). Howto do this is a question for arch users.
But i must admit i'm unsure what you are trying to do there.
Back to top
View user's profile Send private message
AstroFloyd
n00b
n00b


Joined: 18 Oct 2011
Posts: 56

PostPosted: Wed Nov 29, 2017 6:03 pm    Post subject: Reply with quote

Thank you everyone for your patience and effort!

@NeddySeagoon:
Code:
dhcpcd eth0
on the Pi gives me no IP address(inet4), but
Code:
ifconfig eth0 192.168.2.5
does, and I can log in from my Gentoo laptop. First baby step accomplished ;-) Second step taken too - it works for both the crossover and the normal ethernet cables, which is good to know.

So this would mean that either I haven't set up my dhcp server correctly on my Gentoo laptop, or dhcp doesn't work on the Pi. However, when I connect the Pi to my modem/router using an ethernet cable (for the Pi), dhcp *does* work every time, at home or at work (I just tried it again, to be sure). So it seems to me that the problem is in my Gentoo setup...


@krinn: I don't know much about inet6. An inet6 address doesn't show up on the Pi if I boot with the ethernet cable unplugged (makes sense to me). It does show up when I plug in the cable (also seems to make sense), but it still shows up when I unplug the cable again (for all I know until shutdown). Is that what you expect?

My situation is thus: I need the Pi for a class I teach at work. The networks there are firewalled - I can connect the Pi to the network and internet, but not ssh into it. I can go to a special classroom with a local lan, but that's not a convenient place to work. If I could access my Pi directly through ethernet from my laptop, I can ssh through the cable, while the Pi's wireless connects to the internet and I can install stuff.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3136

PostPosted: Wed Nov 29, 2017 8:14 pm    Post subject: Reply with quote

AstroFloyd wrote:
My situation is thus: I need the Pi for a class I teach at work. The networks there are firewalled - I can connect the Pi to the network and internet, but not ssh into it. I can go to a special classroom with a local lan, but that's not a convenient place to work. If I could access my Pi directly through ethernet from my laptop, I can ssh through the cable, while the Pi's wireless connects to the internet and I can install stuff.
So, basically you only want to connect 2 machines. And there is YOUR raspberry at one end of the wire and YOUR laptop at the other end of the same wire.
Don't bother with DHCP at all. Just configure static IPs and set static routes (/32, single host only).
Actually, it seems you have already done this. Good, this is the right way to handle this case. I mean, sure, dhcp can do that too, but seriously: dhcp would be an overkill. Not worth the effort of initial configuration.

However, if you really feel like troubleshooting it (for any purpose, probably different than just connecting those 2 pieces with a single wire), wireshark goes a long way. Figuring out your mistakes is much easier when you can actually inspect the network traffic.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Wed Nov 29, 2017 8:33 pm    Post subject: Reply with quote

AstroFloyd,

The static setup will work well enough as long as you do not want to reach the internet over the wire.
Fix your dhcp server at your leisure.

Your Pi is in a /24 subnet with your laptop.
You will get the route for that from your laptop for free.

Do take care that its not the default route or your laptop will send everything to the Pi and not the internet.
Check the output of the route command. Having two default routes is a very bad thing.
For testing, where you only want to reach the Pi, it won't matter.

Code:
$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.253 0.0.0.0         UG    2      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0

Routes are applied from the bottom of the routing table working upwards.

Destination 0.0.0.0 matches everything - its the default, thus two defaults don't make sense. Only one can ever be used.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Thu Nov 30, 2017 2:10 pm    Post subject: Reply with quote

AstroFloyd wrote:
@krinn: I don't know much about inet6. An inet6 address doesn't show up on the Pi if I boot with the ethernet cable unplugged (makes sense to me). It does show up when I plug in the cable (also seems to make sense), but it still shows up when I unplug the cable again (for all I know until shutdown). Is that what you expect?

No i was expecting you get no ip at all or maybe some dhcpcd local ip if the PI remain connect only to the gentoo host.
But i wasn't sure about you were trying to accomplish.

AstroFloyd wrote:
My situation is thus: I need the Pi for a class I teach at work. The networks there are firewalled - I can connect the Pi to the network and internet, but not ssh into it. I can go to a special classroom with a local lan, but that's not a convenient place to work. If I could access my Pi directly through ethernet from my laptop, I can ssh through the cable, while the Pi's wireless connects to the internet and I can install stuff.

In order to ease the solve, your laptop certainly also could connect to that firewall network (using laptop wireless), so it will just put them both on the same network.
This being said, your firewall should filter ssh from or to internet, but not from a local network. Meaning laptop and PI could ssh each other without trouble.
Is your problem that your laptop cannot connect to the wireless too? Or that the firewall rules are paranoiac?
I'm saying this because you might try to build a bridge over a river when maybe its level could allow you to just cross it.
Back to top
View user's profile Send private message
AstroFloyd
n00b
n00b


Joined: 18 Oct 2011
Posts: 56

PostPosted: Fri Dec 01, 2017 5:24 pm    Post subject: Reply with quote

Hi everyone,

Thanks for all your help and effort - it is very much appreciated.

The problem seems to be somewhere in my dnsmasq, but unfortunately I can't find where. I checked the instructions on the Arch and Debian websites, which seem to be identical to those on the Gentoo Wiki. I tried connecting another laptop with the same results as the Pi - it works fine with a static IP address, but not with dhcp. Then I tried dhcpd from net-misc/dhcp, which works out of the box. I'm still a bit annoyed that I can't find the problem in dnsmasq, but not enough to pursue this any further (I did test an older version of dnsmasq though - no luck).


For others who have the same problem and end up on this page, here's how I set up dhcpd (using the ArchWiki page on dhcpd as a reference):

Code:
emerge -va net-misc/dhcp

(ensure that USE=+server, which should be set by default).

Then, in /etc/dhcp/dhcpd.conf:
Code:
option domain-name-servers 8.8.8.8, 8.8.4.4;
option subnet-mask 255.255.255.0;
option routers 192.168.2.100;
subnet 192.168.2.0 netmask 255.255.255.0 {
  range 192.168.2.150 192.168.2.250;
}

In /etc/conf.d/dhcpd:
Code:
DHCPD_IFACE="eth0"

and in conf.d/net:
Code:
# DHCP server:
config_eth0="192.168.2.1/24 brd 192.168.2.255"

Then (re)start the network connection and DHCP server:
Code:
# /etc/init.d/net.eth0 restart
# /init.d/dhcpd restart


On the client:
Code:
dhcpcd eth0

and I obtained an IP address and could start an ssh connection.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum