Monthly Archives: February 2013

UPDATE IP DYNDNS USING CURL PHP


[root@DUREN3REPO ~]# vim no-ip.sh

#!/bin/bash
/usr/bin/links http://www.checkip.org/ | grep “Your IP Address:”|awk -F’:’ ‘{print $2}’ > /tmp/ip.txt
ip_address=`cat /tmp/ip.txt`
CDIR=`pwd`
/usr/bin/php ${CDIR}/update-ip.php $ip_address

[root@DUREN3REPO ~]# vim update-ip.php
<?php
$myip=trim($argv[1]);
$username = “gozigomilis@gmail.com”;
$password = “mypassword”;
//https://www.noip.com/members/dns/host.php?host_id=30961953
//https://www.noip.com/members/dns/
$url      = “https://dynupdate.no-ip.com/nic/update?hostname=mydomain.no-ip.info&myip=${myip}”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERPWD, “$username:$password”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
print $output;
?>
Advertisements

SETTING NTP SERVER ON LACAL LAN – UBUNTU SERVER


SETTING NTP SERVER ON LOCAL LAN –  UBUNTU SERVER

root@dbrscm:/etc# /etc/init.d/ntp stop

root@dbrscm:/etc# ntpdate server 0.us.pool.ntp.org

root@dbrscm:/etc# vim /etc/ntp.conf

server ntp.ubuntu.com
server nist1-dc.WiTime.net iburst
server ntp0.mcs.anl.gov
server 0.us.pool.ntp.org
server 1.us.pool.ntp.org
server 2.us.pool.ntp.org
server 3.us.pool.ntp.org

Also, add a few extra lines to the bottom of your servers list to provide your current local time as a default should you temporarly lose Internet connectivity:

server 127.127.1.0
fudge 127.127.1.0 stratum 10

# Allow LAN machines to synchronize with this ntp server

restrict 0.0.0.0 mask 255.0.0.0 nomodify notrap

save and exit

root@dbrscm:/etc# /etc/init.d/ntp restart

root@dbrscm:/etc# ntpq -c lpeer
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 10 l 6 64 7 0.000 0.000 0.000 
root@dbrscm:/etc#

FROM NTP CLIENT

root@dbrscm:/usr/share/zoneinfo/Asia# /etc/init.d/ntp stop
* Stopping NTP server ntpd

root@dbrscm:/usr/share/zoneinfo/Asia# ntpdate 2.id.pool.ntp.org
18 Feb 11:48:59 ntpdate[24017]: adjust time server 103.12.12.14 offset -0.000175 sec

root@dbrscm:/usr/share/zoneinfo/Asia# ln -sf /usr/share/zoneinfo/Asia/Jakarta /etc/localtime

root@dbrscm:/usr/share/zoneinfo/Asia# hwclock –systohc

root@dbrscm:/usr/share/zoneinfo/Asia# date
Mon Feb 18 11:47:16 WIT 2013

root@dbrscm:/usr/share/zoneinfo/Asia# mysql -uroot -proot -e “select now()”

root@dbrscm:/usr/share/zoneinfo/Asia# vim /etc/mysql/my.cnf

[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
timezone = GMT+7

root@dbrscm:/usr/share/zoneinfo/Asia# /etc/init.d/mysql restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mysql ; start mysql. The restart(8) utility is also available.
mysql stop/waiting
mysql start/running, process 23853
root@dbrscm:/usr/share/zoneinfo/Asia#

root@dbrscm:/usr/share/zoneinfo/Asia# mysql -uroot -proot -e “select now()”

KONFIGURASI NTP SERVER PADA LOKAL LAN – CENTOS/RHEL


Berikut ini adalah langkah-langkah yang dilkukan untuk konfigurasi NTP Server pada lokal LAN

Tujuan dibuat NTP SERVER ini adalah untuk menyamakan waktu masing-masing komputer dan menset ip timeservernya ke TIMESERVER

Pastikan lebih awal time servernya sendiri sudah benar yah:)

Cara ini dilakukan di CENTOS/RHEL

Pastikan sudah menginstall paket ntp

[root@ivr etc]# rpm -aq | grep ntp
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.4p8-2.el6.centos.i686
ntp-4.2.4p8-2.el6.centos.i686
[root@ivr etc]#

Yang perlu di uncomment dari configurasi default adalah :

restrict 127.0.0.1
restrict -6 ::1

Yang perlu di tambah adalah :

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

Yang perlu dihapus atau tidak dihapus

#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org

restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap untuk memperbolehkan semua IP.

Setelah di tambahkan mana  restart service ntp

[root@ivr etc]# /etc/init.d/ntpd restart
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]
[root@ivr etc]# chkconfig ntpd on

Jalankan command :

[root@ivr etc]# ntpq -p

Akan muncul seperti output dibawah ini

[root@ivr etc]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) .LOCL. 10 l 11 64 1 0.000 0.000 0.004

Pastikan ada tanda bintang (*) di depan kata LOCAL , itu artinya server sudah ready menerima request dari masing-masing client

[root@alfamart etc]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 10 l 32 64 377 0.000 0.000 0.004

Setelah ada tanda * ini maka coba jalankan command ntpdate -s $IP_NTP_SERVER

Jika sudah ada tanda bintang maka parameter lain yang perlu di lihat adalah nilai stratumnya, nilai stratum sudah OK jika nilainya < 16

Contoh:

[root@ivr etc]# ntpq -c rv
assID=0 status=0544 leap_none, sync_local_proto, 4 events, event_peer/strat_chg,
version=”ntpd 4.2.4p8@1.1612-o Tue Nov 29 00:06:28 UTC 2011 (1)”,
processor=”i686″, system=”Linux/2.6.32-279.5.1.el6.i686″, leap=00,
stratum=11, precision=-18, rootdelay=0.000, rootdispersion=948.761,
peer=5086, refid=LOCAL(0),
reftime=d4c37560.9bfdf48e Mon, Feb 11 2013 20:49:20.609, poll=6,
clock=d4c37588.149caceb Mon, Feb 11 2013 20:50:00.080, state=3,
offset=0.000, frequency=0.000, jitter=0.004, noise=0.004,
stability=0.000, tai=0

____________________________

Berikut ini adalah config yang sudah OK di Debian

driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 127.127.1.0
fudge 127.127.1.0 stratum 10
restrict default nomodify nopeer noquery
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1
restrict 192.168.137.0 mask 255.255.255.0 nomodify notrap

Jalankan command ini di masing-masing client:

ls /usr/share/zoneinfo/Asia/Jakarta
rm -rf /etc/localtime
ln –s /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
ntpdate 0.us.pool.ntp.org
hwclock –systohc

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: