How to change mysql table engine MyISAM to InnoDB

login to mysql shell as root.
locate the database where the tables are situated.
SET @DATABASE_NAME = ‘name_of_your_db’; // name_of_your_db = the database you want to change table engine.
SELECT CONCAT(‘ALTER TABLE ', table_name, ' ENGINE=InnoDB;’) AS sql_statements FROM information_schema.tables AS tb WHERE table_schema = @DATABASE_NAME AND ENGINE = ‘MyISAM’ AND TABLE_TYPE = ‘BASE TABLE’ ORDER BY table_name DESC;
The result will end up in a list of the tables that needs to be changed. Copy the list and do the following.
Shift to the database involved:

USE name_of_your_db
START TRANSACTION;
insert the copied list
COMMIT;
You have now changed the engine of the tables.

[ERROR] Fatal error: Can’t open and lock privilege tables: Table ‘mysql.user’ doesn’t exist

This error ocurs then the database mysql is missing or corrupt.
Stop the mysql server “service mysql-server stop”
Make a backup of /var/db/mysql “mv /var/db/mysql /var/db/mysql.old”.
To rebuild the database execute “/usr/local/libexec/mysqld –initialize”
You will get a temporary password. Remember the password for later use.
Start the mysql server “service mysql-server start”
To start upp the new configuration “mysql_secure_installation”. Use the Password to start the configuration and step thru the wizzard.
Restore the mysql backup and the server is good as new.

“There has been a critical error on your website. Learn more about debugging in WordPress.” after updating to WordPress 5.7 (All in one WP security and firewall) [Solved]

Investigating the error log reveals that the problem has to do with All in one WP security and firewall plugin:

Got error 'PHP message: PHP Fatal error:  Cannot redeclare retrieve_password() (previously declared in /www/wp-includes/user.php:2671) in /www/wp-content/plugins/all-in-one-wp-security-and-firewall/other-includes/wp-security-rename-login-feature.php on line 358'

The problem has been solved in All in one WP security and firewall plugin version 4.4.8, so it means your WordPress site was updated to 5.7 prior to updating the plugins.

To solve it, you need to update All in one WP security and firewall but not being able to login to your site you will need to solve this using FTP.

Using FTP, rename the folder wp-content/plugins/all-in-one-wp-security-and-firewall to something else. Now you can log into your site and reinstall All in one WP security and firewall. Make sure you get at least version 4.4.8.

ISPConfig3 localized ‘Welcome to your new email account’ mail not working [SOLUTION]

I made a copy of the file welcome_email_en.txt from /usr/local/ispconfig/server/conf/mail to /usr/local/ispconfig/server/conf-custom/mail and named it welcome_email_se.txt and translated the content of the file, as I wanted my clients to be greeted to their new email account in Swedish. However, the client was still receiving the welcome email in English.

It turned out that the configuration file for ISPConfig has a parameter for language which controls what email templates to use. I thought it would use the country settings from the Client but it doesn’t.

In /usr/local/ispconfig/server/lib check if the file config.inc.local.php exists. If it doesn’t, create one (here is a template for it).

Add the line:

$conf['language'] = 'se';

By using config.inc.local.php and not directly editing config.inc.php you are making sure it doesn’t get overwritten in the next ISPConfig3 update.

In a multiserver setup (master/slaves) this must be done on all the slaves as the ‘Welcome to your new email account’-email is being generated on the server where the new mailbox is located.

Automatic restart of IPSec VPN on Teltonika RUT-950 / RUT-240

On one location where I am using a Teltonika RUT-950 / RUT-240 router, the IPSec VPN can only be connected in one direction which is outbound. Normally both ends can initiate the connection. The reason for this is that the router is connecting using 3G/4G and the provider only allows outbound traffic (i.e. “surf the Internet”). I need to buy an extra service for “fixed IP-address” in order to get their firewall removed from my service.

My IPSec VPN setup is based on hostname updated through dynamic DNS. If the router reboots, it will get a new IP-address and sometimes the router tries to connect the VPN before the dynamic DNS has been updated, causing the VPN connection to fail. The router gives up and does not try anymore to connect the VPN. A manual workaround is to remote control a computer on the LAN side of the router, login to the router, disable the VPN profile, save, enable it and save again. Now the VPN connects.

The Teltonika products are wonderful in many ways but I lack a way of restarting IPSec VPN via SMS. It is only possible to restart OpenVPN connections using SMS.

To avoid manual actions to get the VPN up in a case like this I have created a small script. It checks if an IP-address on the other side of the tunnel is ping:able, if not it restarts IPSec VPN and it normally resolves the problem.

  • Log in to the Teltonika RUT-950 / RUT-240 using CLI or SSH.
  • Create a script in /root/chk_vpn.sh with the following content, or you can dowload it with wget from CLI or SSH:
    wget http://heltech.se/filer/chk_vpn.sh

#!/bin/ash
# chmod +x chk_vpn.sh
# crontab -e -> */6 * * * * /root/chk_vpn.sh
HOST=10.0.0.1

LANIP=/sbin/ifconfig br-lan | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
# Email settings
ROUTERNAME="MY ROUTER NAME"
EMAIL_SUBJECT="$ROUTERNAME: VPN restart"
EMAIL_BODY="$ROUTERNAME $LANIP: Ping $HOST failed, trying to restart VPN (date)"
EMAIL_FROM="senders.email@gmail.com"
EMAIL_TO="recipients.email@gmail.lt"
EMAIL_USER="senders.email@gmail.com"
EMAIL_PASS="MYEMAILACCOUNTPASSWORD"
EMAIL_SERVER="smtp.gmail.com"
EMAIL_PORT="587"
#
if ping -I $LANIP -c5 $HOST > /dev/null; then
  logger "chk_vpn.sh: $HOST responded; VPN is up!"
else
  logger "chk_vpn.sh: $HOST did not respond; trying to restart VPN"

echo -e "subject:$EMAIL_SUBJECT\nfrom:$EMAIL_FROM\n$EMAIL_BODY" | sendmail -v -H "exec openssl s_client -quiet -connect $EMAIL_SERVER:$EMAIL_PORT -tls1 -starttls smtp" -f $EMAIL_FROM -au"$EMAIL_USER" -ap"$EMAIL_PASS" $EMAIL_TO
  /usr/sbin/ipsec restart
fi

(The date in the code above should be in back aphostrophes but our WP editor removes it)

  • Edit the file chk_vpn.sh and replace the IP-adress on the HOST= line to an IP-address on the other side of the tunnel that you know should be up at all times and responds only when the IPSec VPN is up, for example the LAN interface of the other router.
    Change all lines regarding email to your email server’s settings and credentials.
  • chmod +x chk_vpn.sh
  • Check from the router’s CLI or SSH that you can ping the IP-address (if you mistakenly enter an IP-address that doesn’t respond to ping even thought IPSec VPN is up, your VPN will be disrupted 10 times per hour).
    You must use ping -I 192.168.0.1 10.0.0.1 where 192.168.0.1 should be replaced with your router’s LAN interface IP-address and 10.0.0.1 replaced with the ping:able IP-address on the other side of the tunnel.
  • Test the script by running it from CLI or SSH and verify that it can ping the host on the other side of the tunnel by entering the command: ./chk_vpn.sh and then go to System -> Administration -> Troubleshoot -> Show syslog and look for the chk_vpn.sh line (probably last row)
  • Edit the crontab by entering the command crontab -e and add the following line:

*/6 * * * * /root/chk_vpn.sh

  • Exit vi (ESC then :wq and enter)

This will check the VPN connection 10 times per hour and if necessary restart it.

Edit: 5 october 2022: Added LANIP as source

Prevent Mac OSX ssh from disconnecting (also on any Linux/BSD/*nix system)

To prevent ssh from disconnecting while idle, add the following to ~/.ssh/config:

Host *
    ServerAliveInterval 30
    TCPKeepAlive no

This solution is alse useable in any Linux/BSD/*nix environment. If you want to implement this not only on your own user, as a sysadmin, add the above to /etc/ssh/ssh_config instead.

Cisco RV160 IPv6 configuration

This is how I configured IPv6 address received dynamically from my ISP. This is not to be confused with using a 6to4 tunnel service which is something completely different. In this case, a real IPv6 address is received using DHCP6 or SLAAC from the ISP.

In this setup the IPv6 LAN side is bridged with the IPv6 WAN side, so the LAN subnet is a part of the larger WAN subnet. Firewall rules will apply even though it is a bridged, not routed setup.

  1. Go to WAN -> WAN settings -> IPv6 Settings and select DHCP, check DHCP-PD and enter “0” for Prefix name. Apply.
  2. Go to Status and Statistics -> IPv6 tab and verify that you get a IPv6 address from your provider (starting with 2a02 in my case).
    Cisco RV160 IPv6
  3. Go to LAN -> VLAN Settings and select vlan 1, click edit button.
    Cisco RV160 IPv6
    In the IPv6 sections, select prefix from WAN 0, in my case address beginning with 2a02 and /48 size.
    Enter 0 for suffix, 64 for prefix length, leave DHCP Type disabled. Apply.
  4. Go to LAN -> Router advertisment and click Enable, select Unicast, do not select Managed or Other. Make sure the IPv6 prefix is visible in the Prefix table.

Done.

WordPress displays 'Connection Information'

WordPress displays “Connection Information” asking for FTP credentials

WP displays “Connection Information” and a text “To perform the requested operation, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

To solve this, add the following line to your wp-config.php:

define('FS_METHOD','direct');

If that doesn’t solve the problem you need to check the file access rights for the WordPress installation on the web server.

How to upgrade Windows 10 Enterprise Evaluation to full version

If you’ve tried the Windows 10 Enterprise Evaluation and decide to go on and buy the full version, Microsoft doesn’t support a simple way of just converting or upgrading.

This is how you do it.

You will need:

  • An ISO image of Windows 10 Enterprise, download it from Microsoft (link is not provided here because Microsoft has a tendency to change their URL:s and direct links usually ends up broken, so you just have to search for it at Microsoft). Note: It MUST be for the same language code as the one used when you installed the Evaluation.
  • A Windows 10 license key.
  1. Start the upgrade using the ISO image but do not continue
  2. Start the Registry Editor (i.e. run regedit)
  3. Search for “CurrentVersion”, i.e:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
  4. In EditionID value data, change EnterpriseEval to Enterprise
  5. In ProductName value, change Windows 10 Enterprise Evaluation to Windows 10 Enterprise
  6. Immediately continue the upgrade while the Registry Editor is still open (otherwise the changed registry values will revert and you will not be able to upgrade).

Config Cisco Nexus L3 vlan routing IPv6

Config Cisco Nexus L3 vlan routing IPv6

This is a simple how to make a nexus switch L3 routeing and the connected access switches still on L2 switching. If you have a router connected between internet and the router switch. Make shure you have a static route configured to the two vlan network.

Router Switch

no system default interface-vlan autostate (brings up the vlan)

conf t

vlan 10  (creates vlan 10 L2)

name Servers vlan 10

exit

vlan 20 (creates vlan 20 L2)

name Servers vlan 20

exit

feature interface-vlan  (Converts L2 vlan 10 to L3 vlan 10)

interface vlan 10

ipv6 address 2001:db8::/50

no ip redirects

exit

feature interface-vlan  (Converts L2 vlan 20 to L3 vlan 20)

interface vlan 20

ipv6 address 2001db8:0:4000::/50

no ip redirects

exit

interface ethernet 1/1 (creates tagged vlan port to access sw1)

description To Access Sw1

switchport

switchport mode trunk

no shutdown

exit

interface ethernet 1/2 (creates tagegd vlan port to access sw1)

description to Access Sw2

switchport

switchport mode trunk

no shutdown

exit

interface ethernet 1/3 (Creates the link network port)

description to Internet

no switchport

ipv6 address 2001:db8:1000:8000::1/64

no shutdown

exit

ipv6 route ::  2001:db8:1000:8000::2 (makes default router to next hop router)

copy running-config startup-config

Access Sw1

conf t

vlan 10 (creates vlan 10 L2)

name Servers vlan 10

exit

vlan 20 (creates vlan 20 L2)

name Servers vlan 20

exit

interface ethernet 1/1 (creates tagged vlan port to Router switch)

description To Router Switch

switchport

switchport mode trunk

no shutdown

exit

interface ethernet 1/2 (creates untagged vlan 10 port to servers)

description Access vlan 10

switchport

switchport mode access vlan 10

no shutdown

exit

interface ethernet 1/3 (creates untagged vlan 20 port to servers)

description  Access vlan 20

switchport

switchport mode access vlan  20

no shutdown

exit

copy running-config startup-config

Access Sw2

conf t

vlan 10 (creates vlan 10 L2)

name Servers vlan 10

exit

vlan 20 (creates vlan 10 L2)

name Servers vlan 20

exit

interface ethernet 1/1 (creates tagged vlan port to Router switch)

description To Router Switch

switchport

switchport mode trunk

no shutdown

exit

interface ethernet 1/2 (creates untagged vlan 10 port to servers)

description Access vlan 10

switchport

switchport mode access vlan 10

no shutdown

exit

interface ethernet 1/3 (creates untagged vlan 20 port to servers)

description  Access vlan 20

switchport

switchport mode access vlan  20

no shutdown

exit

copy running-config startup-config