TechFree avatar

ស្វែងយល់ពី Dynamic Firewall របស់ Redhat/CentOS 7

techfree

Published: 09 Jan 2018 › Updated: 09 Jan 2018ស្វែងយល់ពី Dynamic Firewall របស់ Redhat/CentOS 7

ស្វែងយល់ពី Dynamic Firewall របស់ Redhat/CentOS 7

Untitled-Diagram.png

Firewall មានសារះសំខាន់ណាស់សម្រាប់ការប្រើប្រាស់ធ្វើជារនាំងការពារ Server ដើម្បីកុំអោយមានការលួចវាលុកឬធ្វើអោយ Service ណាមួយមិនដំណើរការនៅក្នុង Server។

Redhat/CentOS ដែលធ្លាប់តែប្រើប្រាស់ iptables ពេលនេះបានប្តូរមកប្រើប្រាស់ Dynamic Firewall ជំនួសវិញ។ ខាងក្រោមនេះជា Rule មួយចំនួនដែល Sysadmin គួរតែដឹងសម្រាប់ការងាររាល់ថ្ងៃ

systemctl restart firewalld សម្រាប់ Restart Service Firewall

systemctl enable firewalld សម្រាប់អោយ firewall ដំណើរការពេលបើកម៉ាស៊ីន

firewall-cmd –help សម្រាប់មើលពីរបៀបប្រើប្រាស់

firewall-cmd –get-default-zone សម្រាប់មើលពី Zone។ Zone ដូចជា Firewall Windows Profile នៅពេលដែលយើងភ្ជាប់ទៅកាន់ Wifi វាតែងសួរយើងថាជា Private Network ឬ Public Network ជាដើម។

zone-firewall.png

ប្រសិនបើចង់មើលថាតើ Network Card របស់យើងស្ថិតនៅក្នុង Zone អ្វីត្រូវប្រើប្រាស់ Command

public-zone.png

firewall-cmd –zone=public –list-all សម្រាប់មើលថាតើ Firewall បានត្រួតពិនិត្យលើ Service អ្វីខ្លះ?

list-all.png

ប្រសិនជាចង់ប្តូ Zone ទៅលើ interface Network ណាមួយអាចប្រើប្រាស់ Command ដូចខាងក្រោម

home-profile.png

សម្រាប់ Server អ្នកមិនគួរប្ត Firewall Zone នោះទេ គួរតែធ្វើវាអោយទៅជាអចិន្ត្រៃយ៏ ដោយចូលទៅកែប្រែ File

vi /etc/sysconfig/network-scripts/ifcfg-eno16777736

home-permanent.png

firewall-cmd –get-services សម្រាប់ឆែកមើលតើមាន Service ប៉ុន្មាននៅក្នុង Server

all-service.png

បន្ទាប់មកយើងអាច Add Service នោះអោយទៅ firewall ដើម្បីត្រួតពិនិត្យបានហើយ

add-services.png

–permanent សម្រាប់ អោយវាជាអចិន្ត្រៃុយ៏

sudo firewall-cmd –zone=public –add-port=10000/tcp សម្រាប់ Add port 10000 និង protocol TCP

sudo firewall-cmd –zone=public –add-port=3000-5000/tcp សម្រាប់ Add port នៅចន្លោះ ៣០០០ ទៅ ៥០០០ ដោយប្រើប្រាស់ protocol TCP/IP

ប្រសិនចង់ Remove service ចេញពី Firewall វិញអាចប្រើប្រាស់ command ដូចខាងក្រោម

firewall-cmd –zone=home –remove-service=http –permanent

remove-http.png

នៅពេលដែលយើង Remove ចេញពី Firewall នោះ Client មិនអាច Access មកកាន់ http server បាននោះទេ។

ប្រសិនបើចង់ Forward ពី port 80 ទៅកាន់ port 8080 ប្រើប្រាស់ command ខាងក្រោម

firewall-cmd –zone=”home” –add-forward-port=port=80:proto=tcp:toport=8080 –permanent

ប្រសិនបើអ្នកចង់អោយវា Forward បន្តទៅកាន់ Server ផ្សេងមួយទៀតត្រូវធ្វើដូចខាងក្រោមនេះ

firewall-cmd –zone=public –add-masquerade

firewall-cmd –zone=”home” –add-forward-port=port=80:proto=tcp:toport=8080:toaddr=10.5.5.2

ពេល request ទៅកាន់ port 80 វានិងរុញទៅកាន់ Server 10.5.5.2:8080

Rich Rule មានមុខងារច្រើនសម្រាប់ប្រើប្រាស់ ស៊ីជំរៅជាងធម្មតា។ Rich Rule មានមុខងាច្រើន RICHRULE

ខាងក្រោមនេះជាឧទាហរណ៏ខ្លះ អំពី ការប្រើប្រាស់Rich Rule

firewall-cmd –zone=home –add-rich-rule ‘rule family=”ipv4″ source address=192.168.1.2 accept’

សម្រាប់ Accept ipv4 traffic ចេញពី computer/device ដែលមាន IP 192.168.1.2

firewall-cmd –zone=home –add-rich-rule ‘rule family=”ipv4″ source address=”192.168.1.2″ port port=22 protocol=tcp reject’

សម្រាប់ ច្រានចោលសំណើរចេញពី Device: 192.168.1.2 ដែលប្រើប្រាស់ port 22 protocol tcp អាចជា ssh protocol។

firewall-cmd –zone=home–add-rich-rule ‘rule family=ipv4 source address=192.168.10.2 forward-port port=80 protocol=tcp to-port=8080’

សម្រាប់Forward request ចេញពី host 192.168.10.2 ទៅកាន់ port 80 របស់ Server ទៅកាន់ port 8080 របស់ Server ដោយប្រើប្រាស់ Protocol TCP/IP

firewall-cmd –zone=public –add-rich-rule ‘rule family=ipv4 forward-port port=80 protocol=tcp to-port=8080 to-addr=192.168.5.2’

សម្រាប់ Forward port 80 ទៅកាន់ Server 192.168.5.2 port 8080 ដោយប្រើប្រាស់ protocol TCP/IP

ប្រភពដើម

Leave ស្វែងយល់ពី Dynamic Firewall របស់ Redhat/CentOS 7 to:

Written by

Read more #cambodia posts


Best Posts From TechFree

We have not curated any of techfree's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From TechFree