examples/gnrc_border_router: add optional DHCPv6 support
This commit is contained in:
parent
b929d013d8
commit
a0b0724f76
10
examples/gnrc_border_router/Kconfig
Normal file
10
examples/gnrc_border_router/Kconfig
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
if MODULE_ETHOS
|
||||||
|
config GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE
|
||||||
|
default y
|
||||||
|
depends on MODULE_GNRC_DHCPV6_CLIENT_6LBR && KCONFIG_MODULE_GNRC_DHCPV6
|
||||||
|
config GNRC_NETIF_IPV6_ADDRS_NUMOF
|
||||||
|
# CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1 requires one more address
|
||||||
|
# for `fe80::2`.
|
||||||
|
default 3
|
||||||
|
depends on KCONFIG_MODULE_GNRC_NETIF
|
||||||
|
endif # MODULE_ETHOS
|
||||||
@ -50,8 +50,15 @@ USEMODULE += shell
|
|||||||
USEMODULE += shell_commands
|
USEMODULE += shell_commands
|
||||||
USEMODULE += ps
|
USEMODULE += ps
|
||||||
|
|
||||||
# include UHCP client
|
USE_DHCPV6 ?= 0
|
||||||
USEMODULE += gnrc_uhcpc
|
|
||||||
|
ifeq (1,$(USE_DHCPV6))
|
||||||
|
# include DHCPv6 client for 6LoWPAN border router
|
||||||
|
USEMODULE += gnrc_dhcpv6_client_6lbr
|
||||||
|
else
|
||||||
|
# include UHCP client
|
||||||
|
USEMODULE += gnrc_uhcpc
|
||||||
|
endif
|
||||||
|
|
||||||
# Optionally include RPL as a routing protocol. When includede gnrc_uhcpc will
|
# Optionally include RPL as a routing protocol. When includede gnrc_uhcpc will
|
||||||
# configure the node as a RPL DODAG root when receiving a prefix.
|
# configure the node as a RPL DODAG root when receiving a prefix.
|
||||||
@ -68,24 +75,45 @@ TAP ?= tap0
|
|||||||
IPV6_PREFIX ?= 2001:db8::/64
|
IPV6_PREFIX ?= 2001:db8::/64
|
||||||
|
|
||||||
ifeq (native,$(BOARD))
|
ifeq (native,$(BOARD))
|
||||||
|
ifneq (1,$(USE_DHCPV6))
|
||||||
TERMDEPS += uhcpd-daemon
|
TERMDEPS += uhcpd-daemon
|
||||||
|
|
||||||
.PHONY: uhcpd-daemon
|
.PHONY: uhcpd-daemon
|
||||||
|
|
||||||
uhcpd-daemon: host-tools
|
uhcpd-daemon: host-tools
|
||||||
$(RIOTTOOLS)/uhcpd/bin/uhcpd $(TAP) $(IPV6_PREFIX) &
|
$(RIOTTOOLS)/uhcpd/bin/uhcpd $(TAP) $(IPV6_PREFIX) &
|
||||||
|
endif # USE_DHCPV6
|
||||||
else
|
else
|
||||||
# We override the `make term` command to use ethos
|
# We override the `make term` command to use ethos
|
||||||
|
ifeq (1,$(USE_DHCPV6))
|
||||||
|
TERMPROG ?= sudo $(RIOTTOOLS)/ethos/ethos
|
||||||
|
TERMFLAGS ?= $(TAP) $(PORT) $(ETHOS_BAUDRATE)
|
||||||
|
else # USE_DHCPV6
|
||||||
TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh
|
TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh
|
||||||
TERMFLAGS ?= $(PORT) $(TAP) $(IPV6_PREFIX)
|
TERMFLAGS ?= $(PORT) $(TAP) $(IPV6_PREFIX)
|
||||||
|
endif
|
||||||
|
|
||||||
|
STATIC_ROUTES ?= 1
|
||||||
# We depend on the ethos host tools to run the border router, we build them
|
# We depend on the ethos host tools to run the border router, we build them
|
||||||
# if necessary
|
# if necessary
|
||||||
TERMDEPS += host-tools
|
TERMDEPS += host-tools
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# As there is an 'Kconfig' we want to explicitly disable Kconfig by setting
|
||||||
|
# the variable to empty
|
||||||
|
SHOULD_RUN_KCONFIG ?=
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|
||||||
|
ifndef CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE
|
||||||
|
ifeq (1,$(STATIC_ROUTES))
|
||||||
|
CFLAGS += -DCONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1
|
||||||
|
# CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1 requires one more address for
|
||||||
|
# `fe80::2`.
|
||||||
|
CFLAGS += -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=3
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: host-tools
|
.PHONY: host-tools
|
||||||
|
|
||||||
host-tools:
|
host-tools:
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# gnrc_border_router using automatic configuration
|
# gnrc_border_router using automatic configuration
|
||||||
This setup uses a single serial interface, ethos (Ethernet Over Serial)
|
This setup uses a single serial interface, ethos (Ethernet Over Serial)
|
||||||
and UHCP (micro Host Configuration Protocol).
|
and UHCP (micro Host Configuration Protocol) (using DHCPv6 alternatively is also
|
||||||
|
possible).
|
||||||
Ethos multiplexes serial data to separate ethernet packets from shell commands.
|
Ethos multiplexes serial data to separate ethernet packets from shell commands.
|
||||||
UHCP is in charge of configuring the wireless interface prefix
|
UHCP is in charge of configuring the wireless interface prefix
|
||||||
and routes on the BR.
|
and routes on the BR.
|
||||||
@ -11,6 +12,34 @@ The script `start_network.sh` enables a *ready-to-use* BR in only one command.
|
|||||||
This functionality works only on Linux machines.
|
This functionality works only on Linux machines.
|
||||||
Mac OSX support will be added in the future (lack of native `tap` interface).
|
Mac OSX support will be added in the future (lack of native `tap` interface).
|
||||||
|
|
||||||
|
If you want to use DHCPv6, you also need a DHCPv6 server configured for prefix
|
||||||
|
delegation from the interface facing the border router. With the [KEA] DHCPv6
|
||||||
|
server e.g. you can use the following configuration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"Dhcp6":
|
||||||
|
{
|
||||||
|
"interfaces-config": {
|
||||||
|
"interfaces": [ "tap0" ]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
"subnet6": [
|
||||||
|
{ "interface": "tap0",
|
||||||
|
"subnet": "2001:db8::/16",
|
||||||
|
"pd-pools": [ { "prefix": "2001:db8::",
|
||||||
|
"prefix-len": 16,
|
||||||
|
"delegated-len": 64 } ] },
|
||||||
|
]
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that when working with TAP interfaces you might need to restart your DHCPv6
|
||||||
|
server once *after* you started the border router application (see below), since
|
||||||
|
Linux might not recognize the interface as connected.
|
||||||
|
|
||||||
|
[KEA]: https://kea.isc.org/
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
First, you need to compile `ethos`.
|
First, you need to compile `ethos`.
|
||||||
Go to `/dist/tools/ethos` and type:
|
Go to `/dist/tools/ethos` and type:
|
||||||
@ -32,6 +61,13 @@ Afterwards, proceed to compile and flash `gnrc_border_router` to your board:
|
|||||||
make clean all flash
|
make clean all flash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to use DHCPv6 instead of UHCP compile with the environment variable
|
||||||
|
`USE_DHCPV6` set to 1
|
||||||
|
|
||||||
|
```bash
|
||||||
|
USE_DHCPV6=1 make clean all flash
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
Start the `start_network.sh` script by doing on `dist/tools/ethos`:
|
Start the `start_network.sh` script by doing on `dist/tools/ethos`:
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user