ข่าว: ข่าวประกาศ

  • 16 มิถุนายน 2024, 06:02:21

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - admin

หน้า: 1 ... 106 107 [108] 109 110 ... 115
1607
ปัญหามันเกิดเนื่องจากว่า M/B ที่มี RAID 0,1,5 ที่ติดมากับ Board นั้น มันใช้ไม่ได้กับ Ubuntu

ก็เลยพยายามหาวิธี ที่จะรวม HDD ทั้งหมด ของ HDD SATA2  80G จำนวน 3 ลูก

ให้ Linux มองเห็นเป็น 240G ลูกเดียว จะได้ง่ายต่อการจัดการ (หรือเปล่าน้อ) อิอิ

ก็เลยใช้ความสามารถของ LVM (เข้ามาช่วย)


1608
Patch Pangya

acl QUERY urlpath_regex cgi-bin \? localhost .asp .aspx .php .inf .dll .Xt .xtp .ini localhost php$ inf$ dll$ Xt$ xtp$ ini$ asp$ aspx$ updatelist$
cache deny QUERY

ให้เช็ค squid.conf ตรง acl QUERY จะต้องมี updatelist$ เพื่อให้อัพเดทได้ ไม่ให้ cache file updatelist


1609
คุยกับทีมวิจัย / Re: สนใจ ระบบ ADSL Bonded รวม ADSL
« เมื่อ: 04 มิถุนายน 2008, 20:39:02 »
ตอนนี้ระบบรวม B/W ของ ADSL ก็สมบูรณ์แล้วนะครับ

แต่ขอทดสอบการใช้งานจริงสักระยะนึง เพราะยังมีข้อจำกัดบางอย่าง

ตอนนี้เลยมีการผสมระหว่าง Multi-WAN และ ADSL Bonded มาใช้รวมกันใน Server ตัวเดียวกัน

เพื่อแบ่ง Service ให้เหมาะสมต่อการใช้งาน

คงใช้เวลาประมาณสัปดาห์หรือสองสัปดาห์นะครับ

1610
แนะนำเป็น Zyxel ES-2048 หรือไม่ก็เป็น 3COM-2250

ราคาอยู่ประมาณ 12,000-15,000.-

เป็น Switch Layer 2 แบบ Manage และมี Gagabit ให้ 2 Port

1611
สำหรับลูกค้าที่ติดตั้ง NetCafe Server จากทาง Hadyai Internet

เนื่องจากได้มีการพัฒนา script สำหรับ NetCafe Server อย่างต่อเนื่อง

ในกรณีที่มีปัญหาเรื่อง Patch Game ต่าง ๆ โหลดแพทแล้ว Error โหลดแล้วไม่สามารถติดต่อ Server ได้

หรือไม่สามารถ ftp ไปที่อื่นได้  หรือ update โปรแกรมบางโปรแกรมไม่ได้

หรือมีการ Login เวปบางเวป แล้วมีการถาม password ซ้ำหลาย ๆครั้ง

เมื่อมีการแจ้งเข้ามา ทาง Hadyai Internet จะได้ทำการ Update Script ให้เพื่อแก้ไขปัญหาดังกล่าว

ขอบคุณครับ


1612
Linux Server System / Re: Kernel-2.6.24 + iptables-1.4.0 + L7-filter-2.17 + ipp2p-0.8.2
« เมื่อ: 02 มิถุนายน 2008, 18:05:29 »
ทดสอบการใช้งาน Layer 7 filter

iptables -A FORWARD -m layer7 --l7proto msnmessenger -j ACCEPT
iptables -A FORWARD -m layer7 --l7proto msn-filetransfer -j ACCEPT
iptables -A FORWARD -m layer7 --l7proto worldofwarcraft -j ACCEPT
iptables -A FORWARD -m layer7 --l7proto ftp -j ACCEPT

ทดสอบผลดูสักระยะ

1613
ใกล้เวลาแล้วที่จะมีกฎหมายกำหนดให้มีการเก็บบันทึกการใช้งาน สำหรับผู้ที่ให้บริการอินเตอร์เน็ต และองค์กรต่าง ๆ

หลายคนก็ยังสงสัยว่า แล้วใน Logfile ของ Squid มันเป็น Unix Timestamp แล้วเราจะรู้ได้อย่างไรว่าใครเข้าเวปอะไรบ้าง
ในเวลานั้น ๆ

ผมก็เลยเอาสคิปไฟล์เล็ก ๆ มาฝาก 2 บรรทัด ก็สามารถจัดการเรื่องเหล่านี้ได้

file name : timeconvert.pl  (เป็นภาษา perl นะครับ)

#! /usr/bin/perl -p
s/^\d+\.\d+/localtime $&/e;


สองบรรทัดแค่นี้แหละครับ

ส่วนวิธีการใช้งานก็ไม่ยาก ใช้คำสั่ง  timeconvert.pl <logfile name>

root@myhost:/var/log/squid#./timeconvert.pl access.log

ก็จะได้การแปลงเวลาออกมา

โค๊ด: [Select]
Thu May 29 06:44:42 2008     11 192.168.182.172 TCP_MEM_HIT/200 519 GET http://www.zheza.com/images/blog/grp/blog_r1_c2.gif - NONE/- image/gif
Thu May 29 06:44:42 2008     26 192.168.182.172 TCP_MEM_HIT/200 457 GET http://www.zheza.com/images/blog/grp/blog_r1_c3.gif - NONE/- image/gif
Thu May 29 06:44:42 2008      3 192.168.182.172 TCP_MEM_HIT/200 519 GET http://www.zheza.com/images/blog/grp/blog_r1_c8.gif - NONE/- image/gif
Thu May 29 06:44:42 2008      4 192.168.182.172 TCP_MEM_HIT/200 615 GET http://www.zheza.com/images/blog/grp/blog_r4_c1.gif - NONE/- image/gif
Thu May 29 06:44:42 2008      3 192.168.182.172 TCP_MEM_HIT/200 472 GET http://www.zheza.com/images/blog/grp/1_r3_c2.gif - NONE/- image/gif
Thu May 29 06:44:42 2008      5 192.168.182.172 TCP_MEM_HIT/200 458 GET http://www.zheza.com/images/blog/grp/blog_r2_c8.gif - NONE/- image/gif
Thu May 29 06:44:42 2008      3 192.168.182.172 TCP_MEM_HIT/200 457 GET http://www.zheza.com/images/blog/grp/blog_r8_c3.gif - NONE/- image/gif

เป็นต้น

ถ้าต้องการให้แสดงผลออกมาเป็น file ก็ใช้คำสั่ง

root@myhost:/var/log/squid#./timeconvert.pl access.log > squid.logfile

ก็จะได้ไฟล์ที่แปลงเวลาเรียบร้อยแล้ว

ถ้าต้องการค้นหาเป็นวัน หรือบางช่วงเวลา ก็ใช้คำสั่ง grep เพื่อดักเฉพาะข้อมูลที่เราต้องการได้ เช่น

ต้องการทราบว่า วันที่ 29 พฤษภาคม 2551 ช่วงเวลา 8:20 ในร้านมีเครื่องไหนเข้าเวปอะไรบ้าง ก็ใช้คำสั่ง

root@myhost:/var/log/squid# ./timeconvert.pl access.log | grep 'May 29 08:20'

*** บางเครื่องอาจจะมี logfile หลายไฟล์ เนื่องจากการทำ rotate จะต้องค้นหาให้ตรงกับไฟล์และเวลาของข้อมูลในไฟล์ ***

โค๊ด: [Select]
Thu May 29 08:20:14 2008    118 192.168.182.137 TCP_MISS/200 841 GET http://www.kapook.com/images/bigbanner/test.php - DIRECT/203.150.224.174 text/html
Thu May 29 08:20:14 2008    139 192.168.182.137 TCP_MISS/200 1791 GET http://164.115.2.192/banner/adshow.php?zid=81 - DIRECT/164.115.2.192 text/html
Thu May 29 08:20:14 2008    201 192.168.182.137 TCP_MISS/200 371 GET http://164.115.2.192/banner/keeptrack.php?bid=112&zid=81&cid=75 - DIRECT/164.115.2.192 text/html
Thu May 29 08:20:32 2008    494 192.168.182.137 TCP_MISS/200 856 GET http://www.kapook.com/images/bigbanner/test.php - DIRECT/203.150.224.176 text/html
Thu May 29 08:20:32 2008    140 192.168.182.137 TCP_MISS/200 1793 GET http://164.115.2.192/banner/adshow.php?zid=81 - DIRECT/164.115.2.192 text/html
Thu May 29 08:20:32 2008    162 192.168.182.137 TCP_MISS/200 371 GET http://164.115.2.192/banner/keeptrack.php?bid=113&zid=81&cid=76 - DIRECT/164.115.2.192 text/html
Thu May 29 08:20:50 2008    374 192.168.182.137 TCP_MISS/200 841 GET http://www.kapook.com/images/bigbanner/test.php - DIRECT/203.150.224.174 text/html
Thu May 29 08:20:50 2008    139 192.168.182.137 TCP_MISS/200 1809 GET http://164.115.2.192/banner/adshow.php?zid=81 - DIRECT/164.115.2.192 text/html
Thu May 29 08:20:50 2008    187 192.168.182.137 TCP_MISS/200 371 GET http://164.115.2.192/banner/keeptrack.php?bid=105&zid=81&cid=70 - DIRECT/164.115.2.192 text/html

เราก็จะทราบได้ว่า เครื่อง IP หมายเลข 192.168.182.137 เข้าเวปที่แสดงผลออกมา

ถ้าเป็นร้านอินเตอร์เน็ตก็ควรจะตั้งค่า IP ประจำเครื่องไว้
แต่ถ้าเป็นหอพัก หรือองค์กรที่ใช้แบบ Dynamic IP ก็จำเป็นจะต้องเก็บ Logfile ของ IP ไว้ด้วย

1614
Linux Server System / Re: Kernel-2.6.24 + iptables-1.4.0 + L7-filter-2.17 + ipp2p-0.8.2
« เมื่อ: 01 มิถุนายน 2008, 15:06:11 »
การใช้ module recent ในการ Block IP ที่ทำการ Brute Force port SSH (เดาสุ่มพาสเวิร์ด)

iptables -I INPUT -i ppp+ -p tcp --dport 22 -m state --state NEW -m recent --set --name SSH
iptables -I INPUT -i ppp+ -p tcp --dport 22 -m state --state NEW -m recent --update --name SSH --seconds 60 --hitcount 4 -j DROP



จากตัวอย่างเป็นการตั้งค่า หากมีการเชื่อมต่อ Port 22 มาเกิน 3 ครั้งใน 1 นาที ก็จะทำการ Block IP นั้น เป็นต้น

1615
Linux Server System / Re: Kernel-2.6.24 + iptables-1.4.0 + L7-filter-2.17 + ipp2p-0.8.2
« เมื่อ: 01 มิถุนายน 2008, 14:35:42 »
module iprange ก็เป็นอีกโมดูลใน iptables ที่นำมาใช้ประโยชน์ได้เยอะ

โดยไม่ต้องทำการแบ่งเป็น subnet ย่อยๆ อีกต่อไป สามารถกำหนด ip ต้น และ ip ปลายได้เลย

เช่น การกำหนดให้ IP 172.16.6.200-254 สามารถ SSH เข้า Server 172.16.6.11 ได้ ก็สามาถใช้คำสั่ง

iptables -A INPUT -i eth0 -m iprange --src-range 172.16.6.200-172.16.6.254 -d 172.16.6.11 -p tcp --dport 22 -j ACCEPT

เป็นต้น

สามารถกำหนดต้นทางและปลายทางโดยไม่ต้องสนใจ netmask

เช่น   192.168.1.1-192.168.2.254 
หรือ   10.0.0.1-100.100.100.254

เป็นต้น

1616
Linux Server System / Traffic Shape with Ubuntu
« เมื่อ: 01 มิถุนายน 2008, 11:32:56 »
Ref : http://www.weijl.org/index.php?page=cbq-traffic-shaping

CBQ traffic shaping with Debian

Version 0.1, 2008-03-31

Traffic shaping (also known as "packet shaping") is an attempt to control computer network traffic in order to optimize or guarantee performance, lower latency, and/or increase usable bandwidth by delaying packets that meet a certain criteria. More specifically, traffic shaping is any action on a set of packets (often called a stream or a flow) which imposes additional delay on those packets such that they conform to some predetermined constraint (a contract or traffic profile). Traffic shaping provides a means to control the volume of traffic being sent into and/or from a network in a specified period (bandwidth throttling), or the maximum rate at which the traffic is sent (rate limiting). This control can be accomplished in many ways and for many reasons; however traffic shaping is always achieved by delaying packets.

What I was looking for is a way to 'cap' my connection, so it won't halt when someone is downloading something from (for example) my website. This can be done with traffic shaping, and a package called shaper is going to make this pretty easy. In this document I will discuss what you need in order to start 'capping' and give some examples to get you started.



Table of Contents
What do we need?
Example configurations files
Testing our shaped connection


--------------------------------------------------------------------------------


What do we need?
What we need is a package called shaper, which can be found in the debian repositories. Just apt-get it and we can go to work!
root@hostname# apt-get update
root@hostname# apt-get upgrade
root@hostname# apt-get install shaper


It is possible you do not have some packages it relies on (like iproute), but apt will take care of that for you just fine.




Example configuration files
Now shaper is installed we can create our configuration files for it and start capping that precious bandwidth. But before I start with the examples let's first look at the statements that I will be using. I had trouble to find the documentation, but a friend of mine pointed me to the init script itself.
# DEVICE=<ifname>,<bandwidth>[,<weight>] mandatory
# DEVICE=eth0,10Mbit,1Mbit
#
# <ifname> is the name of the interface you want to control traffic on, e.g. eth0
# <bandwidth> is the physical bandwidth of the device, e.g. for ethernet 10Mbit or 100Mbit,
# for arcnet 2Mbit
# <weight> is tuning parameter that should be proportional to <bandwidth>.
# As a rule of thumb: <weight> = <bandwidth> / 10
#
# When you have more classes on one interface, it is enough to specify <bandwidth>
# [and <weight>] only once, therefore in other files you only need to set DEVICE=<ifname>.
#
# RATE=<speed> mandatory
# RATE=5Mbit
#
# Bandwidth allocated to the class. Traffic going through the class is shaped to conform to
# specified rate. You can use Kbit, Mbit or bps, Kbps and Mbps as suffices. If you don't
# specify any unit, bits/sec are used. Also note that "bps" means "bytes per second", not bits.
#
# WEIGHT=<speed> mandatory
# WEIGHT=500Kbit
#
# Tuning parameter that should be proportional to RATE. As a rule of thumb,
# use WEIGHT ~= RATE / 10.
#
# PRIO=<1-8> optional, default 5
# PRIO=5
#
# Priority of class traffic. The higher the number, the lesser the priority.
# Priority of 5 is just fine.
#
# RULE=[[saddr[/prefix]][:port[/mask]],][daddr[/prefix]][:port[/mask]]
#
# These parameters make up "u32" filter rules that select traffic for each of the classes.
# You can use multiple RULE fields per config.
#
# The optional port mask should only be used by advanced users who
# understand how the u32 filter works.
#
# Some examples:
#
# RULE=10.1.1.0/24:80
# selects traffic going to port 80 in network 10.1.1.0
#
# RULE=10.2.2.5
# selects traffic going to any port on single host 10.2.2.5
#
# RULE=10.2.2.5:20/0xfffe
# selects traffic going to ports 20 and 21 on host 10.2.2.5
#
# RULE=:25,10.2.2.128/26:5000
# selects traffic going from anywhere on port 50 to
# port 5000 in network 10.2.2.128
#
# RULE=10.5.5.5:80,
# selects traffic going from port 80 of single host 10.5.5.5


I only grabbed the statements I am going to use in this document, but if you're curious what else shaper can do, look at the init file located at /etc/init.d/shaper.

Below is an outgoing SMTP example. You should be placed in /etc/shaper, and let's just name it cbq-0020-smtp.
DEVICE=eth0,100Mbit,10Mbit
RATE=512Kbit
WEIGHT=52Kbit
PRIO=4
RULE=,:25


Let's give another example but now on an incoming HTTP connection. For obvious reasons let's call this one cbq-0030-http.
DEVICE=eth0,100Mbit,10Mbit
RATE=512Kbit
WEIGHT=52Kbit
PRIO=4
RULE=:80,


Of course after you have made the configuration files, we need to restart shaper in order for it to work.
root@hostname# /etc/init.d/shaper restart


Both examples should cap the connection to a maximum of 512Kbit or 64Kbyte.


Testing our shaped connection
Just try and download something from your webserver now. Pretty neat huh?! I can imagine you do not want this behaviour for you localnetwork, so we have to create one more config file in order for it to work like we want it! Let us call it cbq-0010.http-localnetwork
DEVICE=eth0,100Mbit,10Mbit
RATE=100Mbit
WEIGHT=10Mbit
PRIO=4
RULE=:80,<network_range/subnet>


This can probably be done more efficiently, but since this worked for me I didn't look any further.


1617
ในการทำ Firewall นั้น เราจะต้องทราบข้อมูลเข้าและข้อมูลออกทั้งหมดของ Server โดยจะต้องระบุ IP ต้นทาง, IP ปลายทาง, Port และ Protocol เป็นอย่างน้อย

ยกตัวอย่างกรณีแรก เครื่อง Server ทำหน้าที่เป็น Web Server และ Proxy Server
มี 1 Interface คือ eth0 โดยมี IP เป็น 172.16.6.11

ดังนั้น กฎที่เราต้องสร้างขึ้นจะมี 2 รูปแบบ ก็กำหนดได้โดย
1. กำหนดข้อมูลที่วิ่งเข้ามายัง Server
- สามารถเชื่อมต่อมายัง Server ต้นทาง IP 172.16.6.0/24 ด้วย Protocol TCP Port 80 (Web Server)
- สามารถเชื่อมต่อมายัง Server ต้นทาง IP 172.16.6.0/24 ด้วย Protocol TCP Port 8080 (Proxy Server)
- สามารถเชื่อมต่อมายัง Server ได้เฉพาะกลุ่ม IP 172.16.6.200-254 ด้วย Protocol TCP Port 22 (SSH Server)
- สามารถเชื่อมต่อมายัง Server ได้เฉพาะกลุ่ม IP 172.16.6.200-254 ด้วย Protocol TCP Port 10000 (Webmin)
- สามารถปิงเข้ามายัง Server ได้ ต้นทาง IP 172.16.6.0/24
- นอกเหนือจากกฎเหล่านี้ให้ DROP
2. กำหนดข้อมูลที่วิ่งออกจาก Server
- สามารถออกได้หมดทุก ip/port/protocol

เริ่มต้นในการ set firewall นั้น จะเริ่มทำการปิด หรือ DROP policy ของทุก Chain ก่อน

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP


#1. กำหนดข้อมูลที่วิ่งเข้ามายัง Server
#สามารถเชื่อมต่อมายัง Server ต้นทาง IP 172.16.6.0/24 ด้วย Protocol TCP Port 80 (Web Server)
iptables -A INPUT -i eth0 -s 172.16.6.0/24 -d 172.16.6.11 -p tcp --dport 80 -j ACCEPT

#สามารถเชื่อมต่อมายัง Server ต้นทาง IP 172.16.6.0/24 ด้วย Protocol TCP Port 8080 (Proxy Server)
iptables -A INPUT -i eth0 -s 172.16.6.0/24 -d 172.16.6.11 -p tcp --dport 8080 -j ACCEPT

#สามารถเชื่อมต่อมายัง Server ได้เฉพาะกลุ่ม IP 172.16.6.200-254 ด้วย Protocol TCP Port 22 (SSH Server)
iptables -A INPUT -i eth0 -m iprange --src-range 172.16.6.200-172.16.6.254 -d 172.16.6.11 -p tcp --dport 22 -j ACCEPT

#สามารถเชื่อมต่อมายัง Server ได้เฉพาะกลุ่ม IP 172.16.6.200-254 ด้วย Protocol TCP Port 10000 (Webmin)
iptables -A INPUT -i eth0 -m iprange --src-range 172.16.6.200-172.16.6.254 -d 172.16.6.11 -p tcp --dport 10000 -j ACCEPT

#สามารถปิงเข้ามายัง Server ได้ ต้นทาง IP 172.16.6.0/24
iptables -A INPUT -i eth0 -s 172.16.6.0/24 -d 172.16.6.11 -p icmp -j ACCEPT

#2. กำหนดข้อมูลที่วิ่งออกจาก Server
iptables -A OUTPUT -o eth0 -j ACCEPT

เป็นอันเรียบร้อย สำหรับตัวอย่างแรก

ลองใช้คำสั่ง iptables -nvL เพื่อดู rule ที่เพิ่มเข้าไป

1618
การทำ Firewall นั้น ก็คือการสร้างกฎเพื่อกำหนดการเข้าและออกของข้อมูล

กรณีที่มี 1 Interface หรือเป็นแค่เพียง Server ให้บริการธรรมดา ก็จะต้องกำหนดกฎ 2 รูปแบบ
1. กำหนดข้อมูลที่วิ่งเข้ามายัง Server
2. กำหนดข้อมูลที่วิ่งออกจาก Server

กรณีที่มี 2 Interface และทำหน้าที่เป็น Gateway และให้บริการด้วย จะต้องกำหนดกฎ 4 รูปแบบ
1. กำหนดข้อมูลที่วิ่งเข้ามายัง Server ทางขา WAN และ ขา LAN
2. กำหนดข้อมูลที่วิ่งออกจาก Server ทางขา WAN และ ขา LAN
3. ข้อมูลที่วิ่งจาก Localnet ออกไปยัง InterNet
4. ข้อมูลที่วิ่งจาก InterNet เข้ามายัง LocalNet

กรณีที่มี 3 Interface ทำหน้าที่เป็น Gateway และมี Interface DMZ เพิ่มขึ้นมา เพื่อรักษาความปลอดภัยให้ Server ภายใน
1. กำหนดข้อมูลที่วิ่งเข้ามายัง Server ทางขา WAN ,ขา LAN และขา DMZ
2. กำหนดข้อมูลที่วิ่งออกจาก Server ทางขา WAN ,ขา LAN และขา DMZ
3. ข้อมูลที่วิ่งจาก Localnet ออกไปยัง InterNet
4. ข้อมูลที่วิ่งจาก Localnet ออกไปยัง DMZ
5. ข้อมูลที่วิ่งจาก DMZ ออกไปยัง Internet
6. ข้อมูลที่วิ่งจาก DMZ ออกไปยัง LocalNet
7. ข้อมูลที่วิ่งจาก Internet เข้ามายัง LocalNet
8. ข้อมูลที่วิ่งจาก Internet เข้ามายัง DMZ


1619
การเดินทางของ Packet ผ่าน Server จะแบ่งได้เป็น 3 กรณี คือ

1. ข้อมูลวิ่งมายังเครื่อง Server
กรณีนี้คือ เครื่อง Server เป็นผู้ให้บริการ เช่น ftp, web, mail, dns หรือ proxy เป็นต้น
แล้วเครื่องลูกข่าย หรือเครื่องจากภายนอก วิ่งเข้ามายังเครื่อง Server

การเดินทางของ Packet จะเป็นดังนี้ คือ

จาก Interface ของ Server เช่น eth0, ppp0 หรืออื่น ๆ ที่ข้อมูลวิ่งเข้ามา จะวิ่งเข้ามายัง
Chain PREROUTING  --> Conntrack , mangle , nat ตามลำดับ  จากนั้นก็จะวิ่งไปยัง
Routing Process
Chain INPUT --> Filter , Conntrack , mangle ตามลำดับ จากนั้นก็จะวิ่งไปยัง
Local Process

สรุปง่าย ๆ คือ  Interface -> PREROUTING --> Routing Process --> INPUT --> Local Process

2. ข้อมูลวิ่งออกจากเครื่อง Server
กรณีนี้คือ เมื่อเครื่อง Server ได้รับการติดต่อมาจากภายนอก แล้วทำการตอบกลับ ก็จะมีการส่งข้อมูลออก
เช่น การปิงมายัง Server , การส่งข้อมูลไปยังเครื่องลูกข่าย

การเดินทางของ Packet จะเป็นดังนี้

Local Process
Chain OUTPUT --> Conntrack , mangle , nat , filter ตามลำดับ จากนั้นจะวิ่งไปยัง
Routing Process
Chain POSTROUTING --> mangle , nat , Conntrack ตามลำดับ จากนั้นก็จะวิ่งไปยัง
สู่ Interface ของ Server เช่น ppp0, eth0 เพื่อส่งข้อมูลออกไป

สรุป ง่าย ๆ คือ Local Process --> OUTPUT --> Routing Process --> POSTROUTING --> Interface

3. ข้อมูลวิ่งผ่านเครื่อง Server
ในกรณีที่เครื่องของเราทำหน้าที่เป็น Gateway ก็จะมีข้อมูลวิ่งจาก Interface นึงไปยังอีก Interface นึง
ไม่ว่าจะเป็นจาก WAN --> LAN  หรือ จาก LAN --> WAN ก็จะมีลักษณะเหมือนกัน

ซึ่งจะแทนด้วย Interface A ไปยัง Interface B การเดินทางของ Packet จะเป็นดังนี้

เริ่มต้นจากเข้ามาสู่ Interface A
Chain PREROUTING --> Conntrack , mangle , nat ตามลำดับ จากนั้นจะวิ่งไปยัง
Routing Process
Chain FORWARD --> mangle , filter ตามลำดับ จากนั้นจะวิ่งไปยัง
Chain POSTROUTING --> mangle , nat , Conntrack ตามลำดับ จากนั้นจะวิ่งไปยัง
วิ่งออกทาง Interface B

สรุป ง่าย ๆ คือ Interface A --> PREROUTING --> Routing Process --> FORWARD --> POSTROUTING --> Interface B


1620
ปูพื้นฐานเรื่องความรู้เรื่อง port , ip และ Protocol กันก่อน
IP
หมายเลข IP จะประกอบด้วย 32 bit  4 กลุ่ม คั่นด้วย . นั่นก็คือ   8bit . 8bit . 8bit . 8bit
192.168.0.100 = 11000000.10101000.00000000.01100100
172.16.20.5 = 10101100.00010000.00010100.00000101
10.0.100.1 = 00001010.00000000.01100100.00000001

NetMask จะประกอบด้วย จำนวนเลข 1 ทางซ้ายมือ และจำนวนเลข 0 ทางขวามือ
11111111.11111111.11111111.11111111 = 255.255.255.255 หรือ /32 (บิตที่เป็น 0 ไม่มี)
11111111.11111111.11111111.00000000 = 255.255.255.0 หรือ /24 (บิตที่เป็น 1 มีจำนวน 24 บิต)
11111111.11111111.00000000.00000000 = 255.255.0.0 หรือ /16 (บิตที่เป็น 1 มีจำนวน 16 บิต)
11111111.00000000.00000000.00000000 = 255.0.0.0 หรือ /8 (บิตที่เป็น 1 มีจำนวน 8 บิต)
00000000.00000000.00000000.00000000 = 0.0.0.0 หรือ /0 (บิตที่เป็น 1 ไม่มี)

Network และ Subnet
ในการอ้างอิง Network นั้นจะต้องระบุ ชื่อ Network และ Netmask เพื่อระบุขนาด เช่น
192.168.200.0/255.255.255.0 โดยที่ /255.255.255.0 สามารถแทนได้ด้วย /24
จะได้เป็น 192.168.200.0/24 จะมีความหมายเหมือนกัน

Private IP และ Public IP
Private IP ที่ใช้กันคือ
10.0.0.0/8  172.16.0.0/12  192.168.0.0/16
IP ที่นอกเหนือจากนี้จะถือเป็น Public IP

Port
System Port คือ Port ตั้งแต่ 1 ถึง 1024
Application Port คือ Port ตั้งแต่ 1025 ถึง 65535

Protocol
TCP
UDP
ICMP

หน้า: 1 ... 106 107 [108] 109 110 ... 115