openHAB delete stubborn things

If you try to delete a thing via the GUI in openHAB 4 and it does not get removed (status remains stuck on: removing), you can remove it using the CLI.

For this, login to the karaf console:

openhab-cli console

Username: openhab ; password: habopen

openhab:things remove thing:full:name

Install Cockpit management on Ubuntu

If you want to install cockpit on your server, follow these steps:

To install cockpit on Ubuntu, run the following command:

sudo apt install cockpit

Additionally, install the following package for more detailed metrics:

sudo apt install cockpit-pcp

Now there is a bug in Ubuntu, prohibiting cockpit to update the system through the webinterface (packagekit cannot refresh cache whilst offline). This seems to have to do with differences in netplan and network manager. To overcome this, you have to create a a placeholder file and a network interface:

nano /etc/NetworkManager/conf.d/10-globally-managed-devices.conf

Add the following two lines to that file. Save the file ant quit the nano editor.

 [keyfile]
 unmanaged-devices=none

Optionally: If you run Ubuntu on an ARM system, you may need to install the following packages:

sudo apt install linux-modules-extra-raspi

Now set up a dummy network interface:

nmcli con add type dummy con-name fake ifname fake0 ip4 1.2.3.4/24 gw4 1.2.3.1

Reboot your machine. Now you should be able to update the packages in the web interface.

Cockpit should be starting automatically. If this does not happen, configure it to do so:

systemctl start cockpit
systemctl enable cockpit

Access your cockpit installion under https://my.server.IP.address:9090

Source: https://cockpit-project.org/faq.html

Auto start issues?

If you happen to see the following error when enabling cockpit:

The unit files have no installation config (WantedBy=, RequiredBy=, Also=, Alias= settings in the [Install] section, and DefaultInstance= for template units). This means they are not meant to be enabled using systemctl.

Than you have to edit the configuration file:

sudo nano /usr/lib/systemd/system/cockpit.service

And add the following lines at the end, save and start the service:

[Install]
WantedBy=multi-user.target
systemctl enable cockpit.service
systemctl start cockpit.service

source: https://mj57.github.io/2021/03/Installer-Cockpit/

Using FreePBX instead of the FritzBox as your phone server

Most private landline phone users in Luxembourg use a FritzBox to connect their phones (often DECT phones) to the national telephone network, supposed they still have a landline phone in their home. Although that the FritzBox really does an excellent job at this and is very easy to use, I always felt that I wanted to have more control over my VoIP server. The path to go was for me to move over to locally hosted FreePBX server.

So I started installing FreePBX (16) in a virtual machine on my ProxMox server, providing it with decent resources (64 GB Disk, 4 GB RAM, 2 cores) and put it into the isolated Phone VLAN in my network, together with my VoIP phones (and my FritzBox phone server).

In order to get started with a single phone, you need to:

Caution

I was experimenting with FreePBX using a second VoIP number and in the same time keeping my other number online through the Fritzbox. This allowed me to do outbound calls on the FreePBX attached phone using the second number, but I was unable to receive inbound calls on that line. When calling inbound from the cellphone, the line appeared ringing, but no phone (extension) received the call. No entries were found in the FreePBX log file neither. So I assume that running the Fritzbox and the FreePBX system in parallel in a home network seems to lead to routing issues. The Fritzbox seemed to be the master receiver, as the other VoIP number still worked fine. This is all hypothetical, but in my case, things didn’t work. Shutting down the Fritzbox, and waiting for a few minutes, allowed the FreePBX system to receive the incoming calls too.

Configuring the firewall for FreePBX

Internal firewall

Go to the Connectivity menu, submenu Firewall. I guess you should run the Wizard to accomplish a basic configuration. Anyway, Make sure that the FreePBX main interface (eth0) is defined as Local(Local trusted traffic) under the Interfaces tab.

The networks tab should include all the devices that should be able to contact the FreePBX server:

  • all your VoIP phones
  • potential software phones
  • your main computer (to manage the FreePBX system).
  • Don’t forget to allow your external SIP server (uplink) to contact your FreePBX!

Network firewall

I needed to define a Port Forwarding rule in my router’s (Unifi Dream Machine Pro) firewall to allow the external SIP server (my uplink) to contact my internal FreePBX server. I specifically allow the external server’s IP to access the IP of my FreePBX on port 5060 on both (UDP, TCP) protocols.

It is also recommended to disable the Conntrack Modules in the router that handle SIP traffic (H.323 and SIP), although it might help if you are in a double-NAT network.

Define an inbound route in FreePBX

Go to the Connectivity menu, submenu Inbound Routes. Click the button: Add Inbound Route.

Add a route Description, a DID Number (important if you use several incoming phone numbers) and define Set Destination to an Extension or to a Ring Group (if you have defined one).

Example of an inbound route

Connect a Yealink T46S phone to FreePBX

Create the account / line

Open your VoIP phone’s configuration interface. Go to the Accounts tab. Select the next free account and enter the following information:

Line active (enabled), the Label, the Display Name, the Register Name, the Username and Password of your extension, the Server Host (IP address of your FreePBX server), Port 5060 and hit confirm.

If everything went well, the Register Status should be switching from Registering to Registered.

Yealink T46S

Don’t forget to define a Line Key in the Dsskey tab to make the line visible and usable on your phone. As a Type, use Line, leave the Value on Default, define the Label to show your phone number or whatever you want to see on your phone, and as Line use the account number of the line you created above, in my case: Line 3.

Permit access to Voicemail

To add a voicemail button to your phone, in the Dsskey tab, define a Line Key that has as Type: BLF, as value *97, label it Voice Mail and select your Line as the Line (again for me: Line 3). After hitting the Confirm button, a line key button shows up with a green light (or red, if you already have a message). Of course, this only works if your voicemail is activated for this extension in the FreePBX.

You can also add a button for the general voicemail of your FreePBX system. This mailbox is normally defined ass extension 6000. In this case, the value for the line key has to be *986000. *98 allows to call a voice mailbox of another user. *97 goes to the mailbox of the extension you are using.

Configuration of a general and personal voicemail number

Problem solving

If the phone does not register, make sure the entered configuration data is correct and that the firewalls (FreePBX & your router’s firewall, in case you are on a different LAN or VLAN) allow for the connection to happen.

If you want to see the communication between your phone and your FreePBX server, connect with SSH to the FreePBX box and run the following command:

sngrep

Add a VoIP phone to your FreePBX

Create an extension

Go to the menu Applications and submenu Extensions. Click on Add New SIP [chan_pjsip] Extension.

Create new extension

Enter the User Extension, the Display Name and the Secret. You can either create a new Username or use an existing one for this line.

If you want to use voicemail, go to the Voicemail tab and provide a Voicemail Password and an Email Address (if you want to receive an email with the audio message).

If you are done, hit submit and apply config.

Define a SIP trunk in FreePBX

Go to the Connectivity menu, Trunks submenu. Click Add trunk. Add a SIP (chan_pjsip) Trunk.

Define a Trunk Name and an Outbound CallerID.

Define the Dialed Number Manipulation Rules which defines what numbers can be called. Be careful which number structures you allow, as some numbers might become very expensive.

In the pjsip Settings under General, fill out the Username, the Auth username, the Secret and the SIP Server. These information should have been given to you by your VoIP provider. The SIP Server port is mostly 5060. Authentication should be set to Outbound. If your external SIP server has a fixed IP or hostname (and you are on a public dynamic IP), then Registration should be set to Send.

SIP Trunk configuration

I also filled out the advanced tab information for Contact User, From Domain and From User. Not sure if this is absolutely necessary, but as iI was experimenting a lot to get things going, it is filled out in my case.

When you are done, hit Submit and Apply config.

Configure the SIP settings

Go to the Settings menu, Asterisk SIP settings submenu. Go to the General SIP Settings tab.

For maximum security, disallow Anonymous Inbound SIP calls & SIP Guests.

In the NAT settings, enter your static WAN IP or your dynamic DNS name.

Optional: In the Audio codecs, move the ulaw codec to the top of the list.

Now go to the SIP Settings [chan_pjsip] tab.

udp – 0.0.0.0. – All should be enabled.

0.0.0.0 (udp) Port to Listen On: 5060.

Submit and apply these changes. Restart the Asterisk service using the following command in the Admin menu, Asterisk CLI submenu:

core restart now