How to automount CIFS/SMB on Alpine Linux

In order to automatically mount CIFS on boot of an Alpine Linux instance, use a line like this in /etc/fstab:

//1.2.3.4/mydrive /mydrive   cifs uid=1000,gid=1000,credentials=/root/.smb-credentials,iocharset=utf8,noperm 0 0

with a standard /root/.smb-credentials like this:

user=myuser
password=raatahteiC1veiza8ahno8lu5quook

and run the following command to enable automount on boot:

rc-update add netmount boot

After a reboot, the filesystem should mount automatically.

Posted by Uli Köhler in Alpine Linux, Networking

How to fix apt update EXPKEYSIG 1DB7590E83C8F643

Problem:

When running sudo apt update you see the following error message:

Err:14 https://ocean.surfshark.com/debian stretch InRelease
  The following signatures were invalid: EXPKEYSIG 1DB7590E83C8F643 Surfshark package maintainer <[email protected]>

Solution:

Install the updated Surfshark package by pasting the following into your shell (as shown on the Surfshark help page):

curl -f https://downloads.surfshark.com/linux/debian-install.sh --output surfshark-install.sh
cat surfshark-install.sh
sh surfshark-install.sh

After that, the error should be fixed and you can run

sudo apt update

again.

Posted by Uli Köhler in Linux

BUP MySQL backup using mysqldump without intermediary file

BUP is a nice git-based backup tool that is both free and easy to use and saves space by differential backups.

You can also use bup to backup a MySQL database using mysqldump directly instead of first dumping to a .sql file and then backing up the file.

This is possible by piping the mysqldump output directly into bup split:

mysqldump [...]| bup -d $BUP_DIR split -n mysqldump.sql

By using -n mysqldump.sql you are telling bup that the file created by the dumping should be named mysqldump.sql in the backup.

Full example:

export BUP_DIR=/var/lib/bup/mysql.bup
export MARIADB_ROOT_PASSWORD=piahaen9ehilei0Ieneirohthue4Iu

bup -d $BUP_DIR init
mysqldump -uroot -p${MARIADB_ROOT_PASSWORD} --all-databases | bup -d $BUP_DIR split -n mysqldump.sql

 

Posted by Uli Köhler in bup

How to autostart Wireguard using systemd (wg-quick)

If you’ve added a wg-quick config, e.g. /etc/wireguard/wg0.conf, you can enable autostarting it on system boot using systemd:

sudo systemctl enable --now wg-quick@wg0

If you have started Wireguard with this config manually before, you need to shut it down first or systemd will not be able to start it !

Posted by Uli Köhler in Networking, systemd, Wireguard

How I connected a network_mode: host container to its database container

I have setup my FreePBX to use network_mode: 'host' but faced issues when it couldn’t connect to the MariaDB container which was not using network_mode: 'host'.

I fixed this by:

  • Setting the MariaDB container to network_mode: 'host'
  • Setting the FreePBX container to connect to 127.0.0.1 (DB_HOST=127.0.0.1). Setting it to localhost did NOT allow FreePBX to connect to MariaDB!
Posted by Uli Köhler in Docker, FreePBX, Networking

What is MikroTik RouterOS WebFig?

WebFig is the Web UI for MikroTik RouterOS routers. When people say to use WebFig for a given task, this typically means to not use the MikroTik terminal.

Posted by Uli Köhler in MikroTik, Networking

How to add RFC1918 address list to MikroTik using terminal

Use these commands to add all RFC1918 networks to a MikroTik RouterOS IP address list:

/ip firewall address-list add address=10.0.0.0/8 list=RFC1918
/ip firewall address-list add address=172.16.0.0/12 list=RFC1918
/ip firewall address-list add address=192.168.0.0/16 list=RFC1918
Posted by Uli Köhler in MikroTik, Networking

Complete list of RFC1918 addresses

RFC1918 defines the following networks as private address spaces:

  • 1.0.0.0/8
  • 172.16.0.0/12
  • 192.168.0.0/16
Posted by Uli Köhler in Networking

How to fix MikroTik RouterOS Couldn’t add New Firewall Address List – … is not a valid dns name (6)

Problem:

If you want to add a MikroTik Address List e.g. for use in firewall rules like this:

you see an error message like

Couldn't add New Firewall Address List - 192.168.0.0/24,10.0.0.0/8 is not a valid dns name (6)

Solution:

You can’t add multiple addresses to an address list at once. The way to add multiple addresses to an address list is to create multiple entries with the same Name.

See our detailed guide on How to add multiple addresses to MikroTik RouterOS address list using WebFig for more details on how to achieve that in WebFig.

Posted by Uli Köhler in MikroTik, Networking

How to add multiple addresses to MikroTik RouterOS address list using WebFig

If you are trying to create a MikroTik firewall address list using WebFig (in IP/Firewall), you will see that you can’t just add multiple addresses in the Address field:

How to add multiple addresses

First, add the first address like this:

This will look like this in the Address List view:

Then, add another address with the same name (the comment can be different if you want). You can also select the name using the dropdown for the Name field.

This will look like this in the Address List view:

Our RFC1918 list will now identify both networks 10.0.0.0/8 and 192.168.0.0/16.

Posted by Uli Köhler in MikroTik, Networking

Recommended docker-compose mariadb service

I recommend this service:

mariadb:
  image: mariadb:latest
  environment:
    - MYSQL_DATABASE=servicename
    - MYSQL_USER=servicename
    - MYSQL_PASSWORD=${MARIADB_PASSWORD}
    - MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
  volumes:
    - ./mariadb_data:/var/lib/mysql
  command: --default-storage-engine innodb
  restart: unless-stopped
  healthcheck:
    test: mysqladmin -p${MARIADB_ROOT_PASSWORD} ping -h localhost
    interval: 20s
    start_period: 10s
    timeout: 10s
    retries: 3

(replace servicename by the name of your service, e.g. kimai, redmine, …) and this .env:

MARIADB_ROOT_PASSWORD=eiNgam3woh4ahTee4chi9vohvauk6a
MARIADB_PASSWORD=shahb4alubei5Vie8arahhok2morae

You can also easily generate these passwords by using:

echo -e "MARIADB_ROOT_PASSWORD=$(pwgen 30 1)\nMARIADB_PASSWORD=$(pwgen 30 1)" > .env

 

Posted by Uli Köhler in Container, Docker

How to fix Marlin Error: Build environment ‘linux_native’ is incompatible with BOARD_RAMPS_14_EFB

Problem:

When compiling Marlin for simulation, you see an error message like

Error: Build environment 'linux_native' is incompatible with BOARD_RAMPS_14_EFB. Use one of these: mega2560, mega1280

Solution:

Open Marlin/Configuration.h and change the line

#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_RAMPS_14_EFB
#endif

to use the BOARD_LINUX_RAMPS board:

// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_LINUX_RAMPS
#endif

Even if the error message shows that you should use mega2560 or mega1280, you need to use BOARD_LINUX_RAMPS!

Posted by Uli Köhler in 3D printing

How to run Asterisk command from shell

Use

asterisk -rx "[command]"

to run an Asterisk command (-x) in an already running Asterisk server (-r), for example:

asterisk -rx "core restart now"

 

Posted by Uli Köhler in FreePBX

How to restart Asterisk in FreePBX

This tutorial will show how to restart the Asterisk service in FreePBX.

First, you need to install the Asterisk CLI module. In order to do that, login to your FreePBX admin panel and click at the Admin -> Module Admin menu entry.

After the module is installed, open Admin -> Asterisk CLI

Now enter one of the following commands

  • If you just want to restart Asterisk immediately, even if that stops ongoing calls, enter
    core restart now

    This is typically used while setting up the PBX

  • If you don’t want to interrupt ongoing calls but you don’t want to admit new calls, use
    core restart gracefully

    Asterisk will restart when all ongoing calls have been finished

  • In case you don’t want to interrupt ongoing calls but still admit new calls to the system, use
    core restart when convenient

    Asterisk will restart at the first opportunity when no calls are in progress

Posted by Uli Köhler in FreePBX

Local redmine backup using bup (docker-compose compatible)

This script uses bupto backup your docker-compose based redmine installation to a local bup folder e.g. in /var/lib/bup/my-redmine.bup:

#!/bin/bash
# Auto-determine the name from the directory name
# /opt/my-redmine => $NAME=my-redmine => /var/lib/bup/my-redmine.bup
export NAME=$(basename $(pwd))
export BUP_DIR=/var/lib/bup/$NAME.bup
bup_directory() {
        echo "BUPing $1"
        bup -d $BUP_DIR index $1 && bup save -9 --strip-path $(pwd) -n $1 $1
}
# Init
bup -d $BUP_DIR init
# Save MariaDB
source .env && docker-compose exec -T mariadb mysqldump -uroot -p${MARIADB_ROOT_PASSWORD} --all-databases | bup -d $BUP_DIR split -n $NAME-mariadb.sql
# Save directories
bup_directory redmine_data
bup_directory redmine_themes
# Backup self
bup_directory backup.sh
bup_directory docker-compose.yml
# OPTIONAL: Add par2 information
#   This is only recommended for backup on unreliable storage or for extremely critical backups
#   If you already have bitrot protection (like BTRFS with regular scrubbing), this might be overkill.
# Uncomment this line to enable:
# bup fsck -g

# OPTIONAL: Cleanup old backups
bup -d $BUP_DIR prune-older --keep-all-for 1m --keep-dailies-for 6m --keep-monthlies-for forever -9 --unsafe

It will backup:

  • MySQL data from inside redmine using mysqldump
  • The redmine_data folder
  • The redmine_themes folder
  • The backup script backup.sh itself
  • docker-compose.yml

Place it in the same folder where docker-compose.yml is located.

The script is compatible with our previous post How to create a systemd backup timer & service in 10 seconds

Posted by Uli Köhler in bup, Docker

Minimal .ssh/config for passwordless login

The following configuration specifies an SSH key and username to login to a specific machine.

Host 192.168.1.215
  User uli
  IdentityFile /home/uli/.ssh/id_bup
  IdentitiesOnly yes

After you have copied it to ~/.ssh/config, you can just

ssh 192.168.1.215

to the machine, without specifying key or user name

Posted by Uli Köhler in Networking

How to fix bup bup.client.ClientError: server tunnel returned exit code 255

Problem:

When running bup using the bup remote functionality, e.g. using

bup init -r 192.168.1.215:/var/bup

you see these error messages:

Traceback (most recent call last):                                                                                                                            
  File "/usr/lib/bup/cmd/bup-init", line 45, in <module>                                                                                                      
    cli = client.Client(argv_bytes(opt.remote), create=True)                                                                                                  
  File "/usr/lib/bup/cmd/../bup/client.py", line 108, in __init__                                                                                             
    self._available_commands = self._get_available_commands()                                                                                                 
  File "/usr/lib/bup/cmd/../bup/client.py", line 181, in _get_available_commands                                                                              
    raise ClientError('unexpected help header ' + repr(line))                                                                                                 
bup.client.ClientError: unexpected help header b''                                                                                                            
Exception ignored in: <function Client.__del__ at 0x7fa7d7e2bb80>                                                                                             
Traceback (most recent call last):                                                                                                                            
  File "/usr/lib/bup/cmd/../bup/client.py", line 122, in __del__                                                                                              
    self.close()                                                                                                                                              
  File "/usr/lib/bup/cmd/../bup/client.py", line 147, in close                                                                                                
    raise ClientError('server tunnel returned exit code %d' % rv)                                                                                             
bup.client.ClientError: server tunnel returned exit code 255

Solution

You need to accept the remote host key and setup passwordless login, else bup won’t be able to connect to the host using SSH.

Just SSH to the host without username (since bup will not use an explicit username either):

ssh 192.168.1.215

If you see a prompt like

The authenticity of host '10.11.12.15 (10.11.12.15)' can't be established.
ECDSA key fingerprint is SHA256:ZaIJ51uHwI9Q3i/CKdjF3Erwt27CjQqa4YL45UV5rwM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 

enter yes and press return.

If you see a password prompt, you have not setup SSH correctly.

I use the following ~/.ssh/config on the bup client:

Host 192.168.1.215
  User bup
  IdentityFile /home/uli/.ssh/id_bup
  IdentitiesOnly yes

and I have copy-&-pasted the content of /home/uli/.ssh/id_bup.pub to /home/bup/.ssh/authorized_keys on the bup server in order to setup passwordless login.

Posted by Uli Köhler in Networking

How to fix bup remote sh: bup: not found

Problem:

When running bup using the bup remote function, e.g.

bup init -r 192.168.1.215:/var/bup

you see an error like

sh: bup: not found                                                                                                                                            
Traceback (most recent call last):                                                                                                                            
  File "/usr/lib/bup/cmd/bup-init", line 45, in <module>                                                                                                      
    cli = client.Client(argv_bytes(opt.remote), create=True)                                                                                                  
  File "/usr/lib/bup/cmd/../bup/client.py", line 108, in __init__                                                                                             
    self._available_commands = self._get_available_commands()                                                                                                 
  File "/usr/lib/bup/cmd/../bup/client.py", line 181, in _get_available_commands                                                                              
    raise ClientError('unexpected help header ' + repr(line))                                                                                                 
bup.client.ClientError: unexpected help header b''

Solution

First, login using SSH to your server and check if bup is installed by running

bup

Example output:

Usage: bup [-?|--help] [-d BUP_DIR] [--debug] [--profile] <command> [options...]

Common commands:
    fsck       Check backup sets for damage and add redundancy information
    ftp        Browse backup sets using an ftp-like client
    fuse       Mount your backup sets as a filesystem
[...]

If that works, you need to ensure bup is located at /usr/bin/bup !

Run

which bup

to find out where bup is located.

If, for example, it’s at /usr/local/bin/bup, you need to symlink it to /usr/bin/bup:

ln -sf /usr/local/bin/bup /usr/bin/bup
Posted by Uli Köhler in Networking

How to install python-config on Alpine Linux

I recommend to use Python 3.x since Python 2.x is deprecated!

Installing python-config for Python 3.x

The python3-dev apk package provides /usr/bin/python3-config, so you’ll have to symlink that to /usr/bin/python-config:

apk update
apk add python3-dev
ln -sf /usr/bin/python3-config /usr/bin/python-config

Installing python-config for Python 2.x

Just install python2-dev, which installs /usr/bin/python-config

apk update
apk add python2-dev

 

 

Posted by Uli Köhler in Alpine Linux

What is DTMF playback?

DTMF – also called tone dialling – is when a phone number is being dialled by tones at a specific frequency. Each number key on the phone is assigned a combination of two specific tones that are played when the key is being pressed.
DTMF is a newer version of dialing over analog lines, compared to the older pulse dialing method.

DTMF playback controls, if your phone plays the characteristic tone for each.

If DTMF playback is enabled, every time you press a number key on your phone, you will hear the characteristic tone for that key.

If DTMF playback is disabled, you will not hear a DTMF tone while pressing the number keys on your phone.

Posted by Uli Köhler in Networking
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPTPrivacy &amp; Cookies Policy