Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Using Raspberry Pi3 with Duet 2 Ethernet

    Scheduled Pinned Locked Moved
    Duet Hardware and wiring
    6
    24
    3.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • nikkerundefined
      nikker
      last edited by nikker

      @incogizmo i started again with a fresh flash and still no luck, RPI3 address on my network is 192.168.50.16 and when i enter that in chrome nothing loads. I do have another duet 2 wifi running on my network right now as well but I didnt think the MAC addresses were the same. I setup my config.g as you had above (my home network is using 192.168.50.X so there shouldnt be any issues with the RPI3's 192.168.1.X) and performed the steps above with the exception of the dnsmasq and dhcp setup.

      My /etc/network/interfaces looks like this (I am not using an external wifi adapter at the moment as I am trying to keep it simple so only have wlan0 for now:

      auto lo
      iface lo inet loopback

      #iface eth0 inet manual
      allow-hotplug eth0
      iface eth0 inet static
      address 192.168.1.1
      netmask 255.255.255.0
      network 192.168.1.0
      broadcast 192.168.1.255

      allow-hotplug wlan0
      iface wlan0 inet manual
      wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

      allow-hotplug wlan1
      iface wlan1 inet manual
      wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

      my /etc/iptables.ipv4.nat file contains this:

      Generated by iptables-save v1.4.21 on Thu Dec 13 06:32:18 2018
      *nat
      :PREROUTING ACCEPT [2:772]
      :INPUT ACCEPT [2:772]
      :OUTPUT ACCEPT [3:228]
      :POSTROUTING ACCEPT [0:0]
      -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.1.50:80
      -A POSTROUTING -o wlan0 -j MASQUERADE
      COMMIT
      Completed on Thu Dec 13 06:32:18 2018

      I am not sure why wlan1 keeps coming up on a fresh flash even though I have never plugged one in. Is there something i need to configure in raspi-config? If i ping 192.168.1.50 on the RPI3 I see the green light on the Duet 2 ethernet port light up but other than when I ping only the orange light is solid.

      1 Reply Last reply Reply Quote 0
      • incogizmoundefined
        incogizmo
        last edited by

        When you ping the Duet from the PI do you get a ping reply?

        If this is working then there is a problem with the ip forwarding, in this case please send the output from the following commands

        sudo iptables -L
        sudo iptables -L -t nat
        grep ip_forward /etc/sysctl.conf
        ifconfig
        

        If the ping reply is not working then it is likely a network configuration issue on the ethernet side, either on the duet of the PI. If you dont get a ping reply can you send your duet config and the output from ifconfig on the pi?

        1 Reply Last reply Reply Quote 0
        • nikkerundefined
          nikker
          last edited by nikker

          Yeah when I ping the Duet 2 at 192.168.1.50 from the RPI3 this is what I get until I stop it with ctrl+c:

          pi@raspberrypi:~ $ ping 192.168.1.50
          PING 192.168.1.50 (192.168.1.50) 56(84) bytes of data.
          64 bytes from 192.168.1.50: icmp_seq=1 ttl=128 time=0.659 ms
          64 bytes from 192.168.1.50: icmp_seq=2 ttl=128 time=0.289 ms
          64 bytes from 192.168.1.50: icmp_seq=3 ttl=128 time=0.294 ms
          64 bytes from 192.168.1.50: icmp_seq=4 ttl=128 time=0.304 ms
          64 bytes from 192.168.1.50: icmp_seq=5 ttl=128 time=0.302 ms
          64 bytes from 192.168.1.50: icmp_seq=6 ttl=128 time=0.281 ms
          64 bytes from 192.168.1.50: icmp_seq=7 ttl=128 time=0.276 ms
          64 bytes from 192.168.1.50: icmp_seq=8 ttl=128 time=0.270 ms
          ^C
          --- 192.168.1.50 ping statistics ---
          8 packets transmitted, 8 received, 0% packet loss, time 7292ms
          rtt min/avg/max/mdev = 0.270/0.334/0.659/0.124 ms

          here is the output from the commands you asked for,

          pi@raspberrypi:~ $ sudo iptables -L
          Chain INPUT (policy ACCEPT)
          target prot opt source destination

          Chain FORWARD (policy ACCEPT)
          target prot opt source destination

          Chain OUTPUT (policy ACCEPT)
          target prot opt source destination

          pi@raspberrypi:~ $ sudo iptables -L -t nat
          Chain PREROUTING (policy ACCEPT)
          target prot opt source destination
          DNAT tcp -- anywhere anywhere tcp dpt:http to:192.168.1.50:80

          Chain INPUT (policy ACCEPT)
          target prot opt source destination

          Chain OUTPUT (policy ACCEPT)
          target prot opt source destination

          Chain POSTROUTING (policy ACCEPT)
          target prot opt source destination
          MASQUERADE all -- anywhere anywhere

          pi@raspberrypi:~ $ grep ip_forward /etc/sysctl.conf
          net.ipv4.ip_forward=1

          pi@raspberrypi:~ $ ifconfig
          eth0 Link encap:Ethernet HWaddr b8:27:eb:1e:44:b6
          inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
          inet6 addr: fe80::deb:7778:30df:3621/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:9 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:718 (718.0 B) TX bytes:8565 (8.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:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

          wlan0 Link encap:Ethernet HWaddr b8:27:eb:4b:11:e3
          inet addr:192.168.50.16 Bcast:192.168.50.255 Mask:255.255.255.0
          inet6 addr: fe80::42d8:ee2d:87f2:a2b1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:467 errors:0 dropped:0 overruns:0 frame:0
          TX packets:284 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:51217 (50.0 KiB) TX bytes:40944 (39.9 KiB)

          1 Reply Last reply Reply Quote 0
          • nikkerundefined
            nikker
            last edited by

            @incogizmo Im not sure why it worked the first time but I eventually got it to work using some information from this post https://serverfault.com/questions/140622/how-can-i-port-forward-with-iptables

            I added
            sudo iptables -t nat -A PREROUTING -p tcp -i wlan0 --dport 80 -j DNAT --to-destination 192.168.1.50:80
            sudo iptables -A FORWARD -p tcp -d 192.168.1.50 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

            and made sure it was saved in /etc/iptables.ipv4.nat and then gave it a reboot, a prayer and bingo. Now to bookmark the two sites and make a backup of the SD card!

            incogizmoundefined 1 Reply Last reply Reply Quote 0
            • incogizmoundefined
              incogizmo @nikker
              last edited by incogizmo

              @nikker Ahhhh sounds like the default rules were set to DENY, possibly during your first run through you set the default FORWARD rule to accept,
              You possibly ran something like iptables -P FORWARD ACCEPT or the ACCEPT rule you provided above.

              Anyway really good news hearing its all setup and running reliably. 🙂

              1 Reply Last reply Reply Quote 0
              • SupraGuyundefined
                SupraGuy
                last edited by

                This seems needlessly complicated, expensive, and troublesome.

                Why not just get a wireless bridge device, it's not much more than the cost of the micro-SD card for the Pi, let alone the cost of the Pi itself.

                https://www.amazon.com/NETGEAR-N300-Range-Extender-EX2700/dp/B00L0YLRUW/ref=sr_1_4?s=pc&ie=UTF8&qid=1544804805&sr=1-4&keywords=wireless+bridge

                Plug in the wireless bridge, plug the Duet Ethernet into it. Configure the wireless network once, and boom.

                Personally, I love the Raspberry Pi. It's a great little inexpensive PC for small automation tasks, but I feel that it's utterly wasted as just a bridge when there are dedicated devices which do the job frankly better for way less money.

                Lead screw driven printer, powered by Duet 2 Wifi
                MPCNC powered by Duet 2 Wifi
                CoreXY printer driven by Duet 3 6HC
                LowRider CNC powered by Duet 2 Wifi

                1 Reply Last reply Reply Quote 0
                • arnd13undefined
                  arnd13
                  last edited by arnd13

                  Hi,

                  the easiest way is to use a bridge. Something like this (small, enough bandwith):

                  https://www.amazon.de/Vonets-300Mbps-Router-Wireless-Repeater/dp/B0148NO58W/ref=sr_1_3?ie=UTF8&qid=1544824135&sr=8-3&keywords=vonets+var11n-300

                  Costs about 20 euros and can be powered over the 5 Volt pins of the duet.

                  I'm using it with my maestro and it's perfect.

                  1 Reply Last reply Reply Quote 0
                  • incogizmoundefined
                    incogizmo
                    last edited by

                    Whilst I totally agree simplicity is better, there are situations where it makes sense.
                    When you are already using the Pi for other things eg motioneye for remote monitoring / recording or octoprint etc.
                    I would prefer to minimize additional components.

                    1 Reply Last reply Reply Quote 0
                    • nikkerundefined
                      nikker
                      last edited by

                      All are great solutions to various scenarios... @incogizmo hit the nail on the head for my scenario, I am using something similar to motion eye to stream jpegs to DWC. I also have 5 RPI3s, about 10 USB Wifi adaptors and other little tid bits. I have a monoprice duplicator 6 with a Duet WiFi and love it. I just decided to give the Ethernet version a shot on a whim. Who knows, I may come up with other ideas where the RPI3 will come in handy.

                      1 Reply Last reply Reply Quote 0
                      • gtj0undefined
                        gtj0
                        last edited by

                        Here's another possible and much easier solution... use "socat" to bridge the ports...

                        Give the duet and the pi ethernet port static addresses say 10.0.0.2/24 and 10.0.0.1/24 respectively then run socat as follows...

                        socat \
                               TCP4-LISTEN:80,bind=<pi_wifi_addr>,reuseaddr,fork \
                               TCP4:10.0.0.2:80,bind=10.0.0.1
                        

                        Now any connection that comes in over wifi to port 80 will get forwarded to the duet's port 80.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Unless otherwise noted, all forum content is licensed under CC-BY-SA