@Edward,
I managed to get the network forwarding working. The problem is not that systemd
is broken, but our kernel defconfig
is missing some options to enable NAT and the demo image is missing a config option in systemd
itself to enable the use of NAT. I applied two patches:
In meta-toradex-bsp-common
:
diff --git a/recipes-kernel/linux/linux-toradex-mainline-git/defconfig b/recipes-kernel/linux/linux-toradex-mainline-git/defconfig
index 3c6bbc0..d86a5e9 100644
--- a/recipes-kernel/linux/linux-toradex-mainline-git/defconfig
+++ b/recipes-kernel/linux/linux-toradex-mainline-git/defconfig
@@ -59,6 +59,12 @@ CONFIG_INET=y
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
CONFIG_NETFILTER=y
+CONFIG_NF_CONNTRACK=y
+CONFIG_NF_TABLES=y
+CONFIG_IP_NF_IPTABLES=y
+CONFIG_IP_NF_FILTER=y
+CONFIG_IP_NF_NAT=y
+CONFIG_IP_NF_TARGET_MASQUERADE=y
CONFIG_BRIDGE=m
CONFIG_VLAN_8021Q=m
CONFIG_CAN=y
In meta-toradex-demos
:
diff --git a/recipes-core/systemd/systemd_%.bbappend b/recipes-core/systemd/systemd_%.bbappend
index 802daa2..0b22319 100644
--- a/recipes-core/systemd/systemd_%.bbappend
+++ b/recipes-core/systemd/systemd_%.bbappend
@@ -2,7 +2,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/systemd:"
SRC_URI += "file://rndis.network"
-PACKAGECONFIG:append = " networkd"
+PACKAGECONFIG:append = " networkd iptc"
PACKAGECONFIG[acl] = "-Dacl=true,-Dacl=false,acl"
If you rebuild with these patches you should be able to get the forwarding working with your config file. I don’t know if it’s necessary or not, but I also added IPMasquerade=yes
to mine:
root@colibri-imx6ull-06738043:~# cat /lib/systemd/network/hostapd-example.network
[Match]
Name=wlan0 uap0
WLANInterfaceType=ap
[Network]
Address=0.0.0.0/24
DHCPServer=yes
IPMasquerade=yes
IPForward=ipv4
The uap0 interface still has more than one IP address:
root@colibri-imx6ull-06738043:~# ip a show uap0
6: uap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether c0:e4:34:2f:d4:b7 brd ff:ff:ff:ff:ff:ff
inet 192.168.106.1/24 brd 192.168.106.255 scope global uap0
valid_lft forever preferred_lft forever
inet 192.168.15.1/24 brd 192.168.15.255 scope global uap0
valid_lft forever preferred_lft forever
inet6 fe80::c2e4:34ff:fe2f:d4b7/64 scope link
valid_lft forever preferred_lft forever
And my client received an IP address on the .15 network:
root@verdin-imx8mp-07330987:~# ip a show mlan0
6: mlan0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 34:6f:24:4f:56:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.15.227/24 brd 192.168.15.255 scope global mlan0
valid_lft forever preferred_lft forever
inet6 fe80::366f:24ff:fe4f:5623/64 scope link
valid_lft forever preferred_lft forever
And the routes are configured properly on the client side:
root@verdin-imx8mp-07330987:~# ip route show
default via 192.168.15.1 dev mlan0
1.1.1.1 via 192.168.15.1 dev mlan0
192.168.11.0/24 dev usb0 proto kernel scope link src 192.168.11.1
192.168.15.0/24 dev mlan0 proto kernel scope link src 192.168.15.227
192.168.15.1 dev mlan0 scope link
Please let me know if this works for you too.
Regards,
Rafael