Unable to route internet traffic from wifi to ethernet ready TV [SOLVED!]

I’ve reinstalled OSMC alpha 4 on the Pi 2. I’ve been trying to connect my ethernet ready TV to the internet using the Raspberry Pi 2.

The tutorial I followed used an interfaces file in /etc/network. However, I understand from Sam that the file used here is ConnMan under /etc rather than interfaces.

I’m manually allocating the following IPs: eth0 192.168.2.1 netmask 255.255.255.0; wlan0 192.168.15.1. netmask 255.255.255.0.

My sysctl returns net.ipv4.ip_forward = 1. Pinging 192.168.2.2 and pinging 192.168.15.1 both work fine and there’s no packet loss. TV has a manual IP set as 192.168.2.2.

netstat -rn output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.15.1    0.0.0.0         UG        0 0          0 wlan0
192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.15.0    0.0.0.0         255.255.255.0   U         0 0          0 wlan0
192.168.15.1    0.0.0.0         255.255.255.255 UH        0 0          0 wlan0

iptables -v -L output:

Chain INPUT (policy ACCEPT 366 packets, 36259 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  eth0   wlan0   anywhere             anywhere            
    0     0 ACCEPT     all  --  wlan0  eth0    anywhere             anywhere             state RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT 220 packets, 25304 bytes)
 pkts bytes target     prot opt in     out     source               destination

iptables -t nat -v -L output:

Chain PREROUTING (policy ACCEPT 9 packets, 2048 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain INPUT (policy ACCEPT 9 packets, 2048 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 50 packets, 4245 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 9 packets, 524 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  110  9004 SNAT       all  --  any    wlan0   anywhere             anywhere             to:192.168.15.6
    0     0 SNAT       all  --  any    wlan0   anywhere             anywhere             to:192.168.15.6

The eth0 tcpdump on the pi and ping from laptop returns:

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel

However, other times it returned:

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
^C20:15:58.071481 IP Brunos-MacBook-Pro.local > osmc.local: ICMP host 192.168.2.11 unreachable, length 36

1 packet captured
2 packets received by filter
1 packet dropped by kernel

The Pi wlan0 tcpdump returns the following when pinging 8.8.8.8 from the laptop:

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlan0, link-type EN10MB (Ethernet), capture size 262144 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel
1 packet dropped by interface
On all occasions I have to halt the tcpdump on the pi with ctrl+C.

How can I get the 192.168.15.1 network to provide an internet connection to the TV on 192.168.2.2 and have this automated?

Also, thank you Sam and Mariusz for getting me this far as I clearly have limited command of the Pi!

I’ve managed to automate the eth0 manual IP by creating a file ethernet.config in /var/lib/connman with the following:

[service_ethernet]
Type=ethernet
IPv4=192.168.2.2/255.255.255.0

I’m unfamiliar with Linux and even less with ConnMan but there doesn’t seem to be an instruction to route wifi traffic to eth0.

Does anyone have an idea how I can route traffic from internet connected wifi to eth0 using ConnMan?

I managed to sort myself out in the end. If anyone else is curious and wants to do the same, here’s what I’ve done.

Edited the connman.conf file in /etc to include the following lines:

TetheringTechnologies=wifi,ethernet
PersistentTetheringMode=true

I ran the the command ‘connmanctl tether ethernet on’ to turn on the tethering. On my next reboot the Pi was automatically tethering ethernet and my TV has internet! Result!

1 Like

hi @h_ramus
would you mind to discribe again what you have done exactly?

I have added
TetheringTechnologies=wifi,ethernet
PersistentTetheringMode=true
and also set
SingleConnectedTechnology=false
in /etc/connman.conf
I have also created ethernet.config in /var/lib/connman

but as soon as i plug in my ethernetcable I lose immediately my wifi connection.

Thanks in advance
Best regards
Scanto

Hi @scanto

Check that you’ve set

PreferredTechnologies=wifi,ethernet

This setting prioritises connections so WiFi should come first.

The rest is as you described plus the command 'connmanctl tether ethernet on’.

FYI

Step by step of what I’ve done:

OSMC uses connection manager instead of the typical interfaces file in /etc/network and IP tables. They key is to edit the connman.conf file in /etc.

Opening this file up I’ve changed the following:

SinglePreferredTechnology=false
PreferredTechnologies=wifi,ethernet

This allowed me to keep the wifi on when rebooting. I then created an ethernet.config file in /var/lib/connman to include the following:

[service_ethernet]
Type=ethernet
IPv4=192.168.2.2/255.255.255.0

This created static IP to the ethernet port.

However, I don’t think this is really necessary. The way that ConnMan routes traffic from wifi to ethernet is by using tethering, completely different approach to the interfaces files in /etc/network.

Editing the connman.conf file in /etc I included the following lines:

TetheringTechnologies=wifi,ethernet
PersistentTetheringMode=true

I ran the the command ‘connmanctl tether ethernet on’ to turn on the tethering for ethernet and getting internet through it… On my next reboot the Pi was routing traffic to the ethernet and my TV has internet.

Hi @h_ramus , Below are the contents of my file,

osmc@osmc:~$ cat /etc/connman.conf
[General]
PreferredTechnologies=wifi,ethernet
SingleConnectedTechnology=false
AllowHostnameUpdates=false
TetheringTechnologies=wifi,ethernet
PersistentTetheringMode=true

osmc@osmc:~$ sudo cat /var/lib/connman/ethernet.config
[service_ethernet]
Type=ethernet
IPv4=192.168.2.2/255.255.255.0

In the path /var/lib/connman/ there’s a folder created automatically(/var/lib/connman/ethernet_b827eb4a8b94_cable/), with the below contents -:

root@osmc:/var/lib/connman/ethernet_b827eb4a8b94_cable# cat settings
[ethernet_b827eb4a8b94_cable]
Name=Wired
AutoConnect=true
Modified=2015-03-09T15:16:13.937631Z
IPv4.method=fixed
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.2.2
IPv6.method=auto
IPv6.privacy=disabled
Config.file=ethernet
Config.ident=service_ethernet

Now, I have set the following on my TV -:
IP Address - 192.168.2.2
Subnet - 255.255.255.0
Default Gateway - 192.168.2.1 (Tried with 192.168.2.0 and 192.168.1.1 - My Routers IP)
Preferred DNS - 8.8.8.8

Somehow, I’m still not able to make this work.

I have just done what you mentioned in the final step (not installed/ changed anything else).
Any help on troubleshooting? Will keep on trying meanwhile.

FYI, I’m able to ping to 192.168.2.2 from the RPi, but not from the laptop running on the same network (192.168.1.4)

Hi rishibhatia5354

As I mentioned above, setting up a manual IP for the ethernet port doesn’t seem to do much. Have you enbled ethernet tether via ‘connmanctl tether ethernet on’?

After enabling tethering on the ethernet my TV is set to obtain an address automatically via DHCP and it connects to IP 192.168.0.2.

Try to have your TV to obtain an IP address via DHCP and you should be able to ping it on the address it is connected to. Most likely it’ll also be 192.168.0.2.

If you run ifconfig you’ll see that you have your wifi, eth0 and then tether. The tether will provide the internet to the TV and supersede ethernet.

H.

@h_ramus Let me try that again. Everytime I used the command - “connmanctl tether ethernet on”, i got an error, don’t remember the exact thing, but it said something like media not connected, and then all the network would get disconnected. I had to manually reboot the pi everytime i issues this command.

Will try this today again this evening and update.