问题
I'm creating an embedded device (based on an RPi) which will connect to the local network. I would like this device to be able to configure the device via a web page (much the same as many routers).
I would like the user to type [http://my-device-config] (or some other fixed address) into the web browser and be sent to the config page without having to know the ip address of the device.
The steps the user would take are as follows:
- User plugs device into network/turns device on.
- User types 'config' address into browser and is taken to config page. (No network configuration/ip look up etc. required)
From research I believe Avahi (/Bonjour/Zeroconf) can make this possible, however I am unclear on the following points:
- Is Avahi the simplest way to do this?
- Will it work if my device is he only device on the local network running Avahi? (ie. no requirement for installing software on any other computers on the network).
- Will it work across platforms (osx/*nix/windows)?
- Will it work across browsers?
Thanks for any help/insight.
回答1:
- It is the simplest and the most interoperable, but not sufficient for your case.
- Short answer is NO. Longer answer - usually Apple stuff comes with them on, Linux often comes with Avahin On, Windows world won't move finger unless you configure it so. But alternatives are even worse.
- In way, yes it will. Avahi is open-source implementation (read linux/bsd world), while Apple stuff has own proprietary thing (they started whole zeroconf story), and Windows world has own zeroconf implementation. You will also need that nobody uses .local domain within particular local network - there is certain non-zero probability that company-owned networks will have .local already populated by microsoft networking.
- Uhm, theoretically yes - Avahi is essentially low-scale DNS with few other low-level things made up. So if your system has DNS resolver and it can have plugin which pulls underneath Avahi client/server hooks - then browser should work Ok. For last few years I didn't have side effects with it on Linux machines with Firefox and other equipment in net (e.g. configuring printer via avahi-pointed web server on printer). Address for them looks like http://my-device.local or http://thatprinterfromfloor5.local i.e. whatever.local.
来源:https://stackoverflow.com/questions/17005136/connect-to-website-on-local-network-without-knowing-ip