Change reverse ip ptr record with pdnsutil

For Powerdns 4.7

You need to change reverse ip record for 192.168.1.11,So login to powerdns server via ssh an type;

pdnsutil replace-rrset 1.168.192.in-addr.arpa 11 PTR 3600 "rdns.abc.com"

 

System should now answer like this.

Current records for 11.1.168.192.in-addr.arpa IN PTR will be replaced
New rrset:
11.1.168.192.in-addr.arpa. 3600 IN PTR rdns.abc.com

 

Also you can check it with a dns tool like dig or a website like https://centralops.net/

Basic dig usage:

dig <your full reverse zone ending with in-addr.arpa> ptr

 

 

mount /tmp as a separate filesystem

# mkdir -p /root/images/
# dd if=/dev/zero of=/var/tmpfile bs=1 count=0 seek=4G
# mkfs.ext4 /var/tmpfile
# mount -o loop,rw,nodev,nosuid,noexec /var/tmpfile /tmp
# chmod 1777 /tmp
# mount -o rw,noexec,nosuid,nodev,bind /tmp /var/tmp
# vi /etc/fstab

/var/tmpfile   /tmp   ext4    rw,noexec,nosuid,nodev,bind    0 0
/tmp /var/tmp none rw,noexec,nosuid,nodev,bind 0 0

 

monitor the reading and writing performance of a disk device

Use the dd command to measure server throughput (write speed):

dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync

 

to measure server latency

dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync

 

Elasticsearch, Fluentd, Kibana

After setting up the EFK (Elasticsearch, Fluentd, Kibana) stack on Kubernetes, Fluentd collects logs from Kubernetes pods and sends them to Elasticsearch for log collection. This process is explained step-by-step below:

  1. Fluentd ConfigurationFluentd collects logs generated by pods in Kubernetes. By default, Fluentd monitors and collects logs in Kubernetes’ /var/log/containers directory.

    Fluentd is run as a DaemonSet, so a Fluentd pod is placed on each Kubernetes node. Fluentd accesses the Kubernetes API to identify which pod, namespace, and container the logs originate from.

    Example DaemonSet:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: kube-system
spec:
  selector:
    matchLabels:
      name: fluentd
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      containers:
      - name: fluentd
        image: fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch
        env:
        - name: FLUENT_ELASTICSEARCH_HOST
          value: "elasticsearch-service"
        - name: FLUENT_ELASTICSEARCH_PORT
          value: "9200"
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers

Collecting Logs with Fluentd

Fluentd pods on Kubernetes nodes monitor the /var/log/containers directory on the node’s filesystem and collect all container logs found there. Fluentd then sends these logs to Elasticsearch according to its configuration.

3.Storing Logs with Elasticsearch

Fluentd sends the collected logs to Elasticsearch, which indexes and stores them. While setting up Elasticsearch, you can define a Service as shown below to enable Fluentd to connect to Elasticsearch:

apiVersion: v1
kind: Service
metadata:
  name: elasticsearch-service
  namespace: kube-system
spec:
  selector:
    app: elasticsearch
  ports:
  - port: 9200
    targetPort: 9200

4.Visualizing Logs with Kibana

Kibana allows you to visualize logs stored in Elasticsearch. After installing Kibana as a Deployment on Kubernetes, you need to configure Elasticsearch in Kibana.

Kibana Configuration:

apiVersion: v1
kind: Service
metadata:
  name: kibana-service
  namespace: kube-system
spec:
  ports:
  - port: 5601
    targetPort: 5601
  selector:
    app: kibana

5.Viewing Logs

You can analyze and visualize the collected logs using Kibana. Go to the Kibana interface, add your Elasticsearch indices, and start viewing the logs.

6.Granting RBAC Permissions

Fluentd needs appropriate permissions to collect Kubernetes metadata. For this, you should use Role-Based Access Control (RBAC) in Kubernetes to grant the necessary permissions to Fluentd.

Creating Role and RoleBinding:

Role (Defining Permissions): Use the following Role definition to grant listing permissions on namespace resources:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: fluentd-role
  namespace: kube-system
rules:
- apiGroups: [""]
  resources: ["namespaces"]
  verbs: ["list", "get", "watch"]
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: fluentd-rolebinding
  namespace: kube-system
subjects:
- kind: ServiceAccount
  name: default
  namespace: kube-system
roleRef:
  kind: Role
  name: fluentd-role
  apiGroup: rbac.authorization.k8s.io

 


This way, you can collect logs from all pods in the Kubernetes cluster via Fluentd, send them to Elasticsearch, and view them with Kibana. Make sure Fluentd is configured correctly and that Elasticsearch is accessible by Fluentd.

Reset a Windows guest admin password in KVM

If you forget the Windows 10 administrator password you used in KVM, you can reset your password by performing an operation on the qcow image.

First, you should install guestfish on your Linux KVM host..Installation steps;

 

 

sudo apt install libguestfs-tools

 

 

I did it with the command.

Then;

 

sudo guestfish -i win_11.qcow2

I executed the command and it brought me to the fs area.

 

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: ‘help’ for help on commands
‘man’ to read the manual
‘quit’ to quit the shell

Operating system: Windows Server 2012 R2 Standard
/dev/sda1 mounted on /

><fs> mv /Windows/System32/utilman.exe /Windows/System32/utilman1.exe
><fs> cp /Windows/System32/cmd.exe /Windows/System32/utilman.exe
><fs> exit

 

By replacing utilman.exe with cmd.exe, we call cmd.exe by clicking the accessibility button on the Windows 10 login page.

After exiting the Guestfish console by typing exit, we start our operating system normally. When you click the button you see on the screen below, cmd will run instead of utilman.

Apply the command you will see on the cmd command line.

 

 

 

 

odbc and php mssql support for cloudlinux

For your Cloudlinux or a different Redhat based server, add the appropriate version repo below to your server.

#RHEL 7 and Oracle Linux 7

#curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo

#RHEL 8 and Oracle Linux 8

# curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo

#RHEL9

# curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo

Delete any potentially conflicting packages from the system.

# yum remove unixODBC-utf16 unixODBC-utf16-devel

Install odbc package from Microsoft repo

ACCEPT_EULA=Y yum install -y msodbcsql17 unixODBC-devel

Go to the PHP selector settings of the hosting where you will connect to Microsoft SQL Server with your PHP codes and activate the pdo, pdo_odbc, pdo_sqlsrv, sqlsrv plugins and optionally the pdo_dblib plugin.

 

You need to include the package you installed for Cloudlinux OS in the cagefs structure. This will not be necessary on other RH-based systems…

# cagefsctl –addrpm unixODBC

# cagefsctl –force-update

Then test your connection with a test script.

Sample Code

 

<?php

    $server = "";
    $database = "";
    $kullaniciadi = "";
    $sifre = "";
    $Karakter = "utf-8";
    $Port = "1433";


    try
    {
      
        $db = new PDO("sqlsrv:Server=$server;Database=$database;", "$kullaniciadi", "$sifre");
        //$db = odbc_connect("Driver={SQL Server};Server=$server,$Port;Database=$database;",  $kullaniciadi, $sifre);
 
        
        if ($db)
    	    echo "success"; 

   }
    catch (Exception $e)
    {
        //Eğer bağlantı sırasında bir hata oluşursa ekrana oluşan hata bastırılacaktır.
        echo $e->getMessage();
    }
     exit;

?>

 

 

Remove specific mails from postfix queue with jq

In this example, all emails whose sender is [email protected] are deleted from the queue.

postqueue -j | jq -r ‘select(.sender == “[email protected]”) | .queue_id’ | xargs -I {} postsuper -d {}

jq must be installed ( apt install jq )

for other filtering criteria

postqueue -j | jq

You can type and see the fields in the json output.

Phalcon Php Framework 3.x Installation

Phalcon 3.x (old version) installation steps on Cyber Panel + Ubuntu 20 server

1.Install the pecl and pear plugins for the php version you want.

apt install lsphp72-pecl lsphp72-pear

 

2. Download Phalcon 3.4.5 tar file.

wget https://github.com/phalcon/cphalcon/archive/refs/tags/v3.4.5.tar.gz

tar zxvf v3.4.5.tar.gz

cd cphalcon-3.4.5/build/

./install

 

3.If all steps are successful, add the ini file

Create phalcon.ini file under /usr/local/lsws/lsphp72/etc/php/7.2/mods-available. Restart openlitespeed.

cat phalcon.ini

#extension=psr.so #Required for v4 and later.
extension=phalcon.so

 

 

Note: Similarly, you can install Phalcon v4, but it requires psr plugin. For this;

cd /usr/local/lsws/lsphp72/bin

./pecl install psr-1.1.0

 

 

Centos /Cloudlinux 7 error restarting a systemd service

Unable to register authentication agent

** (pkttyagent:478736): WARNING **: 18:16:34.777: Unable to register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject Error registering authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject (polkit-error-quark, 0)

# groupadd -g 23 nohidproc
# usermod -a -G nohidproc polkitd
# mount -o remount,rw,hidepid=2,gid=nohidproc /proc
# systemctl restart polkit

 

 

nano /etc/fstab
# comment the following line :
from : proc /proc proc defaults,hidepid=2 0 0
to : # proc /proc proc defaults,hidepid=2 0 0
# add the following line
proc /proc proc defaults,hidepid=2,gid=nohidproc 0 0

Add MX Record with Custom Priority for Plesk

/sbin/plesk bin dns -a abc.com -mx "" -mailexchanger mail.abc.com -priority 1