6

I use Raspbian Jessi(kernel v4.4) on Raspberry pi 3.

These are my configurations.

pi@raspberrypi:~ $ cat /etc/network/interfaces source-directory /etc/network/interfaces.d auto lo iface lo inet loopback auto eth0 iface eth0 inet manual auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf allow-hotplug wlan1 iface wlan1 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp 

pi@raspberrypi:~ $ cat /etc/dhcpcd.conf -- default -- ........ -- default -- interface eth0 static ip_address=10.0.0.4 

pi@raspberrypi:~ $ ifconfig eth0 Link encap:Ethernet HWaddr b8:27:eb:35:80:7b inet addr:10.0.0.4 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::e38f:f977:c7d9:c394/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:13103 errors:0 dropped:0 overruns:0 frame:0 TX packets:18870 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1116394 (1.0 MiB) TX bytes:21546414 (20.5 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:8284 errors:0 dropped:0 overruns:0 frame:0 TX packets:8284 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:20791523 (19.8 MiB) TX bytes:20791523 (19.8 MiB) wlan0 Link encap:Ethernet HWaddr b8:27:eb:60:d5:2e inet addr:192.168.0.139 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::ba27:ebff:fe60:d52e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:13334 errors:0 dropped:87 overruns:0 frame:0 TX packets:4495 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:10853548 (10.3 MiB) TX bytes:473468 (462.3 KiB) 

My laptop(window 10, MSI 6QE leopard pro) connects to the Raspberry Pi through LAN cable. I can remote the Pi with putty in SSH. At the same time, my laptop connects to the internet with wifi.

Pi can connect to the internet with wifi(ping and apt-get are possible). the problem is when I put the LAN cable to remote the machine, only ping to 8.8.8.8 is possible and nothing works. (ping 8.8.8.8 OK. apt-get can't find the host)

Can I use the internet while LAN cable is connected?

1
  • 1
    Your /etc/network/interfaces is the illegitimate offspring of 2 different networking methods (and is not correct for either) so it is difficult to predict what it will do. How do I set up networking/WiFi/Static IP describes the standard Raspbian setup which enables both. The older standard (which is one of the parents of your current config) generally allows only a single interface. Other methods e.g. network-manager provide finer control as does manual configuration. You need to decide exactly what you are trying to achieve. Commented Jul 10, 2016 at 11:27

2 Answers 2

2

This shouldn't be a problem.

Unfortunately I don't use /etc/net/interfaces or dhcpcd and friends so cannot say what might be right or wrong there; in my opinion it is easier to just disable these things and set stuff up manually, but that is an eccentricity of mine and not something I should recommend generally.

However, I can make a guess and a suggestion if no one comes along with anything more proper:

  1. ifplugd is a background daemon that detects and responds to plugging in an ethernet cable and it will mess with you. I am not positive it is still being used on Raspbian; it isn't on the -lite image, but likely it is on the standard one -- check with ps -C ifplugd. If it shows up, systemctl stop ifplugd and check again. If it is still there, try disabling it as described in the answer to the question linked above and reboot, then check again.

  2. Once ifplugd is out of the picture, comment everything about eth0 out of /etc/network/interfaces; also remove references to it in dhcpcd.conf. Then reboot.

    On first glance in your scenario it sounds as if you require the ethernet connection just to access the pi, but if you are plugging in the cable during runtime and noting a loss of internet that is not the case.

    If you do already have access, then you should be able to run these commands one way or another when you attach to the PC:

    sudo ip link set eth0 up sudo ip addr add 10.0.0.4/24 eth0 

    If not you can add them to /etc/rc.local without sudo but this requires the cable be attached when you boot.

I think this should be sufficient for you to connect with PuTTY. If there are problems you could also try:

sudo ip route add 10.0.0.0/24 dev eth0 

You might want to use that in the first place, actually -- I don't think it can create a problem, it may just be superfluous in this context.

1
  • Thanks so much, but ifplugd is not exist on my latest version of raspbian. I solved this problem few minute ago. I set DNS server as 8.8.8.8 and it worked. Commented Jul 10, 2016 at 12:37
0

I set DNS server as 8.8.8.8 and it worked. sudo nano /etc/resolv.config

change nameserver address to 8.8.8.8

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.