share wifi connection via ethernet on libreelec 10

  • Hi guys,

    I am running openelec 10.0.0 on raspberry 4b.

    I have found a few threads in this forum and articles in other places about how to convert a raspberry into a wifi hotspot, but I want to actually do the opposite.

    Right now, I have libreelec set up with a static ip via wlan0 and i want to share that connection with an LG tv connected to the LAN port on the raspberry. The main reason for this being that wifi on the tv has stopped working and since the raspberry is next to it (but the internet router is far away), it will save me from a installing a long cable that my wife will definitely complain about.

    I've done the enabling of ipv4_forward, created a few iptables rules, etc, but when I set the openelec's ip as router on the tv, traffic is not working. i have enabled development mode on the tv and I can ssh to test connectivity. I can ping the raspberry (and get response), but I don't seem to go beyond that. I can not get to any public dns server.

    I haven't tried this recently, but I remember doing this with raspbian some time ago and it worked with the commands I mentioned: ip forwarding, iptables rules, etc.

    I couldn't find anything specific for openelec, so i'm following guides for raspbian and I am now wondering if there's anything in openelec that may be preventing this kind of setup. If there isn't, I'd be really grateful if you can point me to any tutorial that the community may have already created.

    This is my setup:

    INTERNET >> homerouter (192.168.0.1) >> openelec (wlan0 / 192.168.0.10-static-ip) >> openelec (eth0 / 192.168.1.10-static-ip) >> lg-tv (ip: 192.168.1.20, netmask: 255.255.255.0, router: 192.168.1.10)

    I don't have any dhcp server in my network (disabled in the router's configuration) and every single device has the ip, netmask and dns details manually configured.

    Thanks in advanced for your help.

  • Here is another option to look at, which I think will enable a bridge (which is easier, IMO):

    Alomon
    May 11, 2021 at 2:07 PM
    Enable Ethernet tethering with LibreELEC
    I have my Raspberry Pi 3 connected to my WLAN with the on-board chip. Now I want to connect my TV's Ethernet cable (it does not have WiFi) to the RPi3 to…
    raspberrypi.stackexchange.com


    For the route you are going you would probably have to setup NAT via iptables, did you do that? what do those rules look like? More than likely you need to just reverse interface names in a few places.

    iptables -t nat -F

    iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

    iptables -F FORWARD

    iptables -A FORWARD -i eth0 -j ACCEPT

    should be the minimal configuration, along with enabling ip_forward. But I would go with the bridge/tethering option, as it is a lot simpler, and the TV device would appear on your network.

    Edited once, last by frakkin64 (January 8, 2022 at 1:27 PM).

  • frakkin64 thanks for your reply.

    I'm happy to report that I made it work based on your suggestion to use the bridge/tethering option.

    i initially went down the route of playing with iptables because that was what i'd done before but i couldn't make it work. I copied the contents of my sd card and reinstalled everything from scratch. Then I tried the commands you shared but i couldn't make the routing work. Funnily enough, though, they do work on raspbian and an older raspberry pi i found. I still believe there may be something in libreelec's implementation that may be preventing this. I made sure ip_forwarding was enabled and tried a few more commands that I found googling, but nothing.

    so, anyway, what you suggested works but i have to say it's not really stable. it's not every time i reboot, but more often than not, the raspberry has no connectivity. configuration is kept when you reboot (in the file suggested in the links you shared), but i have to manually disable/enable wifi from the Kodi to gain access back.

    i tried to automatically "fix" this by enabling/disabling the wifi via crontab, but it doesn't seem to do anything.

    It's not all the time and it only takes one second to fix. I keep this machine running all the time, so it doesn't bother me that much, but anyone looking for a similar setup may find this useful.