WLAN is not as stable as a wired network connections, there are connections drops sometimes. Please consider using a wired network connection.
For technical reasons, it is not possible to create a linux network bridge using a WLAN interface. Because of that, you need a bridge without a physical interface and to use port forwading to access the virtual CCU. To configure that, you need to do the following steps. Do not change the IP adresses 192.168.253.x in the commands.
-
Configure Interfaces
sudo apt install bridge-utils sudo bash -c 'cat << EOT > /etc/network/interfaces source-directory /etc/network/interfaces.d auto lo iface lo inet loopback auto wlan0 iface wlan0 inet dhcp wpa-ssid <PUT_YOUR_SSID_HERE> wpa-psk <PUT_YOUR_WLAN_KEY_HERE> auto br0 iface br0 inet static bridge_ports none bridge_fd 0 address 192.168.253.1 netmask 255.255.255.0 EOT'
or via netplan (Ubuntu > 18.04):
sudo apt install bridge-utils sudo bash -c 'cat << EOT > /etc/netplan/50-cloud-init.yaml network: ethernets: eth0: dhcp4: true optional: true version: 2 wifis: wlan0: access-points: <PUT_YOUR_SSID_HERE>: password: <PUT_YOUR_WLAN_KEY_HERE> dhcp4: true optional: true bridges: br0: addresses: [192.168.253.1/24] parameters: stp: false forward-delay: 0 EOT'
-
Configure (private) static IP for CCU (this needs to be done after each restore, too) (If you are using piVCCU3, please you the path /var/lib/piVCCU3 instead of /var/lib/piVCCU)
sudo systemctl stop pivccu sudo bash -c 'cat << EOT > /var/lib/piVCCU/userfs/etc/config/netconfig HOSTNAME=homematic-ccu2 MODE=MANUAL CURRENT_IP=192.168.253.2 CURRENT_NETMASK=255.255.255.0 CURRENT_GATEWAY=192.168.253.1 CURRENT_NAMESERVER1=8.8.4.4 CURRENT_NAMESERVER2=8.8.8.8 IP=192.168.253.2 NETMASK=255.255.255.0 GATEWAY=192.168.253.1 NAMESERVER1=8.8.4.4 NAMESERVER2=8.8.8.8 CRYPT=0 EOT'
-
Add IF UP Hook for port forwarding
sudo bash -c 'cat << EOT > /etc/network/if-up.d/pivccu #!/bin/sh HOST_IF=wlan0 BRIDGE=br0 HOST_IP=192.168.253.1 CCU_IP=192.168.253.2 if [ "\$IFACE" = "\$BRIDGE" ]; then echo 1 > /proc/sys/net/ipv4/ip_forward iptables -A FORWARD -i \$IFACE -s \$HOST_IP/24 -m conntrack --ctstate NEW -j ACCEPT iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT -o \$BRIDGE iptables -A POSTROUTING -t nat -j MASQUERADE -s \$HOST_IP/24 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 80 -j DNAT --to-destination \$CCU_IP:80 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 1999 -j DNAT --to-destination \$CCU_IP:1999 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 2000 -j DNAT --to-destination \$CCU_IP:2000 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 2001 -j DNAT --to-destination \$CCU_IP:2001 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 2002 -j DNAT --to-destination \$CCU_IP:2002 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 2010 -j DNAT --to-destination \$CCU_IP:2010 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 8181 -j DNAT --to-destination \$CCU_IP:8181 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 8183 -j DNAT --to-destination \$CCU_IP:8183 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 8700 -j DNAT --to-destination \$CCU_IP:8700 iptables -t nat -A PREROUTING -p tcp -i \$HOST_IF --dport 8701 -j DNAT --to-destination \$CCU_IP:8701 fi EOT' sudo chmod +x /etc/network/if-up.d/pivccu
-
On Systems like Ubuntu > 18.04 you need to tell netplan to use the if-up.d script with
/etc/networkd-dispatcher/routable.d/50-ifup-hooks
:
#!/bin/sh
for d in up post-up; do
hookdir=/etc/network/if-${d}.d
[ -e $hookdir ] && /bin/run-parts $hookdir
done
exit 0
- If you are using Docker on the same machine you need to knock out the intelligent bridge-detection and make it dumb, because Docker also uses bridges:
sudo sed -i '/lxc.network.link/c\lxc.network.link \= br0' /etc/piVCCU3/lxc.config
Note that this will probably need to be done again when the piVCCU package updates.
- Reboot