0

I'm trying to get rpi to connect to the Internet via wifi (wlan0) - it will connect to a mobile hotspot. It also has to have wired connection (eth0) to a router that is not connected to the Internet.

My desktop PC is also connected to the router. I'm doing this so that I can access a web application running on rpi from my desktop pc, while rpi has its own wifi connection to the Internet.

I understand that this is a bit strange, but this is the only way that I can run local web applications in my office without hopefully breaking any security policies.

I've followed the instructions on this post. My rpi can only ping www.google.com but not my router 192.168.1.1.

I've been tinkering around for over two hours now but I still can't have it so that rpi will respond when I ping from my desktop pc, and at the same time google will respond when I ping www.google.com from rpi.

I'd really appreciate it if someone could give me a hand on this...

Ji Park
  • 111
  • 1
  • 4
  • does this work from the Pi - ping -I eth0 192.168.1.1 ? <-- that is a capital i and not a lowercase l before eth0...What IP address does eth0 have ? – Lawrence Sep 26 '13 at 05:45
  • 1
    Welcome to Raspberry Pi Stack Exchange! Please don't add "thanks" to your question. Upvote answers you like, this is the Raspberry Pi Stack Exchange way of saying thank you. – Piotr Kula Sep 26 '13 at 08:38
  • What does netstat -r show? – HeatfanJohn Sep 26 '13 at 13:40
  • @Lawrence: eth0 has 192.168.1.42. Entering ping -I eth0 192.168.1.1 gives me the following response: "from 192.168.1.42 icmp_seq=1 Destination Host Unreachable" – Ji Park Sep 27 '13 at 01:46
  • what does the command route output ? – Lawrence Sep 27 '13 at 02:01
  • @HeatfanJohn: netstat -r shows http://imgur.com/19g4KAs – Ji Park Sep 27 '13 at 02:07
  • @Lawrence: route outputs the same thing that netstat -r outputs. http://imgur.com/19g4KAs – Ji Park Sep 27 '13 at 02:08
  • Oops, didn't notice HeatfanJohn's comment. If you bring down the wlan interface temporarily, can you ping the router ? – Lawrence Sep 27 '13 at 03:44
  • 3
    @Lawrence: I still get "Destination Host Unreachable" message when I ping the router. All the configuration settings are exactly the same as described on this post (except for ssid and pass of course): (http://raspberrypi.stackexchange.com/questions/8851/setting-up-wifi-and-ethernet) – Ji Park Sep 27 '13 at 04:25
  • How about if you disconnect the wifi adapter, then reboot and try and ping the router ? – Lawrence Sep 27 '13 at 06:23
  • 1
    @Lawrence: dang it... this is very embarrassing... the ethernet cable was disconnected this whole time! so it's working now. Thank you for taking a look into this! – Ji Park Sep 28 '13 at 05:16
  • Happens to all of us :D – Lawrence Sep 28 '13 at 15:33
  • I am facing the exact same question with you. Could you share with me how you solve it? I want to access my pi through direct ethernet connection while keep the wifi not affected. I don't have an extra router, and just want to visit the web application on my raspberry pi. – Jiechao Li Jan 07 '14 at 14:29
  • @Ji. Have you solved this issue yet? If so, could you please create a self-answer and mark it as such. We are trying to get the Q:A ratio up and that would help us a ton. Thanks! – RPiAwesomeness Mar 03 '14 at 17:30

1 Answers1

1

Using the USB Wi-fi adapter, I was able to connect RPi to the Internet via a mobile hotspot. It has a wired connection to a router as well. Also, I have a PC connected to the router, which means I can access web applications running on RPi. Please note that just as described in the original post, I was able to accomplish this by following the instructions on this post. Here are the configuration settings that I have on my RPi:

pi@raspberrypi ~ $ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID"
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="PASSWORD"
id_str="home"
priority=5
}

pi@raspberrypi ~ $ sudo cat /etc/network/interfaces

auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.42
netmask 255.255.255.0
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
address 192.168.43.142
netmask 255.255.255.0
broadcast 192.168.43.255
gateway 192.168.43.1
iface default inet dhcp

pi@raspberrypi ~ $ sudo cat /etc/default/ifplugd

INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

pi@raspberrypi ~ $ sudo cat /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
sudo ifplugd eth0 --kill
sudo ifup wlan0
exit 0
Ji Park
  • 111
  • 1
  • 4