Thursday, October 12, 2017

ການໃຊ້ງານ UFW ເພື່ອເຮັດເປັນ host firewall ເທິງ Ubuntu

Image does not exist: https://1.bp.blogspot.com/-mqYP588h8yQ/VwE2Rix-clI/AAAAAAAAQOU/9JBYWeuO_bIE53DyTRfgqxDPKbJr2u_Wg/s1600/ufw8.JPG
UFW ຫຍໍ້ມາຈາກ Uncomplicated Firewall ເປັນໂປຣແກຣມທີ່ຕິດຕັ້ງໄວ້ໃຫ້ແລ້ວເທິງ ubuntu 16.04 ແຕ່ຢັງບໍ່ເປີດໃຊ້ງານ
UFW ເຮັດໃຫ້ການ allow ແລະ deny ການເຂົ້າເຖິງ port ຂອງ service ຕ່າງ ໆ ສະດວກກວ່າການຂຽນຄຳສັ່ງ iptables ຢ່າງໃດກໍຕາມະຫາກເຮົາຮູ້ເລື່ອງ iptables ກໍຈະເປັນການດີ
ນອກຈາກໂປຣແກຣມ UFW ແລ້ວ ອີກຕົວໜຶ່ງທີ່ເຄີຍຂຽນບັນທຶກໄວ້ ແລະ ໃຊ້ງານກັນຢູ່ຄື shorewall ກໍຂໍໃຫ້ເລືອກເອົາວ່າຈະໃຊ້ງານຕົວໃດ ແຕ່ຄິດວ່າ ເຮົາໜ້າຈະໃຊ້ UFW ເພາະ ubuntu ໃຫ້ມາຢູ່ແລ້ວ ແລະ ຂຽນ rule ໄດ້ງ່າຍ

ການເປີດໃຊ້ UFW

sudo ufw enable

ການເປີດໃຊ້ UFW ຈະເປັນການ DENY ALL ດັ່ງນັ້ນຫຼັງຈາກຄຳສັ່ງນີ້ ເຮົາຈະຕ້ອງ allow port ທີ່ໃຫ້ບໍລິການທັນທີ
ການກວດສອບສະຖານະ

sudo ufw status verbose

ຜົນຮັບ

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip


ຖ້າເຄີຍ allow 25/tcp, 22/tcp ເຮົາຈະເຫັນຜົນຮັບເປັນແບບນີ້

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To Action From
– —— —-
25/tcp ALLOW IN Anywhere
22/tcp ALLOW IN Anywhere
25/tcp (v6) ALLOW IN Anywhere (v6)
22/tcp (v6) ALLOW IN Anywhere (v6)

ການປິດ UFW

sudo ufw disable

ການກວດສອບລະດັບລຸ່ມ (ເບິ່ງ iptables rules)

sudo ufw show raw

ໄວຍະກອນຂອງຄຳສັ່ງ UFW ໃຊ້ງ່າຍ ປະມານນີ້
ຄຳສັ່ງ Allow

sudo ufw allow <port>/<optional: protocol>

ເຊັ່ນ

sudo ufw allow 53/udp
sudo ufw allow from xxx.xxx.xxx any port xxxx 

ຄຳສັ່ງ Deny

sudo ufw deny <port>/<optional: protocol>

ເຊັ່ນ

sudo ufw deny 53/tcp

ການລົບ rule (delete rule)

sudo ufw delete <ຄຳສັ່ງ><port>/<optional: protocol>

ເຊັ່ນ

sudo ufw delete allow 53/udp
sudo ufw delete deny 53/tcp

ການເຮັດວຽກຂອງ UFW rule
UFW ອ່ານຈາກ rule ຈາກເທິງລົງລຸ່ມ ພົບແລ້ວ matched ເລີຍ ບໍ່ເຮັດຕໍ່ rule ຂ້າງລຸ່ມ ຈຶ່ງຕ້ອງລຽງລຳດັບໃຫ້ດີ
ດັ່ງນັ້ນຫາກເຮົາຈະປ່ຽນແປງ rule ກໍຈະຕ້ອງລົບ rule ເກົ່າດ້ວຍ ກ່ອນຈະໃສ່ rule ໃໝ່ເຂົ້າໄປ

ການລົບ ຫລື ແຊກ rule ກົງຕຳແໜ່ງບັນທັດ
ກວດສອບ

sudo ufw status numbered

ເຊັ່ນ ລົບ rule ທີ່ 1

sudo ufw delete 1

ແຊກໃຫ້ເປັນ rule ທີ່ 1

sudo ufw insert 1 allow from <ip address>

src.opensource.cc.psu.ac.th
[tag]Linux, Firewall, ufw[/tag]

Subscribe

  • RSS Atom

ອອນລາຍ: 1 | ມື້ນີ້: 13 | ວານນີ້: 25 | ທິດນີ້: 93 | ເດືອນນີ້: 872 | ປີນີ້: 11832 | ລວມ: 78935