ADB over network with Android 2.3

For testing purposes I use an old Android 2.3 device that runs an old version of Cyanogenmod. Unfortunately I could not find an option to enable ADB over network in the device’s settings. I am not a fan of plugging in the device every time I would like to debug an application. But, fortunately, there is a way to enable ADB over network via Terminal if your device is rooted:

su
setprop service.adb.tcp.port 5555
stop adbd
start adbd

Afterwards you can connect as usual by running adb connect device-ip on your development machine.

To disable ADB over network you can set the TCP port option to -1:

setprop service.adb.tcp.port -1
stop adbd
start adbd