Konfigurasi Partisi LVM (Logical Volume Manager) melalui terminal Linux

Konfigurasi Partisi LVM (Logical Volume Manager) melalui terminal Linux

19:20 0

Pada pembahasan kali ini kita akan membahas mengenai LVM (Logical Volume Manager). Sebelum masuk kebagian tatacara konfigurasi pembuatan partisi LVM (Logical Volume Manager) melalui terminal linux, ada baiknya kita bahas terlebih dahulu sedikit penjelasan mengenai  LVM (Logical Volume Manager) partisi. LVM (Logical Volume Manager) merupakan metode pengalokasian partisi (pembagian) harddisk dengan cara menggabungkan beberapa unit harddisk fisik menjadi sebuah logical volume partisi. 

structure
Tujuan pembuatan partisi LVM (Logical Volume Manager) adalah :
- Mudah untuk merubah ukuran partisi (memperbesar atau mengurangi)
- Menggabungkan beberapa partisi menjadi satu untuk memperoleh space yang lebih besar.
- Mudah dalam hal management partisi hard disk
Kelemahan pembuatan partisi LVM (Logical Volume Manager) adalah :
- Dapat membuat proses booting lebih rumit dan membuat perbaikan dari bencana sulit dilakukan jika salah satu harddisk dari partisi LVM ada yang rusak.

Baiklah sekarang kita masuk ke bagian cara pembuatan partisi LVM melalui terminal linux. Harddisk yang digunakan pada uji coba kali ini adalah 2 buah harddisk yang masing-masingnya mempunyai kapasitas 1 Terabyte yang nantinya akan dijadikan satu partisi LVM (Logical Volume Manager). Langkah-langkah yang dilakukan adalah :



  1. Langkah pertama yang harus dilakukan adalah mengecek type harddsik melalui terminal dengan mengetikkan perintah:
  2. fdisk -l
    Pada uji coba kali ini kita akan menggunakan partisi sdb dan sdc dimana kapasitas masing-masingnya adalah 1 Tera Byte. Karena secara default kedua harddisk tersebut terdeteksi seperti itu dan nantinya akan kita gabungkan menjadi sebuah partisi LVM (Logical Volume Manager).
    1
  3. Membuat phisical volume untuk kedua partisi harddisk sdb & sdc dengan mengetikkan perintah :
    pvcreate /dev/sdb 
    pvcreate /dev/sdc
    Melalui terminal linux dan pastikan success seperti gambar di bawah ini.

    2
  4. Untuk mengecek phisical volume yang telah kita uat tadi, ketikkan perintah
    pvs
    Pada terminal linux anda seperti gambar berikut.
    3
  5. Selanjutnya membuat partisi volume group Backup dengan menggabungkan kedua partisi phisical volume sda & sdbdengan mengetikkan perintah :
    vgcreate Backup  /dev/sdb  /dev/sdc/
    Pada terminal linux anda, dan pastikan success seperti tampilan di bawah ini.

    4
  6. Cek partisi volume group Backup yang telah kita buat tadi dengan dengan mengetikkan perintah:
    vgs
    Pastikkan volume size kedua phisical volume harddisk sdb dan sdc telah tergabung manjadi satu. Pada gambar di bawah dapat dilihat bahwa kapasitas harddisk volume group Backup sudah tergabung menjadi 1,82 Tera Byte.
    5
  7. Untuk mencek lebih detail mengenai kapasitas volume group yang telah digabung tadi dapat dicheck dengan mengetikkan perintah:

    vgdisplay
    Pada terminal linux anda, maka akan menampilkan info dari partisi volume group tersebut lebih detail. Seperti tampilan berikut.

    5-1
  8. Kemudian untuk memastikan kedua phisical volume sdb dan sdc sudah masuk kedalam volume group Backup. Lakukan pengecekan dengan mengetikkan perintah:
    pvs
    Pada terminal linux anda. Jika sudah, maka pada kolom VG akan terbuat volume group Backup pada masing-masing harddisk sdb dan sdc seperti tampilan berikut ini.

    5-2
  9. Untuk melalukan pengecekkan phisical volume lebih detail ketikkan perintah

    pvdisplay
    Pada terminal linux anda, maka akan tampil phisical volume lebih detail seperti gambar di bawah ini.

    5-3
  10. Selanjutnya membagi partisi logical volume Backup menjadi dua, tahap pertama beri nama Team-Backup dengan kapasitas 500 Giga Byte dengan cara mengetikkan perintah :
    lvcreate -L 500 -n Backup-Team Backup
    Pada terminal linux, dan pastikan pembuatan partisi success seperti gambar di bawah ini.

    6
  11. Untuk kapasitas harddisk logical volume Backup sisanya jadikan dan berikan nama Backup-Mail dengan cara mengetikkan perintah :

    lvcreate -l 100%FREE -n Backup-Mail Backup
    Pada terminal linux anda, dan pastikkan success seperti tampilan di bawah ini.

    7
  12. Setelah itu untuk mencek partisi LVM yang sudah dibuat tadi ketikkan perintah :

    lvm
    Pada terminal linux anda, maka kita akan bisa melihat partisi LVM yang telah kita buat tadi beserta kapasitasnya seperti gambar di bawah ini8
  13. Untuk mengecek kapasitasi LVM lebih detailnya dapat dicek dengan mengetikkan perintah :

    lvdisplay
    Pada terminal linux anda, maka akan terlihat partisi dan kapasitas LVM yang telah dibuat tadi lebih detail, seperti tampilan di bawah ini.

    8-1
  14. Selanjutnya formasi partisi LVM Backup-Teams yang sudah dibuat tadi dengan type partisi ext3 dengan cara mengetikkan perintah :

    mkfs.ext3 /dev/Backup/Backup-Teams
    Pada terminal linux anda dan pastikan proses formatnya success seperti tampilan berikut ini.
    9
  15. Kemudian format partisi LVM Backup-Mail yang sudah dibuat tadi dengan type partisi ext3 dengan cara mengetikkan perintah :

    mkfs.ext3 /dev/Backup/Backup-Mail
    Pada terminal linux anda dan pastikan proses formatnya success seperti tampilan berikut ini.

    10
  16. Buat directory Backup-Teams dan Backup-Mail didalam directory home dengan mengetikkan perintah:

    mkdir Backup-Teams
    mkdir Backup-Mail
    Pada terminal linux anda seperti gambar berikut, yang nantinya nya akan difungsikan sebagai path mounting partisi LVM Backup-Teams dan Backup-Mail yang sudah kita buat tadi

    11
  17. Sebelum me-mount-kan LVM Backup yang telah dipartisi menjadi dua bagian yaitu partisi Backup-Mail dan Backup-Team kita check sekali lagi dengan cara mengetikkan perintah

    ls /dev/Backup
    Pada terminal linux anda, jika partisi sudah ready dan ok maka akan tampil seperti gambar berikut.

    12
  18. Untuk melalukan mounting partisi LVM Backup-Mail dan Backup-Teams kedalam partisi /home/Backup-Team dan/home/Backup-Mail yang telah kita create tadi, maka ketikkan perintah :

    mount /dev/Backup/Backup-Teams /home/Backup-Teams
                             dan
    mount /dev/Backup/Backup-Mail /home/Backup-Mail
  19. Setelah proses mounting pada kedua LVM success, selanjutnya cek kapasitas directory Backup-Teams pada directory home yang telah kita mount-kan LVM backup pada partisi Backup-Teams tadi. Berikut tampilan hasil pengecekkan kapasitas directory Backup-Teams yang sudah ter-mount LVM Backup untuk partisi Backup-Team dengan kapasitas 500 Giga Byte.

    Screenshot-2
  20. Berikut tampilan hasil pengecekkan kapasitas directory Backup-Mail yang sudah ter-mount LVM Backup untuk partisi Backup-Mail dengan kapasitas 1,2 Tera Byte.

    Screenshot

Secure Calling Asterisk with SIP RTP n ZRTP

22:42 0

Secure calling can be achieved by enabling TLS to encrypt the signalling and enabling SRTP or ZRTP to encrypt the media or data. Once implemented SIP UA can choose to use transport TLS instead of UDP or TCP. The advantage of choosing TLS is that the SIP traffic exchanged between SIP UA and Asterisk will be encrypted, it means it will take a considerable amount of time and effort to decrypt it without the encryption key, if not possible.
There are 3 sub-topics in this topic, they are:
Later after going through this topic in the end you must decide whether you want to implement TLS with SRTP or TLS with ZRTP. You cannot have both for a call, but you might have both implemented on your systems (for different calls).
Please note that having TLS enabled is a must, and successfully configure and enable SRTP or ZRTP is crucial on any Asterisk deployment.

Secure SIP

SIP is the signalling part of communication. Securing SIP means that we are protecting the call metadata from the Man in The Middle.

Generate Certificates

Create placeholder for our keys:
mkdir -p /etc/asterisk/keys
Navigate to Asterisk source code directory and its contrib/scripts. Example:
cd /home/support/asterisk-11.18.0/contrib/scripts
Use contributed script to generate self-signed certificates. Usage for server certificate:
./ast_tls_cert -C [COMMON_NAME] -O "[ORG_NAME]" -d /etc/asterisk/keys
Example of generating server certificate:
./ast_tls_cert -C 192.168.2.5 -O "My Asterisk" -d /etc/asterisk/keys
Usage for client certificate:
./ast_tls_cert -m client -c /etc/asterisk/keys/ca.crt -k /etc/asterisk/keys/ca.key -C [CLIENT_IP_HOSTNAME] -O "[ORG_NAME]" -d /etc/asterisk/keys -o [CLIENT_CERT_NAME]
Example of generating client certificate:
./ast_tls_cert -m client -c /etc/asterisk/keys/ca.crt -k /etc/asterisk/keys/ca.key -C 192.168.2.10 -O "My Asterisk" -d /etc/asterisk/keys -o allphones
You may omit the -C [CLIENT_IP_HOSTNAME] parameter if you intend to create the client certificate for all SIP UA.
Navigate to our keys placeholder again:
cd /etc/asterisk/keys
Generate .p12 file for SIP UA requesting certificate in this format, usage:
openssl pkcs12 -export -out [CLIENT_CERT_NAME].p12 -inkey ca.key -in ca.crt -certfile asterisk.crt
Example:
openssl pkcs12 -export -out allphones.p12 -inkey ca.key -in ca.crt -certfile asterisk.crt
Check all generated server and client certificates:
ls -l /etc/asterisk/keys
You should found similar list to this:
-rw------- 1 root root 1208 Aug  5 09:56 allphones.crt
-rw------- 1 root root  570 Aug  5 09:56 allphones.csr
-rw------- 1 root root  887 Aug  5 09:56 allphones.key
-rw-r--r-- 1 root root 4909 Aug  5 09:57 allphones.p12
-rw------- 1 root root 2095 Aug  5 09:56 allphones.pem
-rw------- 1 root root 1208 Aug  5 09:53 asterisk.crt
-rw------- 1 root root  570 Aug  5 09:53 asterisk.csr
-rw------- 1 root root  887 Aug  5 09:53 asterisk.key
-rw------- 1 root root 2095 Aug  5 09:53 asterisk.pem
-rw------- 1 root root  157 Aug  5 09:53 ca.cfg
-rw------- 1 root root 1757 Aug  5 09:53 ca.crt
-rw------- 1 root root 3311 Aug  5 09:53 ca.key
-rw------- 1 root root  118 Aug  5 09:56 tmp.cfg
Here are files that you can distribute to clients where they can use them on their SIP UA:
ca.crt
asterisk.crt
allphones.crt
allphones.p12

Enable TLS supports

Edit /etc/asterisk/sip.conf and add below options:
tlsenable=yes
tlsbindaddr=0.0.0.0
tlscertfile=/etc/asterisk/keys/asterisk.pem
tlscafile=/etc/asterisk/keys/ca.crt
tlscipher=ALL
tlsclientmethod=tlsv1
Followed by Asterisk restart
asterisk -rx 'core restart now'

Verify Configuration

Look for port 5061 in netstat result:
netstat -lnptu | grep 5061
Enable transport option on each SIP accounts.
Edit /etc/asterisk/sip_friends.conf:
[101]
type=friend
...
...
transport=tls
Reload SIP configuration:
asterisk -rx 'sip reload'

SIP UA configuration

SIP UA need to use the supplied client certificate by adding it though the provided menu on SIP UA and then add the CA certificate to their computer if the CA certificate is a self-signed certificate.
Adding CA certificate to Ubuntu (as root):
cp ca.crt /usr/local/share/ca-certificates/asterisk-server.crt
update-ca-certificates
Adding CA certificate to CentOS (as root):
yum install ca-certificates
update-ca-trust enable
cp ca.crt /etc/pki/ca-trust/source/anchors/
update-ca-trust extract

Secure RTP

RTP is the media path or data part of communication. This is the actual voice stream that need to be protected. An encrypted RTP packets will not be easy (read: virtually impossible) to listen to.

Enable encryption

Enable RTP encryption for specific SIP account by turning encryption option to yes in SIP account. The transport option must be tls and SIP UA must be registered and using transport TLS.
Edit /etc/asterisk/sip_friends.conf:
[101]
type=friend
...
...
transport=tls
encryption=yes
Reload SIP configuration:
asterisk -rx 'sip reload'

ZRTP

Quoting Wikipedia:
ZRTP (composed of Z and Real-time Transport Protocol) is a cryptographic key-agreement protocol to negotiate the keys for encryption between two end points in a Voice over Internet Protocol (VoIP) phone telephony call based on the Real-time Transport Protocol. It uses Diffie–Hellman key exchange and the Secure Real-time Transport Protocol (SRTP) for encryption.
What I know about Asterisk+ZRTP:
  • ZRTP is using Secure RTP to encrypt data
  • ZRTP implements Short Authentication String (SAS) to mitigate Man in The Middle attack (basically this is to make sure that the other end is someone the caller knows verbally)
  • ZRTP initiated by the caller and the callee must respond to it
  • We need to choose between using TLS+SRTP or TLS+ZRTP, cannot have both in one secure call
  • Asterisk do not understand ZRTP and cannot allow ZRTP to pass between participating SIP accounts, therefore the RTP (which is actually ZRTP packets) between SIP accounts must be direct peer-to-peer without Asterisk intervention
  • No NAT between each participating SIP accounts in conversation
Please note: You do not need to setup Asterisk for ZRTP if you already choose to use TLS with SRTP. Further more setting up Asterisk for ZRTP is currently limiting your Asterisk to provide some feature, or should I say you will be forced to limit some feature otherwise ZRTP won't work.
Continue ? Ok.
Direct peer-to-peer RTP between SIP accounts in Asterisk requires certain condition to be met. On each SIP accounts you must set the following:
  • Disable NAT support by setting nat to no on each peers
  • Disable SRTP by setting encryption to no on each peers, you can still use transport=tls
  • Enable peer-to-peer media path by setting directmedia to yes on each peers
  • Set directrtpsetup to yes globally
  • Set disallowed and allowed codec the same for all participating SIP accounts, for example by setting disallow=allfollowed by allow=ulaw
Below is the example of ZRTP preparation for a SIP account (in this case 101). You must do these type of changes on all participating SIP accounts.
Edit /etc/asterisk/sip_friends.conf:
[101]
type=friend
...
...
transport=tls
encryption=no
nat=no
directmedia=yes
disallow=all
allow=ulaw
Edit /etc/asterisk/sip.conf, add option directrtpsetup=yes just above the include of file sip_friends.conf:
...
...
directrtpsetup=yes
...
...
#include "sip_friends.conf"
Reload SIP configuration:
asterisk -rx 'sip reload'
Continue to configure all participating SIP UA to disable SRTP and enable or create ZRTP session.

Source from : https://github.com/antonraharja/book-asterisk-101/blob/master/book-contents/en/Chapter_05/Secure-Calling.md