Networking

You are currently browsing the articles from KomKid.Net matching the category Networking.

Centralized Log ภาคที่ 1 : NTP

ติดตั้ง NTP (Network Time Protocol)
ตาม พรบ.ว่าด้วยการกระทำผิดเกี่ยวกับคอมพิวเตอร์ พ.ศ. 2550 กำหนดให้ ต้องตั้งนาฬิกาของอุปกรณ์บริการทุกชนิดให้ตรงกับเวลาอ้างอิงสากล (Stratum 0) โดยผิดพลาดไม่เกิน 10 มิลลิวินาที
1.ติดตั้ง apt-get install ntp (ที่ Log Server และ Server อื่น ๆ)
2.ตั้งค่า Log Server (/etc/ntp.conf)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift

# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

#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

# You do need to talk to an NTP server or two (or three).
server 203.185.69.60 dynamic
server time.navy.mi.th dynamic
server time.nist.gov dynamic
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
broadcastdelay 0.008
keys /etc/ntp/keys

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestric$
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
#restrict -4 default kod notrap nomodify nopeer noquery
restrict default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
#restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

3. ตั้งค่า Server อื่น ๆ ที่เป็น linux

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift

# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

#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

# You do need to talk to an NTP server or two (or three). (192.168.0.251 is Log Server)
server 192.168.0.251

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
#restrict -4 default kod notrap nomodify nopeer noquery
#restrict -6 default kod notrap nomodify nopeer noquery
restrict default ignore

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
#restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated. (192.168.0.251 is Log Server)
restrict 192.168.0.251 mask 255.255.255.255 nomodify notrap noquery

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

ทดสอบ

# ntpq -pn
# ntpdc
ntpdc>sysinfo

3. ตั้งค่าเครื่องอื่น ๆ ที่เป็น Windows โดยใช้ regedit.exe (save เป็น . reg แล้ว double click)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config]
"AnnounceFlags"=dword:00000005
"MaxNegPhaseCorrection"=dword:00000e10
"MaxPosPhaseCorrection"=dword:00000e10
 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
"NtpServer"="192.168.0.251,0x1"
"Type"="NTP"
 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient]
"SpecialPollInterval"=dword:00000384
 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer]
"Enabled"=dword:00000001

restart service w32time

:\>net stop w32time
:\>net start w32time

ทดสอบ

:\>net time
:\>net time /querysntp

Written by Komkid on November 22nd, 2009 with no comments.
Read more articles on Admin and Internet and Networking and Ubuntu.

Ubuntu : Squid error page

เข้าไปแก้ไขได้ที่ /usr/share/squid/errors/English/ แล้วก็เลือก file ที่ต้องการแก้ไข เช่น หน้าสำหรับแสดงว่าถูก block ปกติจะชื่อ ERR_ACCESS_DENIED
ตัวอย่าง

1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF8">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY bgcolor="#000000">
 <div align="center">
 
  <img src="http://intranet.sci.com/sci/blocked.jpg" border="0" alt="Access dinied">
 
  </div>
<br>
 <div align="center"><a href="http://intranet.sci.com/viewtopic.php?f=54&t=5403">รายการ web ที่ถูก block ในช่วงเวลา 8:00-12:00 น. และ 13:00-17:40 น</div>

Written by Komkid on November 22nd, 2009 with no comments.
Read more articles on Admin and Networking and Ubuntu.

Solve Host to IP without DNS

แปลง Host เป็น IP โดยไม่ต้องพึ่ง DNS Server ทำได้โดย ระบุในไฟล์ ชื่อ hosts
ของ Windows อยู่ที่ C:\WINDOWS\system32\drivers\etc\hosts
ของ linux อยู่ที่ /etc/hosts

รูปแบบคือ
IP ช่องว่างตามด้วย host

ตัวอย่างของ Windows

# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost

อันนี้ของ linux

192.168.0.250 IF-Nikom.sci.com IF-Nikom
192.168.0.1 axaptaserver.sci.com axaptaserver
192.168.0.251 server1.sci.com server1
192.168.0.252 server2.sci.com server2
192.168.0.253 server3.sci.com server3

ตามหลักการก็น่าจะเร็วกว่าการใช้ dns ด้วย เพราะไม่ต้องวิ่งผ่าน server

Written by Komkid on October 4th, 2009 with no comments.
Read more articles on IT Tips and Networking.

Delete Domain Controller using ntdsutil.exe

1.ntdsutil
2.metada cleanup
3.connections
4.connect to server
5.quit
6.select operation target
7.list domains
8.select domain
9.list sites
10.select site
11.list servers in site
12.select server
13.quit
14.remove selected server
15.quit
16.quit

Written by Komkid on August 28th, 2009 with no comments.
Read more articles on Admin and Networking.

Set IP from command line

netsh interface ip

Usage:
set address [name=]
[[source=]dhcp | [source=] static [addr=]IP address [mask=]IP subnet mask]
[[gateway=]|none [gwmetric=]integer]

Parameters:
* name – The name of the interface.
* source – One of the following values:
o dhcp: Sets DHCP as the source for configuring IP addresses for the specific interface.
o static: Sets the source for configuring IP addresses to local static configuration.
* gateway – One of the following values:
o : A specific default gateway for the static IP address you are setting.
o none: No default gateways are set.
* gwmetric – The metric for the default gateway. This field should not be set if gateway is set to ‘none’.

The following options are used only if source is ‘static’:
* addr – An IP address for the specified interface.
* mask – The subnet mask for the specified IP address.

Remarks:
Used to change the IP address configuration mode from either DHCP to static mode or static mode to DHCP. Adds IP addresses on an interface with static IP address or adds default gateways.

Examples:

* set address name=”Local Area Connection” source=dhcp
* set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1

netsh interface ip set address name=”Local Area Connection” static 192.168.0.250 255.255.255.0 192.168.0.1 1

Written by Komkid on April 16th, 2009 with 2 comments.
Read more articles on Admin and IT Tips and Networking.

« Older articles

Newer articles »