raspap-webgui icon indicating copy to clipboard operation
raspap-webgui copied to clipboard

DHCP for eth0

Open arrmo opened this issue 6 years ago • 28 comments

Subject of the issue

My apologies in advance - this is more of a question than a bug ... at least for now ... LOL. I have checked the Wiki / FAQ, and can't seem to find this (may be me!), but - which side of the WAN / LAN router functionality is eth0 on? I'd like it to be on the LAN side - meaning => WAN = WiFi (wlan0), providing router functionality to WiFi (uap0) and wired ethernet (eth0). Is this possible? And I guess, in the end uap0 and eth0 are bridged, both providing DHCP to LAN clients, right?

Your environment

  • Raspberry Pi hardware (examples: Pi 3 Model B, Pi Zero W)
    Pi 3 Model B+

  • Raspbian version (examples: Stretch Lite, Stretch Desktop) Stretch Desktop

  • Followed the project prerequisites? (Y/N) Y

  • Checked the project FAQ? (Y/N) Y

  • RaspAP Quick Install or Manual setup? Quick Install

  • Using default configuration? (Y/N) N

  • Simultaneous AP and managed mode? (Y/N) Y

  • Other software or services running with RaspAP?

Steps to reproduce

As above, not sure it's an issue, until I can test it. Trying to understand it first.

Expected behavior

As above.

Actual behavior

TBD

arrmo avatar Apr 29 '19 21:04 arrmo

I'm also trying to figure out how to set this up.

voney avatar May 02 '19 23:05 voney

I'm also interested in this.

My use case is as follows:

I work away from home a lot, and use Raspap-Webgui as the bridge between my linux laptop and the hotel WiFi because (for some reason) this works better than connecting my laptop to the wifi directly.

I'm in the process of building out a "mobile IoT Lab" to take with me, and as part of this I'd like to have one pi running Raspap, in "dual-mode" (AP and Client), with DNSMasq running on eth0 and lo/uap0.

This would enable me to attach a switch to the ethernet port, and then share the wifi between the nodes in the "mobile lab" as well as wifi clients like my laptop.

I'm assuming that changes would need to be made that gave eth0 a static IP, and then reconfigured DNSMasq to listen on that interface as well, but I'm not 100% sure!

Thanks for an excellent product by the way, it's really seamless when I arrive at a hotel these days as a result!

proffalken avatar Jun 11 '19 19:06 proffalken

im also interested

manolosolalinde avatar Jul 12 '19 03:07 manolosolalinde

me to :)

HebusJon avatar Jul 15 '19 17:07 HebusJon

I have a fix for this, review my git page and wifi gateway page. https://github.com/olewsaa/Yacht-computer/tree/master/wifi2wifi/web-version https://sites.google.com/site/olewsaa/yacht-server/raspberry-pi-as-a-router-gateway

It's working nicely. It is however sensitive to any web-gui clicks on save buttons.

It would be nice if this could be part of the normal setup, e.g. buttons or menu in the web-gui.

olewsaa avatar Jan 28 '20 08:01 olewsaa

there's currently no ui for this but recently #501 was merged. you can put custom configuration without fears of it being overwritten by raspap into /etc/dnsmasq.d.

in your cases the following should work.

# /etc/dnsmasq.d/eth0.conf

interface=eth0
dhcp-range=eth0,172.24.1.50,172.24.1.150,12h

adjust your ip ranges according to your eth0 address space. something like this may also work with the dhcp-host option. consult man dnsmasq.

more info:

  • https://jackywu.ca/enable-multiple-dhcp-range-for-multiple-nic-with-dnsmasq
  • https://stackoverflow.com/q/9326438

glaszig avatar Feb 29 '20 21:02 glaszig

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 29 '20 22:04 stale[bot]

Good to see that this issue is Open again. I successed to have something working, but with my poor knowledge, I'm almost sure it is not well implemented and there will probably bugs in IP traffics :/.

What I did : I modified 2 files.

  • /etc/dhcpcd.conf

I added an eth0 par, that was totally absent.

# RaspAP eth0 configuration
interface eth0
static ip_address=192.168.0.1/24
static domain_name_server=9.9.9.9 1.1.1.1
  • /etc/dnsmasq.d/090_raspap.conf Under the existing wlan0 DHCP configuration, I set the eth0 DHCP server range there.
interface=eth0
dhcp-range=192.168.0.50,192.168.0.255,255.255.255.0,12h

It's actually working for 20 hours. But I have some slow traffic sometimes (I'm not sure if it's a ISP network slow problem, or if it is due to my modifications.)

And it would be nice to bridge eth0 and wlan0 (br-lan ?) and make only one DHCP server for br-lan.

If someone can tell me if what I did is good, or better, if he know how I can do the bridge as describe above.

And of course even better, @billz, you could make it easy to set-up on the Raspap Web-GUI ?? It would be so GREAT.

Thank you in advance for the great help.

mathojojo avatar Apr 30 '20 16:04 mathojojo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 30 '20 13:06 stale[bot]

Hi,

I tried doing what mathojojo did. But when I connect a device on eth1, I am not able to connect any devices on wlan0 since they cant get an ip address. Do I need to have different ranges for eth1 and wlan0 or should I bridge them? If so whats the best/easiest way?

Thanks for all the work.

annunity avatar Jul 28 '20 08:07 annunity

This has been a popular request so I've made time to work on it. Follow the linked PR for progress updates.

Untitled

billz avatar Nov 06 '20 09:11 billz

Testing with an OrangePi3 (client) connected to RaspAP on eth0 with an external adapter on wlan1:

dhcp-eth0

billz avatar Nov 09 '20 17:11 billz

Some notes:

  1. A static IP address must first be configured for eth0 in Networking > eth0.
  2. The DHCP Server settings page will detect a missing eth0 configuration and provide a message to this effect.
  3. Enable the DHCP for eth0 toggle, configure the eth0 interface and Save settings.
  4. Be sure to define a subnet for eth0 different from the AP interface (192.168.0.1/24 is used here).
  5. Reboot your device.
  6. Connect a second device on eth0 (an orangepi3 is used here).
  7. Monitor DHCP logs.
dnsmasq-dhcp[909]: DHCP, IP range 192.168.0.50 -- 192.168.0.255, lease time 12h
dnsmasq-dhcp[909]: DHCP packet received on eth0 which has no address
dnsmasq-dhcp[909]: DHCPDISCOVER(eth0) 192.168.0.253 02:▒▒▒▒▒▒▒▒▒▒▒
dnsmasq-dhcp[909]: DHCPOFFER(eth0) 192.168.0.253 02:▒▒▒▒▒▒▒▒▒▒▒
dnsmasq-dhcp[909]: DHCPREQUEST(eth0) 192.168.0.253 02:▒▒▒▒▒▒▒▒▒▒▒
dnsmasq-dhcp[909]: DHCPACK(eth0) 192.168.0.253 02:▒▒▒▒▒▒▒▒▒▒▒ orangepi3

At the moment the toggle lives on the Advanced tab while the interface is configured on the Server settings tab. Probably better UX to move the toggle to the latter.

billz avatar Nov 12 '20 10:11 billz

@billz, any chance to make a choice between eth0 and eth1 or other eths in webgui?

darnokb avatar Nov 12 '20 16:11 darnokb

@darnokb yes definitely. already thinking along those lines ;) I started with eth0 as a POC.

billz avatar Nov 12 '20 16:11 billz

What began as a simple enhancement is turning into a complete refactoring of dhcp/dnsmasq 😅 Good things, though.

  1. DHCP option toggle for all interfaces
  2. Server settings page is now ajaxified (big UX improvement)
  3. Better & more consistent use of /etc/dnsmasq.d
Screen Shot 2020-11-16 at 7 35 51 PM

billz avatar Nov 16 '20 18:11 billz

Yeah. I have been trying to figure this out recently. I think controlling from the DHCP Server page is the right way to go.

Would it be possible to listen to eth(n) and if another DHCP service is detected disable the eth(n) DHCP on RaspAp? This way plugging into my local LAN to service the Pi would just work. Especially when I miss configure wlan0 and get locked out of RaspAp like I did last week.

RobertDuncan42 avatar Nov 17 '20 17:11 RobertDuncan42

@RobertDuncan42 I like the idea of detecting services on eth(n) and auto configuring it.

billz avatar Nov 17 '20 21:11 billz

As the project has evolved more control over DHCP has moved from the Networking tabs to the DHCP Server UI. Interface .ini files are managed separately in /etc/raspap/networking/ and written to /etc/dhcpcd.conf. A static IP must be defined before enabling DHCP on a given interface, and this is performed on a completely different UI in Networking, which then must be saved and applied. Many of the inputs in these two UIs are also redundant and can be confusing to the user. This UX could obviously be improved.

For sanity, I propose migrating control over the few remaining settings (fallback to static, static IP, interface metric, etc) to the DHCP server UI and deprecating the Networking interface tabs.

Nice thing about this approach is it a) centralizes everything DHCP-related in one area, and b) creates a space for future network-related enhancements (@zbchristian's networking > mobile data UI, IP routing table, QoS, etc).

billz avatar Nov 24 '20 10:11 billz

All network configuration on one panel, possible multiple tabs, makes sense. But it should be called Network Configuration, Not DHCP Server. So deprecate Networking and rename DHCP to Networking.

RobertDuncan42 avatar Nov 25 '20 00:11 RobertDuncan42

I'm new here, but just love the work being done with RaspAP. I have read a lot of documentation, some I understood, a lot a didn't, but wanted to ask a question that relates somewhat to the above discussion.

I would like to plug in an additional WiFi Access Point (probably a Unifi AP Pro) to the eth port on the Pi4, to extend or create a new WiFI SSID (or simply turn off the AP on the Pi4 and only use the Unifi AP).

If I simply plugged in the Unifi AP to the Pi4 eth port, is there any configuration I would have to do within RaspAP? For example, enable dhcp on eth so that clients connecting via Unifi AP would be provided with an IP?

Thanks and apologies in advance if this has been asked before or is so simple, I can't see the wood for the trees!

OzzieGaz avatar Nov 25 '20 02:11 OzzieGaz

@RobertDuncan42 I considered this, although the current DHCP server panel has management of static DHCP leases, active leases, upstream DHCP servers, etc. Could also be a place for MAC address filtering, which is often requested. Thinking of how to best group these settings in a way that makes sense to the end user.

billz avatar Nov 25 '20 09:11 billz

Would this work over a VPN connection too? I would like to use this so that any device connected over ethernet can have its traffic routed over a VPN as specified in the VPN Config page, just as can be down now over wifi.

ajkblue avatar Dec 05 '20 22:12 ajkblue

@ajkblue the default behavior for VPN is to route traffic between tun0 and wlan0, but an option could be added to make the interface selectable.

billz avatar Dec 09 '20 15:12 billz

@billz It would be great if there would be an option so the eth0 interface could be used to route VPN traffic as well from either wlan0 or wlan1. This would be useful to use a VPN connection on devices where accessing the router isn't an option to plug in directly and the devices themselves don't have wifi cards. I hope that wouldn't be too difficult to implement.

ajkblue avatar Dec 10 '20 19:12 ajkblue

@ajkblue sounds like a good 'ideas' topic for Discussions. let's keep the focus here on the issue.

billz avatar Dec 10 '20 21:12 billz

The associated PR has been wrapped up with several enhancements + other fixes into pre-release v2.6-beta https://github.com/billz/raspap-webgui/releases/tag/2.6-beta

Beta testers are welcome. See the release notes for info.

billz avatar Dec 26 '20 11:12 billz

This feature is now part of the version 2.6 general release.

billz avatar Jan 25 '21 17:01 billz

Thanks to everyone for their input in this issue. For those on this thread that are interested in the related WLAN Routing feature, add a quick reply and I'll send you an invite to the Insiders repo.

billz avatar Feb 08 '24 08:02 billz

Thanks to everyone for their input in this issue. For those on this thread that are interested in the related WLAN Routing feature, add a quick reply and I'll send you an invite to the Insiders repo.

Hi, can I try the WLAN routing feature? thank you

lnguyen234 avatar Apr 05 '24 17:04 lnguyen234