Mục tiêu thực hành:
- Cài đặt các gói Update cho CentOS v7 trước khi cài đặt FreeSwitch v.1.6.
- Tiến hành download FreeSwitch v1.6 về CentOS v7.
- Cài đặt FreeSwitch v1.6 và các gói Sound cho FreeSwitch.
- Tạo tài khoản freeswitch thuộc nhóm daemon trên CentOS v7.
- Khởi tạo systemd unit file trên CentOS v7.
- Khởi động và kiểm tra dịch vụ freeswitch.service.
- Kiểm tra các Open Port đang mở trên FreeSwitch và CentOS v7.
- Kiểm tra trạng thái của FreeSwitch v1.6.
- Kiểm tra trạng thái Internal Sofia Status trên FreeSwitch.
- Kiểm tra trạng thái External Sofia Status trên FreeSwitch.
Các bước triển khai:
Cài đặt các gói Update cho CentOS v7 trước khi cài đặt FreeSwitch v.1.6.
- Cài đặt các gói Update cho CentOS v7.
yum updateyum -y install make bison bison-devel ncurses ncurses-devel zlib zlib-devel openssl openssl-devel gnutls-devel gcc gcc-c++ kernel-devel flex libxml2-devel which autoconf automake git-core libjpeg-devel libtool pkgconfigyum install unixODBC-devel openssl-devel libogg-devel libvorbis-devel curl-devel libtiff-devel libjpeg-devel python-devel expat-devel zlib zlib-devel bzip2yum install wget
- Cài đặt gói ncurses-5.6.
yum install ncurses-devel
or
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gztar zxvf ncurses-5.6.tar.gz./configure -prefix=/usr/local -with-shared -without-debugmakemake install
Tiến hành download FreeSwitch v1.6 về CentOS v7.
cd /usr/srcrpm -Uvh http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpmyum install freeswitch-config-vanilla freeswitch-sounds* freeswitch-lang* freeswitch-lua freeswitch-xml-cdryum -y install git gcc-c++ autoconf automake libtool wget python ncurses-devel zlib-devel libjpeg-devel openssl-devel e2fspyum -y install libyuv-devel opus-devel libvpx-devel libvpx2* libdb4* libidn-devel unbound-devel libuuid-devel lua-devel lib
yum groupinstall -y 'Development Tools'yum install -y git autoconf automake libtool gcc-c++ libuuid-devel zlib-devel libjpeg-devel ncurses-devel openssl-devel sqlite-devel curl-devel pcre-devel speex-devel ldns ldns-devel libedit-devel gtk+-devel gtk2-devel yasm-devel lua-devel opus-devel e2fsprogs-devel libyuv-devel lua-devel libsndfile-devel libshout-devel lame-devel libvpx-devel opusfile libbroadvoice-dev
wget http://files.freeswitch.org/freeswitch-1.6.20.zipsudo yum install -y zip unzipunzip /usr/src/freeswitch-1.6.20.zip
git clone https://github.com/yasm/yasm.git && cd yasm && ./autogen.sh && make && sudo make installyum install -y epel-releaseyum install ldns-devel libidn-devel unbound-devel
Cài đặt FreeSwitch v1.6 và các gói Sound cho FreeSwitch.
cd /usr/src/freeswitch-1.6.20./configuremakemake installmake install sounds-installmake install moh-installmake hd-sounds-installmake hd-moh-installmake uhd-sounds-installmake uhd-moh-installmake samples
Tạo tài khoản freeswitch thuộc nhóm daemon trên CentOS v7.
- Khởi tạo simlinks để thuận tiện cho việc sử dụng các dịch vụ services.
ln -s /usr/local/freeswitch/bin/freeswitch /usr/bin/ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin
- Tạo mới Group và User với đặc quyền privileges thấp hơn để chạy FreeSWITCH service.
cd /usr/localuseradd --system --home-dir /usr/local/freeswitch -G daemon freeswitchpasswd -l freeswitch
chown -R freeswitch:daemon /usr/local/freeswitch/chmod -R ug=rwX,o= /usr/local/freeswitch/chmod -R u=rwx,g=rx /usr/local/freeswitch/bin/
Khởi tạo systemd unit file trên CentOS v7.
- Khởi tạo mới file freeswitch.service.
vi /etc/systemd/system/freeswitch.service
- Nội dung của file freeswitch.service.
[Unit]Description=freeswitchWants=network-online.targetRequires=network.target local-fs.targetAfter=network.target network-online.target local-fs.target[Service]Type=forkingEnvironment="DAEMON_OPTS=-nonat"EnvironmentFile=-/etc/default/freeswitchExecStartPre=/bin/chown -R freeswitch:daemon /usr/local/freeswitchExecStart=/usr/bin/freeswitch -u freeswitch -g freeswitch -ncwait $DAEMON_OPTSTimeoutSec=45sRestart=alwaysUser=rootGroup=daemonLimitCORE=infinityLimitNOFILE=100000LimitNPROC=60000LimitSTACK=250000LimitRTPRIO=infinityLimitRTTIME=infinityIOSchedulingClass=realtimeIOSchedulingPriority=2CPUSchedulingPolicy=rrCPUSchedulingPriority=89UMask=0007NoNewPrivileges=false[Install]WantedBy=multi-user.target
Khởi động và kiểm tra dịch vụ freeswitch.service.
- Khởi động dịch vụ freeswitch.service.
chmod ugo+x /etc/systemd/system/freeswitch.servicesystemctl start freeswitch.servicesystemctl enable freeswitch.servicesystemctl restart freeswitch.service
- Kiểm tra trại thái dịch vụ freeswitch.service.
[root@static local]# systemctl status freeswitch.service● freeswitch.service - freeswitchLoaded: loaded (/etc/systemd/system/freeswitch.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2021-04-22 03:13:03 EDT; 11s agoMain PID: 45578 (freeswitch)CGroup: /system.slice/freeswitch.service└─45578 /usr/bin/freeswitch -u freeswitch -g freeswitch -ncwait -nonatApr 22 03:12:56 static.vnpt.vn systemd[1]: Starting freeswitch...Apr 22 03:12:57 static.vnpt.vn freeswitch[45576]: 45578 Backgrounding.Apr 22 03:13:03 static.vnpt.vn freeswitch[45576]: FreeSWITCH[45576] Waiting for background process pid:45578 to be ready.....Apr 22 03:13:03 static.vnpt.vn freeswitch[45576]: FreeSWITCH[45576] Waiting for background process pid:45578 to be ready.....Apr 22 03:13:03 static.vnpt.vn freeswitch[45576]: FreeSWITCH[45576] System Ready pid:45578Apr 22 03:13:03 static.vnpt.vn systemd[1]: Started freeswitch.[root@static local]#
Kiểm tra các Open Port đang mở trên FreeSwitch và CentOS v7.
[root@static local]# netstat -tulnapActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 10.10.10.188:8081 0.0.0.0:* LISTEN 45578/freeswitchtcp 0 0 10.10.10.188:8082 0.0.0.0:* LISTEN 45578/freeswitchtcp 0 0 10.10.10.188:7443 0.0.0.0:* LISTEN 45578/freeswitchtcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 16709/sshdtcp 0 0 10.10.10.188:5080 0.0.0.0:* LISTEN 45578/freeswitchtcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 16866/mastertcp 0 0 10.10.10.188:5060 0.0.0.0:* LISTEN 45578/freeswitchtcp 0 0 10.10.10.188:5066 0.0.0.0:* LISTEN 45578/freeswitchtcp 0 0 10.10.10.188:22 118.69.66.40:59492 ESTABLISHED 76116/sshd: root@pttcp6 0 0 ::1:8081 :::* LISTEN 45578/freeswitchtcp6 0 0 ::1:8082 :::* LISTEN 45578/freeswitchtcp6 0 0 :::8021 :::* LISTEN 45578/freeswitchtcp6 0 0 :::22 :::* LISTEN 16709/sshdtcp6 0 0 ::1:5080 :::* LISTEN 45578/freeswitchtcp6 0 0 ::1:25 :::* LISTEN 16866/mastertcp6 0 0 ::1:5060 :::* LISTEN 45578/freeswitchudp 0 0 10.10.10.188:5060 0.0.0.0:* 45578/freeswitchudp 0 0 10.10.10.188:5080 0.0.0.0:* 45578/freeswitchudp 0 0 0.0.0.0:1337 0.0.0.0:* 45578/freeswitchudp 0 0 127.0.0.1:323 0.0.0.0:* 23884/chronydudp6 0 0 ::1:5060 :::* 45578/freeswitchudp6 0 0 ::1:5080 :::* 45578/freeswitchudp6 0 0 ::1:323 :::* 23884/chronyd[root@static local]#
Kiểm tra trạng thái của FreeSwitch v1.6.
[root@static local]# fs_cli –r.=======================================================.| _____ ____ ____ _ ___ || | ___/ ___| / ___| | |_ _| || | |_ \___ \ | | | | | | || | _| ___) | | |___| |___ | | || |_| |____/ \____|_____|___| || |.=======================================================.| Anthony Minessale II, Ken Rice, || Michael Jerris, Travis Cross || FreeSWITCH (http://www.freeswitch.org) || Paypal Donations Appreciated: paypal@freeswitch.org || Brought to you by ClueCon http://www.cluecon.com/ |.=======================================================..=======================================================================================================.| ____ _ ____ || / ___| |_ _ ___ / ___|___ _ __ || | | | | | | |/ _ \ | / _ \| '_ \ || | |___| | |_| | __/ |__| (_) | | | | || \____|_|\__,_|\___|\____\___/|_| |_| || || _____ _ _ ____ __ || |_ _|__| | ___ _ __ | |__ ___ _ __ _ _ / ___|___ _ __ / _| ___ _ __ ___ _ __ ___ ___ || | |/ _ \ |/ _ \ '_ \| '_ \ / _ \| '_ \| | | | | | / _ \| '_ \| |_ / _ \ '__/ _ \ '_ \ / __/ _ \ || | | __/ | __/ |_) | | | | (_) | | | | |_| | | |__| (_) | | | | _| __/ | | __/ | | | (_| __/ || |_|\___|_|\___| .__/|_| |_|\___/|_| |_|\__, | \____\___/|_| |_|_| \___|_| \___|_| |_|\___\___| || |_| |___/ || _____ _ _ || | ____|_ _____ _ __ _ _ / \ _ _ __ _ _ _ ___| |_ || | _| \ \ / / _ \ '__| | | | / _ \| | | |/ _` | | | / __| __| || | |___ \ V / __/ | | |_| | / ___ \ |_| | (_| | |_| \__ \ |_ || |_____| \_/ \___|_| \__, | /_/ \_\__,_|\__, |\__,_|___/\__| || |___/ |___/ || ____ _ ____ || __ ____ ____ __ / ___| |_ _ ___ / ___|___ _ __ ___ ___ _ __ ___ || \ \ /\ / /\ \ /\ / /\ \ /\ / / | | | | | | |/ _ \ | / _ \| '_ \ / __/ _ \| '_ ` _ \ || \ V V / \ V V / \ V V / _ | |___| | |_| | __/ |__| (_) | | | | _ | (_| (_) | | | | | | || \_/\_/ \_/\_/ \_/\_/ (_) \____|_|\__,_|\___|\____\___/|_| |_| (_) \___\___/|_| |_| |_| || |.=======================================================================================================.Type /help <enter> to see a list of commands[This app Best viewed at 160x60 or more..]+OK log level [7]freeswitch@static.vnpt.vn> /exit[root@static local]#
Kiểm tra trạng thái Internal Sofia Status trên FreeSwitch.
- Internal Profile cho phép các Internal Phone register tới FreeSwitch.
[root@static local]# fs_cli –rfreeswitch@static.vnpt.vn> sofia statusName Type Data State=================================================================================================external-ipv6 profile sip:mod_sofia@[::1]:5080 RUNNING (0)10.10.10.188 alias internal ALIASEDexternal profile sip:mod_sofia@10.10.10.188:5080 RUNNING (0)external::example.com gateway sip:joeuser@example.com NOREGinternal-ipv6 profile sip:mod_sofia@[::1]:5060 RUNNING (0)internal profile sip:mod_sofia@10.10.10.188:5060 RUNNING (0)=================================================================================================4 profiles 1 aliasfreeswitch@static.vnpt.vn>
[root@static local]# fs_cli –rfreeswitch@static.vnpt.vn> sofia status profile internal=================================================================================================Name internalDomain Name N/AAuto-NAT falseDBName sofia_reg_internalPres Hosts 10.10.10.188,10.10.10.188Dialplan XMLContext publicChallenge Realm auto_fromRTP-IP 10.10.10.188SIP-IP 10.10.10.188URL sip:mod_sofia@10.10.10.188:5060BIND-URL sip:mod_sofia@10.10.10.188:5060;transport=udp,tcpWS-BIND-URL sip:mod_sofia@10.10.10.188:5066;transport=wsWSS-BIND-URL sips:mod_sofia@10.10.10.188:7443;transport=wssHOLD-MUSIC local_stream://mohOUTBOUND-PROXY N/ACODECS IN OPUS,G722,PCMU,PCMA,VP8CODECS OUT OPUS,G722,PCMU,PCMA,VP8TEL-EVENT 101DTMF-MODE rfc2833CNG 13SESSION-TO 0MAX-DIALOG 0NOMEDIA falseLATE-NEG truePROXY-MEDIA falseZRTP-PASSTHRU trueAGGRESSIVENAT falseCALLS-IN 0FAILED-CALLS-IN 0CALLS-OUT 0FAILED-CALLS-OUT 0REGISTRATIONS 0freeswitch@static.vnpt.vn> /exit
Kiểm tra trạng thái External Sofia Status trên FreeSwitch.
- Khảo sát thư mục chứa Internal vs External Sofia Profile.
[root@static local]# ls /usr/local/freeswitch/conf/sip_profilesexternal external-ipv6 external-ipv6.xml external.xml internal-ipv6.xml internal.xml[root@static local]#
- External Sofia Status cho phép các External Phone register tới FreeSwitch.
[root@static local]# fs_cli –rfreeswitch@static.vnpt.vn> sofia status profile external=================================================================================================Name externalDomain Name N/AAuto-NAT falseDBName sofia_reg_externalPres HostsDialplan XMLContext publicChallenge Realm auto_toRTP-IP 10.10.10.188SIP-IP 10.10.10.188URL sip:mod_sofia@10.10.10.188:5080BIND-URL sip:mod_sofia@10.10.10.188:5080;transport=udp,tcpHOLD-MUSIC local_stream://mohOUTBOUND-PROXY N/ACODECS IN OPUS,G722,PCMU,PCMA,VP8CODECS OUT OPUS,G722,PCMU,PCMA,VP8TEL-EVENT 101DTMF-MODE rfc2833CNG 13SESSION-TO 0MAX-DIALOG 0NOMEDIA falseLATE-NEG truePROXY-MEDIA falseZRTP-PASSTHRU trueAGGRESSIVENAT falseCALLS-IN 0FAILED-CALLS-IN 0CALLS-OUT 0FAILED-CALLS-OUT 0REGISTRATIONS 0freeswitch@static.vnpt.vn> /exit
Tham khảo các Videos lý thuyết CCNA Voice (Collaboration) trước khi tham khảo các bài hướng dẫn thực hành VoIP. Mọi thắc mắc, các bạn vui lòng liên lạc với mình thông qua kênh Zalo (Jade Bùi) 076.877.2021.
0 comments