July 15

nmcli/NetworkManager add/remove IPs

In this example we are adding IP 192.168.1.235 (also we mention GW and DNS for it ) and removing the IP 192.168.1.233

nmcli connection modify ens18 ipv4.addresses 192.168.1.235/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8,1.1.1.1
nmcli connection modify ens18 -ipv4.addresses 192.168.1.233
service NetworkManager restart
nmcli connection reload

June 27

Block FB bot on the server level

Check if FB bot is present:

grep -c "facebook.com/externalhit_uatext.php" /etc/apache2/logs/domlogs/*/*|awk -F'/' {'print $7'}|awk -F: {'print $2,$1'}|sort -k 1

Block whole FB bot network:
yum install -y whois;for i in `whois -h whois.radb.net -- '-i origin AS32934' | grep ^route |grep -v route6|awk {'print $2'}`;do csf -d $i "FB bot network https://developers.facebook.com/docs/sharing/webmasters/crawler/#crawler-rate-limits";done

May 29

How to find out maximum supported RAM in Ubuntu/ArchLinux

f you need a quick way to find out how much RAM your Linux system supports or to determine the number of DIMM slots available, you can use a command line tool called dmidecode.

dmidecode command is a tool for dumping a computer’s DMI (some say SMBIOS) table contents in a human-readable format. Thanks to this table, you can retrieve this information without having to probe for the actual hardware.

# archlinux
yaourt -S dmidecode

# ubuntu
sudo apt-get install dmidecode

To find out the maximum RAM capacity and the number of RAM slots available, use the following command:

sudo dmidecode -t 16

The Maximum Capacity is the maximum RAM supported by your system, while Number of Devices is the number of memory (DIMM) slots available on your computer.

To see complete memory information, including the info above along with currently installed memory information (RAM speed, size, etc.), use:

sudo dmidecode -t memory

Original article is stored here

May 29

FSCK and multi partition mount from disk image file

root@nodes:~# kpartx -v -a /dev/pve/vm-104-disk-0
add map pve-vm--104--disk--0p1 (252:6): 0 2048 linear 252:8 2048
add map pve-vm--104--disk--0p2 (252:12): 0 3715072 linear 252:8 4096
add map pve-vm--104--disk--0p3 (252:13): 0 38221824 linear 252:8 3719168

mount /dev/mapper/pve-vm--104--disk--0p1 /mnt/

kpartx -dv /dev/pve/vm-104-disk-0

Helpful links:
https://superuser.com/questions/211338/how-to-mount-a-multi-partition-disk-image-in-linux

February 11

Linux container to VM

* First create a new KVM with a Harddisk. I used a QEMU-Disk
* Start the VM with a Linux-Live-ISO
* Create the following partitions:
– Linux boot (ext2/3)
– Linux Data (i.e. ext4)
– swap

*set the boot-flag on the boot-partition
* shut down the KVM
* connect to host-console – I preferred to login by ssh
* mount LXC-Disk by enter

pct mount { LXC-ID }

you get the directory of the containers sysroot

* mount the new KVM-harddisk by using the following command:

modprobe nbd max_part=3

qemu-nbd -c /dev/nbd0 { KVM-Disk } // i.e.: vm-114-disk-1.qcow2

mount /dev/nbd0p2 { mount-point }

**** be careful: don’t use /mnt – it’s used by the host *** better use /media

* change to the sysroot-directory you got before
* copy the whole directory-structure to the mounted disk by using rync

rsync -a * { mount-point }

* unmount KVM-disk by enter

umount { mount point }

qemu-nbd -d /dev/nbd0

rmmod nbd

* unmount container-disk by

pct unmount { LXC-ID }

* now start the KVM again with a Live-ISO – should be equal to the LXC-OS
* mount the KVM-Disk i.e. /mnt

mount /dev/sda2 /mnt
mount /dev/sda1 /mnt/boot

* change sysroot by enter

mount -o bind /sys /mnt/sys
mount -o bind /dev /mnt/dev
mount -t proc /proc /mnt/proc

chroot /mnt

* install bootloader grub2

yum install grub2

* install a kernel

yum install kernel

* configure grub2-bootloader

grub2-install --force /dev/sdX1
grub2-mkconfig -o /boot/grub2/grub.cfg

* change the owner-id’s of /bin

cd /bin
chown root:root *

* exit chroot by

exit

* reboot in the KVM

Original post is stored here

January 24

RR DNS Cluster

default Zone Template: standard

; cPanel %cpversion%
; Zone file for %domain%
$TTL %ttl%
@ %nsttl% IN SOA %nameserver%. %rpemail%. (
%serial% ; serial, todays date+todays
3600 ; refresh, seconds
1800 ; retry, seconds
1209600 ; expire, seconds
86400 ) ; minimum, seconds

%domain%. %nsttl% IN NS %nameserver%.
%domain%. %nsttl% IN NS %nameserver2%.
%domain%. %nsttl% IN NS %nameserver3%.
%domain%. %nsttl% IN NS %nameserver4%.

%nameserverentry%. IN A %nameservera%
%nameserverentry2%. IN A %nameservera2%
%nameserverentry3%. IN A %nameservera3%
%nameserverentry4%. IN A %nameservera4%

%domain%. IN A %ip%
%domain%. IN AAAA %ipv6%
ipv6 IN AAAA %ipv6%

%domain%. IN MX 0 %domain%.

mail IN CNAME %maildomain%.
www IN CNAME %domain%.
ftp IN CNAME %domain%.

Updated:
; cPanel %cpversion%
; Zone file for %domain%
$TTL %ttl%
@ %nsttl% IN SOA %nameserver%. %rpemail%. (
%serial% ; serial, todays date+todays
3600 ; refresh, seconds
1800 ; retry, seconds
1209600 ; expire, seconds
86400 ) ; minimum, seconds

%domain%. %nsttl% IN NS %nameserver%.
%domain%. %nsttl% IN NS %nameserver2%.
%domain%. %nsttl% IN NS %nameserver3%.
%domain%. %nsttl% IN NS %nameserver4%.

%nameserverentry%. IN A %nameservera%
%nameserverentry2%. IN A %nameservera2%
%nameserverentry3%. IN A %nameservera3%
%nameserverentry4%. IN A %nameservera4%
%domain%. IN A your_proxy_IP_here
%domain%. IN A your_proxy2_IP_here
www IN CNAME %domain%.

For the DNS-Only the file is located here: /var/cpanel/zonetemplates/root_standard