You are not logged in.

#1 2013-06-28 14:43:05

D4ve
Member
Registered: 2012-08-02
Posts: 209

[Solved] Use my pc as router for my raspberry pi

Hi, i've got a little problem understanding routing, maybe someone can help me.

My pc is connected via wlan (192.168.2.107) to the router (192.168.2.1). The router itself is connected to the internet.

$ ip route show
default via 192.168.2.1 dev wlan0  proto static 
192.168.2.0/24 dev wlan0  proto kernel  scope link  src 192.168.2.107  metric 9 

Now i connect my raspberry pi over ethernet to my pc and nothing happens. So i put on the raspberry pi following:
IP: 192.168.1.24
Netmask: 255.255.255.0
Gateway: 192.168.1.0 (is that right?)

On the pc i set 192.168.1.48 for eth0. Now the routing on my pc changes. Side effect: DNS resolution doesn't work anymore.

$ ip route show
default via 192.168.2.1 dev eth0  proto static 
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.10  metric 1 
192.168.2.0/24 dev wlan0  proto kernel  scope link  src 192.168.2.107  metric 9 
192.168.2.1 dev eth0  proto static  scope link

What I would like to reach: The raspberry pi can be connected via ethernet to the pc and uses its internet connection. Would be nice if this can be made completely statically, without requiring an dhcp server or something similar.

On the raspberrypi runs archlinux-arm, on the computer also archlinux including the gnome-shell and its network manager.

Can someone help me to achieve this?

Last edited by D4ve (2013-06-29 21:28:54)

Offline

#2 2013-06-28 14:46:28

NoSavvy
Member
From: Dorchester, Dorset, UK
Registered: 2013-01-23
Posts: 123

Re: [Solved] Use my pc as router for my raspberry pi

Gateway. Should be 192.168.2.1

Offline

#3 2013-06-28 15:21:10

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: [Solved] Use my pc as router for my raspberry pi

It looks like you set the default route incorrectly (now going via eth0).

As it happens, I've just been doing this today. But I set up internet connection sharing as follows

  • On the pi (OpenELEC) I set up a static ip (10.0.0.3/8) for eth0, gateway (10.0.0.2), DNS 8.8.8.8

  • My home network uses 172.17.2.*, my laptop wireless is on that subnet so I chose 10.*.*.* for the other network

  • installed ifplugd, didn't bother setting up eth0 via udev, just using enp1s0

  • added an auto-wired profile, I set my latop wired connection to 10.0.0.2, the profile also restarts iptables

  • Iptables sets masquerading

  • kernel told to forward packets

cat /etc/netctl/pi
Description='A basic static ethernet connection'
Interface=enp1s0
Connection=ethernet
IP=static
Address='10.0.0.2/24'
ForceConnect=yes
Autowired=yes
ExecUpPost="/usr/bin/systemctl restart iptables"
cat /etc/iptables/iptables.rules 
# Generated by iptables-save v1.4.19.1 on Fri Jun 28 09:05:26 2013
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [11:723]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o wlp2s0 -j MASQUERADE
COMMIT
grep ip_forward /etc/sysctl.conf 
net.ipv4.ip_forward = 1

I think that's about it.

Offline

#4 2013-06-28 16:45:48

D4ve
Member
Registered: 2012-08-02
Posts: 209

Re: [Solved] Use my pc as router for my raspberry pi

I'm sorry, but i still don't know how this will ever work.

NoSavvy wrote:

Gateway. Should be 192.168.2.1

This should be set on the raspberry pi, right?

Problem: The raspberry pi can't even connect to the router (ping 192.168.2.1 gives no results)

vacant wrote:

It looks like you set the default route incorrectly (now going via eth0).

I know, but i didn't change it. This was probably done by gnome-shells network manager (And I have no idea how to prevent this)

The whole topic seems still too complicated for me.

It there no way to simply share my wlan connection over ethernet? Or route everything from eth0 forward to wlan0 (or something like that?)

Offline

#5 2013-06-29 11:06:09

D4ve
Member
Registered: 2012-08-02
Posts: 209

Re: [Solved] Use my pc as router for my raspberry pi

Haha, it works smile

And, of course, everything is in the wiki: Internet Share

So, what have I done? On the raspberry pi:

Address including netmask (as mentioned in netctl): 10.0.0.24/24
Gateway: 10.0.0.1
DNS: 192.168.2.1

On my pc i disabled NetworkManager and started using netctl. Installation and configuring was pretty easy. And everything else stands in the article mentioned above.

So, finally, everything works. Thanks for your help, maybe in future i should try to investigate more time into searching the wiki.

Offline

Board footer

Powered by FluxBB