pfSense Support Subscription

Author Topic: rpi zero usb ethernet to pfsense  (Read 437 times)

0 Members and 1 Guest are viewing this topic.

Offline xbipin

  • Hero Member
  • *****
  • Posts: 1582
  • Karma: +4/-0
    • View Profile
rpi zero usb ethernet to pfsense
« on: July 16, 2017, 07:00:40 am »
raspberry pi zero has a USB otg port and if configured properly can work as a RNDISEthernet Gadget when the module is loaded, my question is i have connected it to pfsense and it displays as a usb Ethernet gadget and i can assign that in interfaces also and that works fine but my aim is to configure it such that pfsense sees it as a workstation so can get a ip from dhcp on the lan nic but the only difference is this rpi wont connect using a Ethernet jack but using usb directly to pfsense so is this possible?

like how we can share the internet connection from windows machine to this USB Ethernet adapter can we do the same in pfsense coz i find usb Ethernet speeds to be much better than connecting a wifi dongle to the rpi zero

Online stephenw10

  • Administrator
  • Hero Member
  • *****
  • Posts: 11494
  • Karma: +428/-13
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #1 on: July 16, 2017, 03:46:47 pm »
Yes that is possible.

You can assign the RNDIS interface and then enable it and enable a DHCP server on it to give the Pi an IP.

You could try bridging the interface to LAN if you want it on the same subnet. You might have to add rules to pass the DHCP requests.

The problem with doing this is that pfSense is not setup to have one of its interfaces disappear during normal run-time. If the Pi is disconnected or the goes to sleep or USB/Ethernet driver crashes pfSense may behave unpredictably. It will certainly have a problem as shipped if you boot it without the Pi attached. It will dump you at the interfaces assign screen on the console as it will have an invalid assignment in the config. It's possible to exclude ue NICs from the boot check but its a hacky workaround and still may lead to unpredictable behaviour.

Steve

Offline xbipin

  • Hero Member
  • *****
  • Posts: 1582
  • Karma: +4/-0
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #2 on: July 17, 2017, 12:41:47 am »
well i did assign a interface to the RNDIS gadget and bridged it to LAN but the problem u mentioned stands plus the RNDIS mac id keeps changing so my plan was to find a way to not use the RNDIS gadget as a interface but using some software like a client nic but over USB so pfsense can see it as a workstation on the LAN similar to how u plug a PC to the LAN nic, no idea if this is even possible.

Online stephenw10

  • Administrator
  • Hero Member
  • *****
  • Posts: 11494
  • Karma: +428/-13
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #3 on: July 17, 2017, 06:36:18 am »
What you're describing is exactly what it's doing. The Pi is running a driver that makes it look like a USB Ethernet device.

You can spoof the MAC address in pfSense to get around the fake MAC generated by the driver whcih, as you say, changes.

You can add the ue interface type to the list here to prevent it being checked at boot if that's the issue you're seeing: https://github.com/pfsense/pfsense/blob/master/src/etc/inc/util.inc#L2156

Potentially you might try running a PPPoE connection there where the changing MAC wouldn't matter. You woul still need to start the PPPoE server on the USB ethernet device though and that may not be present. It may get past some of the issues though.

Otherwise you might try having it appear as a serial port and running a PPP link. No idea if that's possible with the Pi.  ;)

Steve

Offline xbipin

  • Hero Member
  • *****
  • Posts: 1582
  • Karma: +4/-0
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #4 on: July 17, 2017, 06:56:33 am »
actually there r 2 parts to this, it generates 2 mac ids, one is host mac id and second is the rpi device mac id so im guessing it creates like a virtual wire link between the 2 using the USB cable.

yes i understand it creates like a USB Ethernet device and i managed to get it to use fixed mac ids for host and dev mac ids so thats solved, my point was trying to avoid it creating a host mac id which would appear to pfsense, probably something i can run on pfsense which avoids to create an interface on pfsense and then deal with dhcp/bridge on it.

what i was looking for was run some emulation on pfsense etc where it can use the RDNIS from rpi and route internet to the rpi through it but to pfsense it appears as if the traffic is coming through its LAN nic.

the rpi zero will be powered through the usb port on pfsense so chances r less that the rpi will be powered off at all, there could be crashes but i tried with a PC for days and it works without any issues

Online stephenw10

  • Administrator
  • Hero Member
  • *****
  • Posts: 11494
  • Karma: +428/-13
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #5 on: July 17, 2017, 07:19:18 am »
There is no way to do that I know of.

pfSense can only route traffic to interfaces it knows about and that's mostly Ethernet. If you're not using Ethernet then it has to appear as some other interface type such as PPP or PPPoE.
That's the only way to avoid using the rndis adapter I can imagine.

It looks like the Pi Zero can appear as a virtual com port also so you could potentially run some PPP connection across it. pfSense can cope with vanishing com ports far better, that's how 3g/4g modems appear.

Steve

Offline xbipin

  • Hero Member
  • *****
  • Posts: 1582
  • Karma: +4/-0
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #6 on: July 17, 2017, 07:41:21 am »
well like how pfsense generates and routes it own localhost traffic if some how we can achieve this then it would be possible but lets see what i find or else having to create interfaces is the only option i guess

Online stephenw10

  • Administrator
  • Hero Member
  • *****
  • Posts: 11494
  • Karma: +428/-13
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #7 on: July 17, 2017, 08:38:54 am »
Internal routing between processes etc is very different to over USB.

I honestly think your best bet here is some varient of PPP connection unless you want to hack around with the code to make the virtual Ethernet connection work as you need it to.

It can work. You get the exactly the same deal with a tethered phone for example. There are a few threads detailing that for iphone and Android.

Steve

Offline xbipin

  • Hero Member
  • *****
  • Posts: 1582
  • Karma: +4/-0
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #8 on: July 17, 2017, 10:27:58 am »
even if i use a ppp or serial connection etc i still need to initially create a interface in pfsense right? rpi can also emulate serial so in that case also a virtual com port will appear in pfsense to which i need to assign a interface then bridge to lan.

usb Ethernet mode would be better i guess compared to serial

Offline xbipin

  • Hero Member
  • *****
  • Posts: 1582
  • Karma: +4/-0
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #9 on: July 17, 2017, 10:31:07 am »
the last option being connecting a wifi dongle to the rpi but i have tried that and it lags thats y i was trying this USB Ethernet method

Online stephenw10

  • Administrator
  • Hero Member
  • *****
  • Posts: 11494
  • Karma: +428/-13
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #10 on: July 17, 2017, 11:36:09 am »
You could potentially create a PPP connection via the virtual com port and then assign that. pfSense can cope with that disappearing since that's how many (now older) 3g devices appear.

A real USB/Ethernet adapter connected to the Pi would probably be better than USB wifi or emulated USB ethernet.

Steve

Offline johnpoz

  • Hero Member
  • *****
  • Posts: 12877
  • Karma: +1130/-137
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #11 on: July 17, 2017, 12:04:56 pm »
Why don't you just buy a dongle for the pi zero.  I don't recall the one I got off the top of my head for mine.. But will take a look at it when get home.. I currently do not have it connected to anything or would look remotely.. But my zero is currently sitting in a cup on my desk at home ;)  I needed its sd card for something else and have not gotten around to replacing and bringing it back up ;)

I will look in my my amazon orders to see if I can find out... BRB

edit: found it
https://smile.amazon.com/gp/product/B00RM3KXAU
Plugable USB 2.0 OTG Micro-B to 10/100 Fast Ethernet Adapter for Windows Tablets & Raspberry Pi Zero (ASIX AX88772A chipset)
« Last Edit: July 17, 2017, 12:08:51 pm by johnpoz »
- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- If I have helped you and want to help back, https://www.freebsdfoundation.org/donate/
- Please don't PM me for personal help, info you don't want public sure. Link to thread you would like me to look at ok, etc.
1x SG-2440 2.3.3_p1 (work)
1x 2.4.0-BETA Jul 21 00:23:55 VM running on esxi 6.5 (home)

Online stephenw10

  • Administrator
  • Hero Member
  • *****
  • Posts: 11494
  • Karma: +428/-13
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #12 on: July 17, 2017, 12:57:40 pm »
Yup. That. ^

I mean it's probably less fun.... but it will work much better!

Steve

Offline xbipin

  • Hero Member
  • *****
  • Posts: 1582
  • Karma: +4/-0
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #13 on: July 17, 2017, 03:13:28 pm »
Well to my testing the emulated Ethernet is very reliable so far, gives good speeds compared to a actual USB Ethernet adapter, btw I have a rpi zero w with built-in Wi-Fi but the drivers are a bit broken on it and I have reported it to the devs so till they fix I was trying this fun thing. The wifi drivers for the built-in Wi-Fi chip give inconsistent ping and network speeds and I need to run freeswitch on this for a project, a USB wifi dongle performs much better but I wanted to try this emulated Ethernet and it's good and gives almost no lag in calls through freeswitch.

Offline johnpoz

  • Hero Member
  • *****
  • Posts: 12877
  • Karma: +1130/-137
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: rpi zero usb ethernet to pfsense
« Reply #14 on: July 17, 2017, 03:58:16 pm »
Sounds great - could you provide some sort of guide or howto on how you got this up and running.. Be willing to give it a go on my pi zero..
- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- If I have helped you and want to help back, https://www.freebsdfoundation.org/donate/
- Please don't PM me for personal help, info you don't want public sure. Link to thread you would like me to look at ok, etc.
1x SG-2440 2.3.3_p1 (work)
1x 2.4.0-BETA Jul 21 00:23:55 VM running on esxi 6.5 (home)