You are not logged in.

#1 2016-01-02 18:17:21

boydster
Member
Registered: 2015-12-30
Posts: 6

Trying to get Internet Sharing to work

I am not able to get a connection established for Internet Sharing between my computer and my Raspberry Pi, and I have been following the guide as best as I know how. If anyone can help point me in the right direction, I think my problem may be in how I tried to implement the systemd-networkd IPForward=kernel setting, but I'm not experienced enough to know for sure how to fix it or if the problem is elsewhere.

Steps I have taken so far (all from the computer with the connection to be shared):
   -- note: I am looking to use the wireless (wlp11s0) interface for internet access and the ethernet (enp9s0) interface to share.
   -- further note: I intentionally skipped the section on making changes persistent on reboot (did not edit /etc/sysctl.d/30-ipforward.conf) as this is kind of a one-off for now.

# ip link set up dev enp9S0
# ip addr add 192.168.123.100/24 dev enp9S0
# sysctl net.ipv4.ip_forward=1
# iptables -t nat -A POSTROUTING -o wlp11s0 -j MASQUERADE
# iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# iptables -A FORWARD -i enp9s0 -o wlp11s0 -j ACCEPT

From there, I created the file /etc/systemd/network/interface.network with the following content:

[Match]

[Network]
IPForward=kernel
DHCP=yes

[DHCP]
RouteMetric=20

I then restarted systemd-networkd  (systemctl restart systemd-networkd). My Raspberry Pi had already grabbed an IP address when I checked it, so I didn't take any action with respect to assigning an IP to a client PC as outlined at the bottom of the internet sharing guide as that seemed unnecessary. Perhaps that was a mistake?

The part I felt the most out of my comfort zone with was the interface.network file, so that is why I'm feeling inclined to believe something went wrong on that step. But I'm open to suggestion/guidance if anyone can help get me pointed in the right direction.

Thanks!


Edit: the following is the output of dmesg | tail:

$ dmesg | tail
[   17.860779] sky2 0000:09:00.0 enp9s0: renamed from eth0
[   18.363999] mousedev: PS/2 mouse device common for all mice
[   18.585819] input: AlpsPS/2 ALPS GlidePoint as /devices/platform/i8042/serio2/input/input17
[   21.581782] IPv6: ADDRCONF(NETDEV_UP): wlp11s0: link is not ready
[   21.805663] IPv6: ADDRCONF(NETDEV_UP): enp9s0: link is not ready
[   21.808359] sky2 0000:09:00.0 enp9s0: enabling interface
[   21.808519] IPv6: ADDRCONF(NETDEV_UP): enp9s0: link is not ready
[   33.497773] fuse init (API version 7.23)
[  836.695603] sky2 0000:09:00.0 enp9s0: Link is up at 100 Mbps, full duplex, flow control both
[  836.695633] IPv6: ADDRCONF(NETDEV_CHANGE): enp9s0: link becomes ready

Last edited by boydster (2016-01-02 18:45:08)

Offline

#2 2016-01-02 18:46:38

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,612

Re: Trying to get Internet Sharing to work

NAT forwarding implies you have two networks.
The Raspberry Pi does not come with wifi, so I assume you are using a wired LAN between your Arch Linux box and your Raspberry Pi (Actually, you did state that)
You stated that you plan to use the wireless card on the Host for Internet access.
I assume these are all non-routable addresses so there is no need to redact them (everything is of the form 192.168.x.y or 10.0.x.y)
What is the output of ip addr on the host?  What is the output of that command on the Raspberry Pi?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2016-01-02 18:52:30

boydster
Member
Registered: 2015-12-30
Posts: 6

Re: Trying to get Internet Sharing to work

Host:

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:21:9b:e8:96:9a brd ff:ff:ff:ff:ff:ff
    inet6 fe80::221:9bff:fee8:969a/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp11s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:22:69:94:96:69 brd ff:ff:ff:ff:ff:ff
    inet 172.20.20.20/24 brd 172.20.20.255 scope global dynamic wlp11s0
       valid_lft 268sec preferred_lft 268sec
    inet6 fe80::222:69ff:fe94:9669/64 scope link 
       valid_lft forever preferred_lft forever

Pi:

# ifconfig
eth0      Link encap:Ethernet  HWaddr B8:27:EB:A9:15:0F  
          inet addr:169.254.217.114  Bcast:169.254.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:126 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1425 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:41272 (40.3 KiB)  TX bytes:352589 (344.3 KiB)

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:356 errors:0 dropped:0 overruns:0 frame:0
          TX packets:356 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:30020 (29.3 KiB)  TX bytes:30020 (29.3 KiB)

wlan0     Link encap:Ethernet  HWaddr 00:0F:60:02:B2:EC  
          inet addr:192.168.1.8  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:184 errors:0 dropped:0 overruns:0 frame:0
          TX packets:225 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:83753 (81.7 KiB)  TX bytes:44993 (43.9 KiB)

I am temporarily using a wifi dongle on the Pi, otherwise the wlan0 interface would be down. The wired connection between the host and the Pi is on the eth0 interface of the Pi and enp9s0 on the host.

Offline

#4 2016-01-02 19:05:59

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,612

Re: Trying to get Internet Sharing to work

Okay the 169 address is a one of those PITA self assigned ones. 
I am puzzled -- Are the Raspberry Pi and the Host on the same Wireless LAN?  One has a 192 address, and the other a 172 address
There is no IPv4 address assigned to the Ethernet port on the host.  You said you ran

ip addr add 192.168.123.100/24 dev enp9S0

But the adapter name is enp9s0.  You need to ensure that the address appears on the network device in the output of ip addr
You also need to set an address on the RaspPi in the 192.168.123.x space. 
Then see if the machines can ping each other on their 192.x.y.z. addresses.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#5 2016-01-02 19:42:58

boydster
Member
Registered: 2015-12-30
Posts: 6

Re: Trying to get Internet Sharing to work

They are on different wlans, correct. The host is on the wlan that I want to share, the Pi is on a different wlan with no outside internet access (again, only connected so I could ssh into it temporarily).

I made a typo as I was entering the instructions I typed into my post, the actual command I ran called enp9s0, sorry for the confusion.

Here's what I just did after a fresh boot on host:

# ip link set up dev enp9s0
# ip addr add 192.168.123.100/24 dev enp9s0
# sysctl net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
# iptables -t nat -A POSTROUTING -o wlp11s0 -j MASQUERADE
# iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -i ACCEPT
# iptables -A FORWARD -i enp9s0 -o wlp11s0 -j ACCEPT

On the Pi, I did the following:

# ip addr add 192.168.123.125 dev eth0
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP8000> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether b8:27:eb:a9:15:0f brd ff:ff:ff:ff:ff:ff
    inet 169.254.89.132/16 brd 169.254.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.123.125/32 scope global eth0
       valid_lft forever preferred_lft forever
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP8000> mtu 1500 qdisc mq qlen 1000
    link/ether 00:0f:60:02:b2:ec brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.8/24 brd 192.168.1.255 scope global wlan0
       valid_lft forever preferred_lft forever
# ping 192.168.123.100
PING 192.168.123.100 (192.168.123.100): 56 data bytes
^C
--- 192.168.123.100 ping statistics ---
67 packets transmitted, 0 packets received, 100% packet loss

While that set the IP address in the right range, the ping didn't work. Interestingly, the ping from the host to the Pi worked:

$ ping 192.168.123.125
PING 192.168.123.125 (192.168.123.125) 56(84) bytes of data.
64 bytes from 192.168.123.125: icmp_seq=1 ttl=64 time=0.840 ms
64 bytes from 192.168.123.125: icmp_seq=2 ttl=64 time=0.605 ms
64 bytes from 192.168.123.125: icmp_seq=3 ttl=64 time=0.629 ms
64 bytes from 192.168.123.125: icmp_seq=4 ttl=64 time=0.614 ms
64 bytes from 192.168.123.125: icmp_seq=5 ttl=64 time=0.665 ms
64 bytes from 192.168.123.125: icmp_seq=6 ttl=64 time=0.718 ms

Edit:
I also ran the following on the Pi after recalling that it was written on the wiki, but was still unable to get a ping response from the host:

# ip link set up dev eth0
# ip route add default via 192.168.123.100 dev eth0 

Last edited by boydster (2016-01-02 20:13:05)

Offline

#6 2016-01-02 22:22:36

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,511

Re: Trying to get Internet Sharing to work

host:
Check that under /proc/sys/net/ipv4/ip_forward.
ifconfig enp9s0 192.168.123.100
systemctl start iptables
iptables -t nat -A POSTROUTING -o wlp11s0 -j MASQUERADE
iptables -t nat -nvL (check it for the right way)
iptables-save >> /etc/iptables/xxxxx (if you have it working right)
pi:
ifconfig enp9s0 192.168.123.xxx
route add default gw 192.168.123.100

You have to get the iptables on the host working.
If you can ping the host on the pi, you're almost there.
Ping your gateway to see that it makes it that far, and of course something like 8.8.8.8 to confirm you are out to the internet.  Don't forget your /etc/resolv.conf on the pi for nameservice.  You could run DHCP on your host to make configuration of your pi easier.

Last edited by nomorewindows (2016-01-02 23:26:03)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

Board footer

Powered by FluxBB