วันพฤหัสบดีที่ 1 กรกฎาคม พ.ศ. 2564

(Shortcut) Uncomplicated Firewall on Ubuntu 20.04

ref https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/ ref https://www.cyberciti.biz/faq/how-to-configure-firewall-with-ufw-on-ubuntu-20-04-lts/ sudo lsof -i:[port-number] sudo lsof -i -P -n | grep LISTEN sudo ufw status sudo ufw status numbered sudo ufw delete [number] sudo ufw enable sudo ufw disable sudo ufw allow 80/tcp comment 'accept Apache' sudo ufw allow 443/tcp comment 'accept HTTPS Connections' sudo ufw allow from [ip]

วันพฤหัสบดีที่ 10 มิถุนายน พ.ศ. 2564

การติดตั้ง Postfix ใน Ubuntu 20.04 ปี 2021

อีกครั้งกับการที่ต้องมา Setup ตัว Postfix ซึ่งไม่ได้ทำบ่อยแล้วไม่มีความรู้เรื่องนี้เอาสะเลย ครั้งนี้จะต้องขึ้น Server Mail ให้ระบบอื่น ๆ เข้ามาเชื่อมต่อเพื่อส่งเมลออกไปยังที่อื่น ๆ ต่อไป แม้จะเคยทำมาแล้วแต่ก็ลืมไปหมด ครั้งนี้ได้โอกาสเลยเอามาเขียยลง Blog ไว้จะถ้ามีโอกาสได้ทำอีก ก็จะได้กลับมาหาอ่านไปกันเร็ว ๆ ได้ ในบทความนี้เราจะมาเริ่มแบบไม่รู้อะไรค่อย ๆ กันแก้ Error ต่าง ๆ ไปด้วย ไปเริ่มทำกันเลย

OS ที่ใช้จะเป็น Ubuntu 20.04 เพื่อให้ใช้ตัวนี้กันไปยาว ๆ ให้เราทำการติดตั้งให้เรียบร้อยตั้ง Date, Local, Network และทำการ Upgrade Package ให้เรียบร้อย
จากนั้นทำการติดตั้ง postfix อีเมล Server และ mailutils เพื่อใช้ทดสอบส่งอีเมลออกจาก Server
# Install postfix and mailutils
sudo apt install postfix mailutils
เมื่อติดตั้งเรียบร้อยแล้วให้ทำการ configuration ตัว postfix โดยใช้คำสั่ง dpkg-reconfigure postfix เพื่อช่วยให้เรา Config ง่ายขึ้น และผมจะใช้ค่า Config Default ตั้งตนไปก่อน เดียวมาทำความเข้าใจแต่ละส่วนที่หลัง ค่าอยู่หลัง : นั้นใช้ Default ระบบมาให้แต่แรกเดียวเราจะกลับมาแก้ที่ละอัน และตั้งค่าที่ configuration แล้วก็ให้ทำการ restart postfix อีก 1 รอบ
# Configure postfix
sudo dpkg-reconfigure postfix

# Config Value
# General type of mail configuration: Internet Site
# System mail name: enoti
# Root and postmaster mail recipient: sarankon
# Other destinations to accept mail for (blank for none): enoti, enoti, localhost.localdomain, , localhost
# Force synchronous updates on mail queue?: <No>
# Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/24 [::1]/128
# Mailbox size limit (bytes): 0
# Local address extension character: +
# Internet protocols to use: all

sudo systemctl restart postfix
ลองส่งอีเมลเลยว่าได้ไหม โดยใช้ mailutils ในการส่ง
# Test Send Mail
echo "Postfix Test" | mail -s "Subject Test" youremail@gmail.com

วันจันทร์ที่ 22 มีนาคม พ.ศ. 2564

Rsyslog ทำความรู้จักกับ Log และตั้งค่าให้ส่ง Log ไปเก็บยังเครื่อง Server

File Log ในระบบ Linux

เราจะต้องมีไฟล์ที่จะบันทึกการทำงานเพื่อใช้ในการตรวจสอบการทำงานและใช้เพื่อหาความผิดปกติที่เกิดขึ้นจากระบบ
Rsyslog มาจากคำว่า "The rocket-fast system for log processing"
Rsyslog เป็น Open Source ในระบบปฏิบัติการ UNIX และ Unix-like ใช้สำหรับส่งข้อมูล Log ผ่านทาง network

อ้างอิงจาก: https://www.rsyslog.com/, https://en.wikipedia.org/wiki/Rsyslog

Syslog

ใน syslog จะประกอบด้วย 3 ส่วน Facility, Priority และ Action โดยจากเขียนในรูปแบบตามนี้
Facility.Priority;Facility.Priority Action (; แทน และ)
Facility,Facility.Priority Action (, แทน หรือ)

วันเสาร์ที่ 20 มีนาคม พ.ศ. 2564

สรุปภาษา Dart เบื้องต้น สำหรับคนมีพื้นฐานการเขียนโปรแกรมแล้ว

method main() สำหรับการเริ่มต้นโปรแกรม และ method print() ในการแสดงผล

เริ่มต้นโครงสร้างต้องมี method main() ระบบจะเริ่มทำงานภายใน method เป็นอันดับแรก
method print('ข้อความ') เป็นการสั่งให้แสดงผลออกมาทาง console
void main() {
	print('Hello World!');
}