hnetd
hnetd copied to clipboard
HomeNet-CP implementation (WIP)
hnetd - a home network configuration daemon
** Abstract **
hnetd is a networking daemon to automatically manage address assignment, routing, DNS, SD and border firewalling in home networks running it. It implements the Home Networking Control protocol as specified in http://tools.ietf.org/html/draft-ietf-homenet-hncp
hnetd is designed to run on generic Linux-based routers.
** License **
This project was originally licensed under the GNU General Public License 2. With the agreement of all copyright holders responsible for contributions in this branch, the license was changed to Apache 2.0 effective April 3rd 2016.
** Features **
-
State synchronization between routers a) link-local multicast transmission b) unicast fallback for bulk synchronization c) collision and conflict detection and resolving
-
Prefix distribution and allocation a) IPv6 prefix delegation b) IPv4 prefix allocation
-
Routing setup a) selection of a shared routing protocol b) fallback mechanism to setup routes autonomously
-
Dynamic border-detection for IPv4 and IPv6 a) on-demand firewall reconfiguration b) on-demand RA/DHCP/DHCPv6 server configuration c) integration of fixed external connections (e.g. PPP, 6rd, ...)
-
Sharing of DNS and Service Discovery configuration a) Local DNS configuration b) mDNS / DNS-SD hybrid proxy configuration
** Compiling **
hnetd depends on the following libraries:
- json-c: https://github.com/json-c/json-c
- libubox: https://git.openwrt.org/project/libubox.git
- libubus (OpenWrt only): https://git.openwrt.org/project/ubus.git
hnetd uses the following auxiliary tools (replacable):
- odhcp6c (DHCPv6 client): https://github.com/sbyx/odhcp6c
- odhcpd (RA/DHCP/DHCPv6 server): https://github.com/sbyx/odhcpd
- ohybridproxy (mDNS proxy, optional): https://github.com/sbyx/ohybridproxy
- minimalist-pcproxy (PCP proxy, optional): https://github.com/fingon/minimalist-pcproxy
- udhcpc (DHCP client): http://busybox.net
hnetd uses cmake:
- To prepare a Makefile use: "cmake . -DCMAKE_INSTALL_PREFIX=/usr"
- To build / install use: "make" / "make install" afterwards.
- To build DEB or RPM packages use: "make package" afterwards.
Note: The script "build-generic.sh" can aid in building hnet and its dependencies and tools on Debian/Ubuntu/Mint and related Linux distributions.
** OpenWrt Firmware Integration **
hnetd and ohybridproxy can be built from the openwrt-routing feed. Use: ./scripts/feeds update ./scripts/feeds install hnetd ohybridproxy
and select both packets in "make menuconfig" under "Network" and the submenu "IP Addresses and Names". Snapshot packages might be available in the OpenWrt daily snapshots folder: http://downloads.openwrt.org/snapshots/trunk/
To use hnetd on an interface add a config section in /etc/config/network, e.g.
config interface homenet0 option ifname eth0 option proto hnet
or select the protocol "Automatic Homenet (HNCP)" in the web interface.
IMPORTANT: Remove or comment out other config sections running DHCP or DHCPv6 clients on the interfaces your run hnet on. Additional static configuration section may be kept for debugging purposes.
WARNING: Do NOT set the proto of either the “lan”, “wan” or “wan6” interface to hnet directly. Always rename your interfaces to a different name, e.g. homenet0 or homenet1.
** Generic Firmware Integration **
hnetd can be integrated into generic Linux router firmwares with recent 3.10.x or later kernels. The scripts that need to be adapted for the integration can be found in the folder "generic".
Copy the scripts hnet-backend and hnetd-routing to /usr/sbin/ and adapt them if needed. The symlinks hnet-client, hnet-ifup and hnet-ifdown should be preserved as well.
Copy the scripts dhcp.script and dhcpv6.script to /usr/share/hnetd and adapt them if needed.
If you are using odhcpd as DHCP/DHCPv6/RA server start it as a daemon. Afterwards run hnetd with appropriate parameters.
Once both services are running, you can use the hnet CLI tools:
hnet-ifup [-c category] [-a] [-d] [-u] [-p prefix] [-l id[/idmask]]
[-i id/idmask [filter-prefix]] [-m ip6_plen] [-k trickle_k]
[-P ping_interval] [-4 global-IPv4-address] [-6 delegated prefix]
[-D dns-server]
hnet-ifdown
hnet-dump dumps you (most of) the current state of the network as JSON.