Lamp script for CentOS 8

Here is a simple lamp install script for CentOS 8.

#!/bin/bash
#update system
dnf update
#install apache
dnf install httpd httpd-tools -y
systemctl enable httpd
systemctl start httpd
systemctl status httpd
#update firewall
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
#install mariadb
dnf install mariadb-server mariadb -y
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb
mysql_secure_installation
# Install PHP 7 on CentOS 8
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
#dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
#dnf module list php
dnf install php php-opcache php-gd php-curl php-mysqlnd -y
systemctl start php-fpm
systemctl enable php-fpm
systemctl status php-fpm
setsebool -P httpd_execmem 1
systemctl restart httpd

Check the installation

# nano /var/www/html/info.php

Insert the PHP code below and save the file.

<?php
 phpinfo ();
?>

Then head out to your browser, and type the URL below. Remember to replace the server IP address with your server’s actual IP address.

http://server-ip-address/info.php

Flush DNS Windows 10

Flushing the DNS cache on Windows 10 is a very easy process and may be needed to connect to web sites that have changed servers. Due to system security permissions, you must ensure that you run the command prompt as an administrator user.

Here is how:

Ensure that you’re on the Windows 10 desktop.
Right click on the start menu and choose Command Prompt (Admin) from the menu.
Type in the command;

ipconfig /flushdns

Command for cPanel Exim that shows script responsible for outbound mail and other exim commands

Here we provide a particularly useful command-line command that shows you which scripts are responsible for outbound mail. For example, when WordPress themes get exploited, you will see a large number of messages coming out of a long directory inside of the user’s WordPress directory. Very large numbers of messages coming from home directories is generally a source of concern.

# grep cwd=/ /var/log/exim_mainlog | cut -d = -f 2 | cut -d " " -f 1 | sort | uniq -c | sort -n

Using Exiqgrep

Much like the exigrep utility we mentioned previously, exiqgrep is also a powerful tool to help you parse through your queue output and retrieve the specific information you’re looking for.

For example, to search through your queue and output only the messages with a specific sender address, you can use the following syntax:

# exiqgrep -f [user]@domain.tld

Above: An example of using exiqgrep with the -f flag followed by a sender address, to specifically identify messages sent by a particular user.

This is particularly useful to identify the source of local spam or to determine what happened after a user reports that a sent message has not arrived (you would first check to see if they are stuck in the queue, then use the logs to find out why).

By Recipient

Need to track down messages by their recipient instead? You can use the exiqgrep command to do this as well. Here, instead of using the -f flag, we would instead use the -r flag (a bit easier to remember, right?).

# exiqgrep -r [user]@domain.tld

Above: An example of an exiqgrep command with the -r flag followed by the recipient you’d like to search the queue for.

This can be useful to investigate when a user reports that an account is no longer receiving mail. Additionally, you can use this to identify when a user has been mail-bombed, and determine if exim has been set to automatically queue messages when over-quota.

By Age

Another handy feature of the exiqgrep utility is to search the queue for messages based on age criteria. Exiqgrep uses flags based on the younger and older terminology, and appropriately uses -o for older, and -y for younger, followed by a number of total seconds.

Two practical examples of this:

# exiqgrep -o 172800

Above: An example of searching the queue for messages older than one day (172,800 seconds).

# exiqgrep -y 1800

Above: An example of searching the queue for messages younger (newer) than 30 minutes (1,800 seconds) old.

Viewing Headers

It can be extremely useful to analyze a message’s header when attempting to determine what exactly happened to that message, or how it was handled by the server.

After acquiring the message’s Exim ID value, you can then use it to specifically output that message’s header using the following syntax:

# exim -Mvh 

Above: Using the exim command-line tool with the -Mvh flags (case-sensitive), followed by a valid Exim ID value (the <> braces are simply for the placeholder; these should not exist in the actual command), will print that message’s header information to STDOUT (read: the terminal).

Viewing the Body

Sometimes the header just isn’t enough, and you need to see what the actual contents of the message’s body look like. You can use a very similar format using the exim command-line tool again, but this time with the -Mvb flag set, followed again by the message’s Exim ID.

# exim -Mvb 

Above: Using the exim command line tool again but with the -Mvb flag this time, still followed by the Exim ID, to retrieve the contents of the message’s body and print it to STDOUT (I’ll be using this term ‘STDOUT’ more often as we progress; if you’re not familiar with it, just remember for now that it stands for standard output, and essentially means that it prints the text normally to your terminal).

Using xargs

The xargs utility can be extremely useful for creating quick one-liner command. It’s essentially a for loop packaged up into a single command. It works by taking the output from one command, and turning it into a line-by-line execution of another command.

For example, let’s say I’ve got a text file that has a list of files in it, each on their own line.

I could cat that file, then pipe the output to xargs to perform a different operation on each of the files listed. This can be quite useful for handling Exim queue operations in bulk, which we’ll explain in a moment.

Using Pipes

To use an example, one of the most common uses you might run across is for the purposes of either “grepping” (using the grep tool to search through a file) or paging through the output of a command:

# cat /var/log/exim_mainlog | less

Above: An example command used to allow you to scroll through the contents of a log file page-by-page, rather than printing the entire contents to the screen at one time.

# exim -bp | grep SPAM

Above: An example command using a pipe to search the output of exim -bp (the command used to print a summary of each message in the queue, remember?) for any mention of the word “SPAM”, case-intact (though the -i flag of course can be used with grep to remove case sensitivity).

Resending a Message

At times, you may want to attempt to re-send a message that exists in your queue. Maybe it was delayed for some time, but you’re ready to go ahead and try to resend it now, rather than waiting for the scheduled retry. Who knows? It’s your call.

However, to do this, you can use the exim command once again, but this time by simply providing it with the -M flag alone, followed again by the Exim ID.

What can be useful here, though, is the use of this command within a one-liner, by providing the kind of piped output and xargs command that we described before.

Let’s take a look at one practical example:

# exiqgrep -r user@domain.tld -i | xargs exim -M

Above: In this example command that utilizes piping and the xargs command, we’re instructing Exim to provide us with all messages in the queue (exiqgrep) with the recipient designated as user@domain.tld (-r user@domain.tld), and informing the exiqgrep tool that we ONLY want to output the Exim IDs that match (-i).

This, by itself, gives us a basic, line-by-line output of Exim IDs that match messages with user@domain.tld as the recipient address.

So you can probably guess what we’re doing with that next, right? We’re piping (|) that output as input for xargs to perform the exim -M command on each matching message. We know now that exim -M attempts a resend of messages, so we can discern that this full command will try to resend all messages that have the user@domain.tld address as its recipient. All in one fell swoop. Nice, right?

Deleting a Message

Now for the scarier stuff. Well… not-so-scary as long as you take caution to confirm what it is you’re taking action on.

At some point in time, you’ll almost certainly need to delete messages from your queue. When that time comes, it’s likely that it won’t just be a single message, either. You’ll probably need to clear out a large number of messages that you’ve determined as spam or otherwise “bad” mail.

The basic command syntax you would use to do this involves the exim tool again, but with the -Mrm flags this time, and again – as usual – followed by the Exim ID of the message:

# exim -Mrm 

Above: The basic syntax for deletion of a message from the queue, based on its Exim ID. Again, we see the pattern (-M followed by rm; just like you’d rm a file from the file system).

So how about doing this as a bulk operation?

Deleting in bulk should of course always be performed with caution. Once you delete mail from your queue, there’s no guarantee that the sender will ever resend it.

So, if you delete a valid message that was intended for a recipient, you’re creating a chance that your user will never receive that mail or the message within it. So basically… be careful.

Let’s look at an example again using a similar circumstance as before.

We’re going to again utilize the exiqgrep command, but this time we’re going to look for all messages with a particular domain in its sender address, using the -f flag, then finally printing only the Exim ID values by specifying the -i flag, as we did before:

# exiqgrep -i -f  @spammer.tld | xargs exim -Mrm

Above: We’re again using xargs to run exim -Mrm (the command to delete messages by Exim ID) on each Exim ID returned from the exiqgrep command that precedes it, which in our case should match all messages with a sender that uses the domain @spammer.tld (they probably could have been a bit more subtle about it, am I right?).

Note again the pipe (|) being used to pipe the output of exiqgrep into the input for xargs.

When in doubt – see https://bradthemad.org/tech/notes/exim_cheatsheet.php

Finding out the Delivery Path of an Address

exim -bt

Another very important exim command line flag we want to make sure and highlight is the -bt flag, which would be followed by a recipient email address.

Exim -bt works like some of the Email Deliverability tests found within the WHM interface. It effectively shows you where exim thinks a message should be going, and how it should get there.

For instance, messages to this user are destined for a local account:

# exim -bt dogs@animals.test
dogs@animals.test
  router = virtual_user, transport = virtual_userdelivery

While messages to this user will leave the server to a remote destination:

# exim -bt noone@gmail.com
noone@gmail.com
  router = lookuphost, transport = remote_smtp
  host gmail-smtp-in.l.google.com      [64.233.169.26]  MX=5
  host alt1.gmail-smtp-in.l.google.com [173.194.219.26] MX=10
  host alt2.gmail-smtp-in.l.google.com [173.194.204.26] MX=20
  host alt3.gmail-smtp-in.l.google.com [74.125.141.26]  MX=30
  host alt4.gmail-smtp-in.l.google.com [64.233.186.26]  MX=40

Notice that the user doesn’t actually need to exist; exim is only checking on the domain part for remote deliveries.

SSH key that uses Ed25519 algorithm

The Ed25519 was introduced on OpenSSH version 6.5. It’s the EdDSA implementation using the Twisted Edwards curve. It offers a better security with faster performance compared to DSA or ECDSA. Some benefits are that its faster, and compact – it only contains 68 characters, compared to RSA 3072 that has 544 characters. Generating the key is fast! It’s also fast to perform batch signature verification with Ed25519.

To test, you will need a client and test server. The client server is where we generate the keys. When we generate keys, there will be a private key and a public key. Then we copy the public key to the test server. When we ssh to the test server, the private key we have on the client server matches the public key that we copied to the test server. To generate a new pair of SSH keys that uses Ed25519 algorithm on the client server, run:

# ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "somename"
Generating public/private ed25519 key pair.
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_ed25519.
Your public key has been saved in /root/.ssh/id_ed25519.pub.
The key fingerprint is:
SHA256:S5mglsGaa7byro5iFvC01VyFt+plsvrt5SLtTTzUHVU geekdecoder
The key's randomart image is:
+--[ED25519 256]--+
|         o.     E|
|   .    o .     .|
|    oo.. . .   . |
|. .o.+o. o.  . ..|
|.ooo+   S.  . . .|
| .oo   .o.oo     |
|  =    ..*  =    |
|+= .    +.o= .   |
|B*+   .o.++.o    |
+----[SHA256]-----+

-f
Specifies filename of the keyfile, used for specifying other than default name
-a
number of primality test while screening DH-GEX candidates
-t
type of key (RSA, ED25519, DSA, etc)
-C
Comment (not used in algorithm, only used in public key)
-o
openSSH key format instead of older PEM (needs OpenSSH 6.5+)

On the server, check for the .ssh direstory. If it is not there , you will need to create it.
On Server, make directory and set permissions

# mkdir -p ~/.ssh
# chmod 0700 ~/.ssh

On Client, Copy Public SSH Key to Server
Using the command “ssh-copy-id” is the preferred way. You will need to have ssh access to the server to copy the key.
Here is the command:

# ssh-copy-id -i ~/.ssh/id_ed25519.pub root@server1.server.com -p22
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@somehost's password:
 
Number of key(s) added: 1
 
Now try logging into the machine, with:   "ssh -p '22' 'root@server1.server.com'"
and check to make sure that only the key(s) you wanted were added.

If you want to just login to the server with the hostname vs the full domain like:

ssh “server1” vs “ssh -p ’22’ ‘root@server.com'”, then add a hostname entry to the client with the following:

ip.of.the.server  server1.server.com        server1

Now try the short ssh:

# ssh server1
Linux v1.bytesoil.host 4.19.0-11-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64
 
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
 
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Nov 19 15:38:24 2020 from 70.114.180.14
root@server1:~#
Categories SSH

Add Emails From cPanel Email to Outlook

Recently, I had the task of importing emails form a cPanel email account to Outlook. This was after the DNS had changed to the office365 servers (mail.protection.outlook.com). There is no export from Horde to PST format – only MBOX. So, there are 3rd party programs to take the MBOX and Convert to PST, but I wanted a solution that was free.

So here are the requirements:

  1. Have Outlook installed and the DNS changed to the new office 365 MX Records.
  2. Have the email set up on Office365 (In this example – user1@testdomain.com).
  3. IP Address of the cPanel Server

So, our test domain changes are set up as follows:

Old DNS Settings:

# dig mx ptestdomain.com +short
0 mail.testdomain.com.

New DNS Setting:

# dig mx testdomain.com +short
0 testdomain-com.mail.protection.outlook.com.

Now, we need to add the old email to outlook.

For this example, the email is: user1@testdomain.com
Since user1@testdomain.com is already set up in outlook, we need to add this email from the old server, but we change the name a bit – use a name – such as “old-user1@testdomain.com”. This is due to Outlook not allowing 2 emails the same. It’s OK, we can change it later.

Here are the steps.

You will need the IP of the cPanel account where the email is stored.
Add the email “old-user1@testdomain.com” to outlook.

Change the name a bit so we can add it.

Choose POP3

Now use the IP address for the old cPanel server for the Incoming and Outgoing mail servers. Ports 110 and 25. You can use port 587 for outgoing if needed.:

Enter password and complete.

Now a Popup appears for the username and password. Enter in the original cPanel username which is the old email name and password.

Now, go to Outlook and let’s change the settings.

Click the drop down and click “Account Settings”. A popup appears. Select the new account and click “Change”. Keep the names as you can separate this from the new outlook email. Make sure the Mail Settings are set to Leave a copy on server. Click “Next” and “Done”.

Now, send and receive. The email should populate in the new folders. Once completed, you can create a new folder (ex., cpanel-mail) under the outlook email and drag the emails to there and drop them to move them to the new outlook folder. Once moved, they will reside on the outlook server.

How to Customize ESXI 6.7 install with Realtek Drivers

Create a folder C:\Esxibuild

Download to C:\Esxibuild
VMware vSphere Hypervisor (ESXi) 6.7U3b Bundle (not the ISO).
https://my.vmware.com/web/vmware/details?downloadGroup=ESXI67U3B&productId=742

Download the Realtek Drivers:
https://vibsdepot.v-front.de/wiki/index.php/List_of_currently_available_ESXi_packages
(For this one, I used the net55-r8168-8.045a-napi-offline_bundle)

Here is what the files look like:

Download and install the VMware PowerCLI
https://my.vmware.com/group/vmware/details?productId=614&downloadGroup=PCLI650R1

Open powershell. Got to the folder C:\Esxibuild in PS.

Add the VMware Modules for Powershell:

Get-Module -ListAvailable VM* | Import-Module

Check Modules:

$env:PSModulePath.Split(';')

Import Modules:

Get-Module -ListAvailable VM* | Import-Module

Find the build information. Open the compressed file for the Esxi bundle you downloaded: c:\esxibuild > ESXi670-201912001 > metadata > profiles. There should be 4 profiles. Copy the path for the next commands.

Change your paths to match.
run:

Add-EsxSoftwareDepot "C:\esxibuild\net55-r8168-8.045a-napi-offline_bundle.zip", "C:\esxibuild\ESXi670-201912001.zip"

Get-EsxImageProfile

New-EsxImageProfile -CloneProfile ESXi-6.7.0-20191204001-standard -name ESXi-6.7.0-20191204001-standard-RTL8111 -Vendor Razz

Set-EsxImageProfile -ImageProfile ESXi-6.7.0-20191204001-standard-RTL8111 -AcceptanceLevel CommunitySupported

Get-EsxSoftwarePackage | Where {$_.Vendor -eq "Realtek"}

Add-EsxSoftwarePackage -ImageProfile ESXi-6.7.0-20191204001-standard-RTL8111 -SoftwarePackage net55-r8168

Export-EsxImageProfile -ImageProfile ESXi-6.7.0-20191204001-standard-RTL8111 -ExportToIso -filepath C:\esxibuild\VMware-ESXi-6.7.0-8169922-RTL8111.iso

Now, there should be an ISO to burn.

Other sources: https://www.sysadminstories.com/2018/08/adding-realtek-8111-driver-to-vsphere.html

Firewalld on CentOS 8

CentOS 8 uses firewalld.You can see all zones by running the following ls command:

# ls -l /usr/lib/firewalld/zones/
total 36
-rw-r--r--. 1 root root 299 Nov  8 11:48 block.xml
-rw-r--r--. 1 root root 293 Nov  8 11:48 dmz.xml
-rw-r--r--. 1 root root 291 Nov  8 11:48 drop.xml
-rw-r--r--. 1 root root 304 Nov  8 11:48 external.xml
-rw-r--r--. 1 root root 397 Nov  8 11:48 home.xml
-rw-r--r--. 1 root root 412 Nov  8 11:48 internal.xml
-rw-r--r--. 1 root root 343 Nov  8 11:48 public.xml
-rw-r--r--. 1 root root 162 Nov  8 11:48 trusted.xml
-rw-r--r--. 1 root root 339 Nov  8 11:48 work.xml

Predefined Zones Explained

block – All incoming network connections rejected. Only network connections initiated from within the system are possible.
dmz – Classic demilitarized zone (DMZ) zone that provided limited access to your LAN and only allows selected incoming ports.
drop – All incoming network connections dropped, and only outgoing network connections allowed.
external – Useful for router type of connections. You need LAN and WAN interfaces too for masquerading (NAT) to work correctly.
home – Useful for home computers such as laptops and desktops within your LAN where you trust other computers. Allows only selected TCP/IP ports.
internal – For use on internal networks when you mostly trust the other servers or computers on the LAN.
public – You do not trust any other computers and servers on the network. You only allow the required ports and services. For cloud servers or server hosted at your place always use public zone.
trusted – All network connections are accepted. I do not recommend this zone for dedicated servers or VMs connected to WAN.
work – For use at your workplace where you trust your coworkers and other servers.

Run the following command to see all zones on CentOS 8:

# firewall-cmd --get-zones

To get your default zone run:

# firewall-cmd --get-default-zone

To see your network interface names run either ip command or nmcli command:

# ip link show
# nmcli device status

When new interface connection added (such as eth0 or ens3) to NetworkManager, they are attached to the default zone. Verify it by running the following command:

# firewall-cmd --get-active-zones
public
  interfaces: eth0

How to Start and enable firewalld

# systemctl start firewalld
# systemctl enable firewalld

Stop and disable firewalld

# systemctl stop firewalld
# systemctl disable firewalld

Check the firewalld status

# firewall-cmd --state

Command to reload a firewalld configuration when you make change to rules

# firewall-cmd --reload

Get the status of the firewalld service

# systemctl status firewalld

How to see firewall rules or services associated with the public zone
Run:

# firewall-cmd --list-all

OR

# firewall-cmd --list-all --zone=public

How to see which services are allowed in the current zone

# firewall-cmd --list-services

OR

# firewall-cmd --list-services --zone=public

Adding

Temporary Adds:

# firewall-cmd --zone=public --add-service=http

Permanent Adds

# firewall-cmd --zone=public --add-service=https --permanent
# firewall-cmd --reload
# firewall-cmd --list-services
# sudo firewall-cmd --list-services --permanent

How to add a service to your zone

# firewall-cmd --zone=public --add-service=dns --permanent

Add ports 5060 5061 for Asterisk by creating a service. Create the following Firewalld service:

# nano /etc/firewalld/services/asterisk.xml

Add the code

<?xml version="1.0" encoding="utf-8"?>
<service version="1.0">
  <short>asterisk</short>
  <description>Asterisk is a software implementation of a telephone private branch exchange (PBX).</description>
  <port protocol="udp" port="10000-10100"/>
  <port protocol="udp" port="4569"/>
  <port protocol="udp" port="2727"/>
  <port protocol="udp" port="5060-5061"/>
</service>

Save the file and – WAIT 5 seconds – apply the new firewall rules by typing:

# firewall-cmd --add-service=asterisk --permanent
# firewall-cmd --reload

If you get an error – just wait and then retry. I received this error the first time:

# firewall-cmd --add-service=asterisk --permanent
Error: INVALID_SERVICE: 'asterisk' not among existing services

Finally check if the new firewall rules are applied successfully with:

# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources:
  services: asterisk cockpit dhcpv6-client ssh
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

Delete dns service

# firewall-cmd --zone=public --remove-service=dns --permanent

How to allow/open TCP/UDP port/protocol

Open TCP port 80:

# firewall-cmd --zone=public --add-port=80/tcp --permanent

To view added ports, run:

# firewall-cmd --zone=internal --list-ports

Deny/block TCP/UDP port/protocol

# firewall-cmd --zone=public --remove-port=23/tcp --permanent

Install Asterisk on CentOS

This install in on Ubuntu 18.04. There is an excellent article for CentOS at – https://www.tecmint.com/install-asterisk-on-centos-7/
Please review aslo:
– https://wiki.asterisk.org/wiki/display/AST/Installing+Asterisk+From+Source
– https://community.asterisk.org/
– https://www.sangoma.com/articles/how-to-install-asterisk-11-on-ubuntu-12-4-lts/
– http://asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/asterisk-Install.html

Install Requirements:

Firewalld. See the Article here to set up asterisk on firewalld – https://www.geekdecoder.com/firewalld-on-centos-8/-

The command installs a bunch of new packages including gcc, g++ and make

# apt install build-essential

Libraries:

Help Finding the Right Libraries

Asterisk comes with a shell script called install_prereq.sh in the contrib/scripts sub-directory. If you run install_prereq test, it will give you the exact commands to install the necessary system libraries on your operating system. If you run install_prereq install, it will attempt to download and install the prerequisites automatically.

cd /usr/local/src/asterisk-17.3.0/contrib/scripts/
./install_prereq test
./install_prereq install

The script calls for calling code (https://en.wikipedia.org/wiki/List_of_country_calling_codes)

Download Files:

Go to the following to see the current asterisk release:
https://downloads.asterisk.org/pub/telephony/asterisk/

Here is what I am using:

Asterisk – https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17-current.tar.gz
dahdi-complete – https://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
dahdi-linux – https://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-current.tar.gz
dahdi-tools – https://downloads.asterisk.org/pub/telephony/dahdi-tools/dahdi-tools-current.tar.gz
libpri – https://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz

Change directory:

# cd /usr/local/src

Get the files:

wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17-current.tar.gz
# wget https://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
# wget https://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-current.tar.gz
# wget https://downloads.asterisk.org/pub/telephony/dahdi-tools/dahdi-tools-current.tar.gz
# wget https://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz

Lets extract

tar -zxvf asterisk-17-current.tar.gz
# tar -zxvf dahdi-linux-complete-current.tar.gz
# tar -zxvf dahdi-linux-current.tar.gz
# tar -zxvf dahdi-tools-current.tar.gz
# tar -zxvf libpri-current.tar.gz

You should now notice that a new sub-directory was created for each of the tarballs, each containing the extracted files from the corresponding tarball. We can now compile and install each of the components.

Building and Installing DAHDI
Let’s install DAHDI!
On Linux, we will use the DAHDI-linux-complete tarball, which contains the DAHDI Linux drivers, DAHDI tools, and board firmware files.

# cd dahdi-linux-complete-3.1.0+3.1.0/
# make
# make install
# make config

Next, building and Installing LibPRI
Have you installed DAHDI? – Before you can build libpri, you’ll need to Build and Install DAHDI.

# cd libpri-1.6.0/
# make
# make install

Using Menuselect to Select Asterisk Options

The next step in the build process is to tell Asterisk which modules to compile and install, as well as set various compiler options. These settings are all controlled via a menu-driven system called Menuselect. To access the Menuselect system, type:

# make menuselect

When you’re first learning your way around Asterisk on a test system, you’ll probably want to stick with the default settings in Menuselect. If you’re building a production system, however, you may not wish to build all of the various modules, and instead only build the modules that your system is using. When you are finished selecting the modules and options you’d like in Menuselect, press F12 to save and exit, or highlight the Save and Exit button and press enter.

See More here: https://wiki.asterisk.org/wiki/display/AST/Using+Menuselect+to+Select+Asterisk+Options

Install asterisk with pre-bundled PJSIP-pjproject

# cd /usr/local/src/asterisk-17.3.0
# ./configure
# make &amp;&amp; make install

You should see:

 +---- Asterisk Installation Complete -------+
 +                                           +
 +    YOU MUST READ THE SECURITY DOCUMENT    +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 + For generic reference documentation:      +
 +    make samples                           +
 +                                           +
 + For a sample basic PBX:                   +
 +    make basic-pbx                         +
 +                                           +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +               make progdocs               +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +
 +-------------------------------------------+

Installing Sample Files

Asterisk Sample Configs: not a sample PBX configuration

For many of the sample configuration files that make samples installs, the configuration contains more than just an example configuration. The sample configuration files historically were used predominately for documentation of available options. As such, they contain many examples of configuring Asterisk that may not be ideal for standard deployments.

While installing the sample configuration files may be a good starting point for some people, they should not be viewed as recommended configuration for an Asterisk system.

To install a set of sample configuration files for Asterisk, type:

# make samples

Any existing sample files which have been modified will be given a .old file extension. For example, if you had an existing file named extensions.conf, it would be renamed to extensions.conf.old and the sample dialplan would be installed as extensions.conf.

Installing Initialization Scripts

Now that you have Asterisk compiled and installed, the last step is to install the initialization script, or initscript. This script starts Asterisk when your server starts, will monitor the Asterisk process in case anything bad happens to it, and can be used to stop or restart Asterisk as well. To install the initscript, use the make config command.

# make config

As your Asterisk system runs, it will generate logfiles. It is recommended to install the logrotation script in order to compress and rotate those files, to save disk space and to make searching them or cataloguing them easier. To do this, use the make install-logrotate command.

# make install-logrotate

Validating Your Installation

Before continuing on, let’s check a few things to make sure your system is in good working order. First, let’s make sure the DAHDI drivers are loaded. You can use the lsmod under Linux to list all of the loaded kernel modules, and the grep command to filter the input and only show the modules that have dahdi in their name.

# lsmod | grep dahdi

If the command returns nothing, then DAHDI has not been started. Start DAHDI by running:

# /etc/init.d/dadhi start

Asterisk can now be started as a service:

# service asterisk start
 * Starting Asterisk PBX: asterisk                                                                               [ OK ]

And stopped:

# service asterisk stop
 * Stopping Asterisk PBX: asterisk                                                                               [ OK ]

And restarted:

# service asterisk restart
 * Stopping Asterisk PBX: asterisk                                                                               [ OK ] 
 * Starting Asterisk PBX: asterisk                                                                               [ OK ]

Asterisk Console

# asterisk -rvvvvv

Let set up a SIP client and Make a test call. Configure extensions.conf. Backup the sample extensions.conf and create a new one

# mv extensions.conf extensions.sample
# vim extensions.conf

We are going to use a very simple dialplan. A dialplan is simply instructions telling Asterisk what to do with a call. Edit your blank extensions.conf to reflect the following:

[from-internal]
exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Hangup()

When a phone dials extension 100, we are telling Asterisk to Answer the call, Wait one second, then Play (Playback) a sound file (hello-world) to the channel and Hangup.

Configure a SIP channel driver. Depending on the version of Asterisk in use, you may have the option of more than one SIP channel driver. You’ll have to pick one to use for the example.

Asterisk 11 and previous: chan_sip is the primary option.
Asterisk 12 and beyond: You’ll probably want to use chan_pjsip (the newest driver), but you still have the option of using chan_sip as well

Follow the instructions below for the channel driver you chose.
Configure chan_sip

Backup and edit a new blank sip.conf. Then add the following to your sip.conf file:

[general]
context=default
 
[6001]
type=friend
context=from-internal
host=dynamic
secret=unsecurepassword
disallow=all
allow=ulaw

Configure chan_pjsip

Backup and edit a new blank pjsip.conf. Then add the following to your pjsip.conf file:

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
 
[6001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6001
aors=6001
 
[6001]
type=auth
auth_type=userpass
password=unsecurepassword
username=6001
 
[6001]
type=aor
max_contacts=1

Configure your SIP phone

Use Jitsi.

Once Jitsi is opened, click Tools > Options > Add.
Select the “SIP” Network”.
For “SIP id”, Enter 6001.
Enter your SIP peer’s password(see above – unsecurepassword) in the Password field.
Click Advanced. Add your Display Name. Click the Connection Tab.
Put in the IP for the asterisk server in the “Registrar” Field.
Review and Click Sign in.



You should see the registration in asterisk:

Start Asterisk. Back at the Linux shell go ahead and start Asterisk. We’ll start Asterisk with a control console (-c) and level 5 verbosity (vvvvv).

# asterisk -cvvvvv

Or if Asterisk is already running, restart Asterisk from the shell and connect to it.

# asterisk -rx "core restart now"
# asterisk -rvvvvv

Make the call. Once registered, enter extension 100 and click the Dial button. The call should be made and you should hear the sound file hello-world!

On the Asterisk CLI, you should see something like:

How to setup home folder to Active Directory user

This article guides you how to assign Home Folder to Active Directory users.

Install the File Server Resource Manager

  1. Open Server Manager
  2. Go to “Add roles and features”
  3. In “Server Roles” expand “File and Storage Services“, again expand “File and iSCI Services“, then tick “File Server Resource Manager” and click “next” to install.

Configure a Shared Folder

  1. Create a shared folder ex:- D:\HOME
  2. Open “HOME” folder properties by right clicking on it and go to properties > sharing.
  3. Click on “Share” button and activate folder sharing. Add users.  Find shared folder path ex:- “\\YOUR-SERVER\home\”
  4. select “security” tab and then open “Advance Security”. Please make sure inheritance is disabled like below.

Configure Disk Quota

  1. Open “File Server Resource Manager”
  2. Expand “Quota Management” , you can configure “Quota Templates” if you wish or you can use existing template like here I did.
  3. Click on “Quotas” –> “Create Quotas” from right hand side.
  4. On then “Create Quota” window, browse and set Quota Path, select “Auto apply template and create quotas on existing and new sub folders” radio button, and make sure to select previously configured template from the drop down menu (200 MB Limit Reports to User – existing template).

Attach Network folder to Active directory user

Open “Active Directory Users and Computers”
Right click on user and open “properties” , then browse “profile” and set following Network path there.

“\\YOUR-SERVER\home\%username%”