Search code examples
linuxnetwork-programmingraspberry-piwifiethernet

Forward ethernet packets in other network and back


i have a networking problem i was hoping to get some answers here. So i have multiple raspberry pi that all have wifi connectivity and ethernet. All the PIs are connected to a network via wifi, and on ethernet to each other. what i need is this: if a raspberry has a problem with the wifi(no signal or smth) i want to send that package over the ethernet and another raspberry should pick up that package on ethernet and forward that on it's owm wifi interface further. Could anybody give me some hints on how this should be approached? Any help would be much appreciate.


Solution

  • you'll have to enable routing in each pi, using sysctl, then enable dynamic routing on each pi, be it ospf or rip does not matter in your case, but you'll have to stick with your choice with the other pis, otherwise you will need to do more complex configuration.
    i strongly suggest that you try to set it up yourself by reading the man, you'll get a feeling of satisfaction when you do it, i'm sure.
    edit 1 : each pi will be a router, having 2 interfaces,2 ethernet connected pis should belong to the same subnet of course.
    edit 2: when a wifi link is down, a raspberry will use the ethernet, the next pi must use nat to translate the packets so they can reach the public network.
    example : wlan0 is external, eth1 is internal

    iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
    iptables -A FORWARD -i eth1 -o wlan0 -j ACCEPT
    

    edit 3: Setting up ospf
    first, install quagga on each router(pi)
    edit /etc/quagga/daemons and replace no by yes in the lines zebra and ospf
    then do this

    cd /etc/quagga
    cp /usr/share/doc/quagga/examples/zebra.conf.sample .
    mv zebra.conf.sample zebra.conf
    

    do the same for ospfd.conf and vtysh.conf
    let the fun begin :
    here is an example on how to do it

    vtysh
    conf t
    router ospf
    network 10.0.1.0/24 area 1
    network 192.168.1.0/24 area 1
    end