Showing posts with label unexpected token near end of file. Show all posts
Showing posts with label unexpected token near end of file. Show all posts

Wednesday, March 26, 2014

unknown option '$TTL' and unexpected token near end of file

วิธีแก้ไข Err. bind(DNS) ใน Debain
- unknown option '$TTL'
- unexpected token near end of file

คำสั่งตรวจสอบค่าคอนฟิก ที่ Zone file ที่มีปัญหา
1. named-checkconf db.domain.co.th
-----------------------------------
#db.domain.co.th:1: unknown option '$TTL'
#db.domain.co.th:47: unexpected token near end of file
//---------------------------------------

2. named-checkzone domain.co.th /var/named/db.domain.co.th
--------------------------------------
zone domain.co.th/IN: NS 'hostxxx.domain.co.th' has no address records (A or AAAA)
zone domain.co.th/IN: not loaded due to errors.
//--------------------------------------

How to fix BIND does not permit underscores "_" unless you specificy the whole domain name

# named-checkzone abc.com. /var/named/abc.com.hosts 
/var/named/abc.com.hosts:60: express_www1.abc.com: bad owner name (check-names)
/var/named/abc.com.hosts:61: express_www2.abc.com: bad owner name (check-names)
zone abc.com/IN: loaded serial 2020122401
OK

Add this to the option []
------
vim /etc/named.conf
options {
        listen-on port 53 { any; };
        listen-on-v6 port 53 { any; };
.
.
         check-names master ignore;
         check-names slave ignore;
         check-names response ignore;
};

# systemctl restart named
# systemctl status named
# named-checkzone abc.com. /var/named/abc.com.hosts   -> recheck if show bad owner name (check-names) but it is OK!

ref:

คำสั่งปฏิบัติการ
1. rndc flush
2. rndc reload
3. เข้าไปแก้ไข Serail Number ที่ Zone File นั้นก่อน restart service DNS
4. /etc/init.d/bind9 reload  (Restart service DNS)


ตัวอย่าง การแก้ไข

root@sip40:/etc/bind# rndc flush
root@sip40:/etc/bind# rndc reload
server reload successful
root@sip40:/etc/bind# named-checkzone domain.co.th db.domain.co.th
zone domain.co.th/IN: NS 'hqbackup01.domain.co.th' has no address records (A or AAAA)   ** แสดงโดเมนที่ไม่สามารถโหลดได้ เราต้องเข้าไปแก้ไขตรวจสอบดูว่า ยังใช้งานอยู่ไหม
zone domain.co.th/IN: not loaded due to errors.

root@sip40:/etc/bind# vim db.domain.co.th ** เข้าไปแก้ไข และปรับค่า Serial ใหม่
root@sip40:/etc/bind# /etc/init.d/bind9 reload
Reloading domain name service...: bind9.
root@sip40:/etc/bind# named-checkzone domain.co.th db.domain.co.th
zone domain.co.th/IN: loaded serial 2014032701
OK
//--------------------------------------------------------------

แล้วกลับไปตรวจสอบอีกครั้ง

1. named-checkconf db.domain.co.th
-----------------------------------
#db.domain.co.th:1: unknown option '$TTL'
#db.domain.co.th:47: unexpected token near end of file
//---------------------------------------
**** ยังเจอ err. อยู่เหมือนเดิม แต่เมื่อลองไป nslookup จากเครื่องอื่น กลับสามารถ solve domain ได้ ถือว่า ok

2. named-checkzone domain.co.th db.domain.co.th
-----------------------------------
zone domain.co.th/IN: loaded serial 2014032701
OK
 //--------------------------------
*** ใช้งานได้แล้ว

Reference:

rndc flush & rndc reload
Command Check DNS