Hướng dẫn tắt,mở dịch vụ tường lửa firewalld trên CentOS 6

Tường lửa là gì?

Trong ngành mạng máy tính, tường lửa (firewall) là rào chắn mà một số cá nhân, tổ chức, doanh nghiệp, cơ quan nhà nước lập ra nhằm ngăn chặn các truy cập thông tin không mong muốn từ ngoài vào hệ thống mạng nội bộ cũng như ngăn chặn các thông tin bảo mật nằm trong mạng nội bộ xuất ra ngoài internet mà không được cho phép.

Tường lửa là một thiết bị phần cứng hoặc một phần mềm hoạt động trong một môi trường máy tính nối mạng để ngăn chặn một số liên lạc bị cấm bởi chính sách an ninh của cá nhân hay tổ chức. Tường lửa còn được gọi là Thiết bị bảo vệ biên (Border Protection Device – BPD), đặc biệt trong các ngữ cảnh của NATO, hay bộ lọc gói tin (packet filter) trong hệ điều hành BSD – một phiên bản Unix của Đại học California, Berkeley.

Vậy trên hệ điều hành Centos 6/7 thì cấu hình tường lửa như thế nào, mời các bạn cùng tìm hiểu nhé.

Centos 6.x

Cài đặt

Tường lửa thường được cài mặc định theo hệ điều hành, để kiểm tra đã có tường lửa trong hệ thống hay chưa, bạn dùng lệnh:

# iptables –version

Nếu chưa thì cài đặt bằng lệnh sau:

# yum install iptables

Cấu hình iptables

Kiểm tra ban đầu:

Để mở port cần thiết bạn cần phải xác định được service muốn mở và port nó.

Ví dụ:

Dịch vụ SSH để truy cập vào máy chủ sử dụng port 22

Dịch vụ Web gồm HTTP (port: 80) và HTTPS(port: 443)

Nhận gửi thư thông qua SMTP (25) và SMTPS (465/587)

Nhận thư thông qua POP3 (110), IMAP (143)

Bạn có thể đóng tất cả các port đang mở bằng lệnh:

# iptables -F

Xem danh sách cổng (port) đang mở:

# iptables -L -n

Các cột trong ảnh có ý nghĩa như sau:

  • target: hành động sẽ được áp dụng
  • Accept: gói dữ liệu được chuyển tiếp để xử lý.
  • Drop: gói dữ liệu bị chặn và tiêu hủy.
  • Reject: gói dữ liệu bị chặn, và tiêu hủy đồng thời thông báo lỗi tới người gửi.
  • prot (protocol – giao thức) quy định các giao thức sẽ được áp dụng bao gồm: all, TCP hay UDP.
  • source: địa chỉ nguồn
  • destination: địa chỉ đích

Mở port

Mở port bằng lệnh:

# iptables -I INPUT -m state –state NEW -m tcp -p tcp –dport XXX -j ACCEPT

Trong đó XXX là port muốn mở.

Lưu cấu hình iptable:

# service iptables save

Khởi động lại dịch vụ:

# service iptables restart

Kiểm tra xem port đã được mở chưa:

# iptables -L –n

Đóng port

Để đóng port bạn chỉ cần chỉnh sửa file iptable bằng lệnh:

# vi /etc/sysconfig/iptables

Sau đó muốn đóng port nào thì comment dòng đó bằng cách thêm dấu # vào phía trước.

Chặn IP

Để chặn 1 IP bất kì truy cập bạn dùng lệnh:

# iptables -A INPUT -s IP_ADDRESS -j DROP

Lưu cấu hình

Sau khi đã thiết lập mở/chặn port, bạn cần chặn toàn bộ kết nối còn lại và mở toàn bộ kết nối từ máy chủ ra ngoài.

Mở tất cả kết nối từ máy chủ ra ngoài:

# iptables -P OUTPUT ACCEPT

Chặn tất cả kết nối còn lại:

# iptables -P INPUT DROP

Kiểm tra lại một lần nữa:

# iptables -L –n

Tránh việc phải cấu hình lại khi reboot máy chủ thì bạn phải lưu lại những thiếp lập đã thực hiện bằng lệnh:

# iptables-save | sudo tee /etc/sysconfig/iptables

Hoặc

# service iptables save

Kết quả trả về như sau là lưu thành công:

Chúc các bạn thành công !

Nếu trong quá trình thực hiện xảy ra lỗi hay sự cố gì, các bạn có thể liên hệ bộ phận kỹ thuật để được giúp đỡ. Hiện tại BKHOST có các cách liên hệ như sau:
• Liên hệ qua số tổng đài 024 7303 8088, sau đó ấn phím 2 để gặp BPKT.
• Gửi ticket thông qua trang web id.bkhost.vn.
• Live chat trực tiếp trên trang chủ bkhost.vn.

 

Tags:
superbetin güncel giriş superbetin giriş superbetin Onay kodu Sanal numara Mobil onay SMS onay superbetin güncel giriş superbetin giriş superbetin superbetin superbetin güncel giriş superbetin giriş superbetin superbetin superbetin güncel giriş superbetin giriş superbetin superbetin perabet güncel giriş perabet giriş perabet perabet perabet güncel giriş perabet giriş perabet perabet betsat güncel giriş betsat giriş betsat betsat xslot güncel giriş xslot giriş xslot xslot cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet grandpashabet güncel giriş grandpashabet giriş grandpashabet grandpashabet güncel giriş grandpashabet giriş grandpashabet grandpashabet güncel giriş grandpashabet giriş grandpashabet grandpashabet güncel giriş grandpashabet giriş grandpashabet wbahis güncel giriş wbahis giriş wbahis wbahis wbahis güncel giriş wbahis giriş wbahis wbahis robinbet güncel giriş robinbet giriş robinbet robinbet robinbet güncel giriş robinbet giriş robinbet robinbet robinbet güncel giriş robinbet giriş robinbet robinbet timebet güncel giriş timebet giriş timebet timebet betsilin güncel giriş betsilin giriş betsilin betsilin betsilin güncel giriş betsilin giriş betsilin betsilin avrupabet güncel giriş avrupabet giriş avrupabet avrupabet avrupabet güncel giriş avrupabet giriş avrupabet avrupabet betpas güncel giriş betpas giriş betpas betpas betpas güncel giriş betpas giriş betpas betpas casinoroys güncel giriş casinoroys giriş casinoroys casinoroys casinoroys güncel giriş casinoroys giriş casinoroys casinoroys parmabet güncel giriş parmabet giriş parmabet parmabet parmabet güncel giriş parmabet giriş parmabet parmabet süratbet güncel giriş süratbet giriş süratbet süratbet süratbet güncel giriş süratbet giriş süratbet süratbet galyabet güncel giriş galyabet giriş galyabet galyabet galyabet güncel giriş galyabet giriş galyabet galyabet betwoon güncel giriş betwoon giriş betwoon betwoon betwoon güncel giriş betwoon giriş betwoon betwoon norabahis güncel giriş norabahis giriş norabahis norabahis norabahis güncel giriş norabahis giriş norabahis norabahis timebet güncel giriş timebet giriş timebet timebet timebet güncel giriş timebet giriş timebet timebet robinbet güncel giriş robinbet giriş robinbet robinbet robinbet güncel giriş robinbet giriş robinbet robinbet jojobet güncel giriş jojobet giriş jojobet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet betcio güncel giriş betcio giriş betcio betcio güncel giriş betcio giriş betcio cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet bahislion güncel giriş bahislion giriş bahislion jojobet güncel giriş jojobet giriş jojobet jojobet güncel giriş jojobet giriş jojobet betcio güncel giriş betcio giriş betcio betcio güncel giriş betcio giriş betcio cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet cratosroyalbet güncel giriş cratosroyalbet giriş cratosroyalbet cratosroyalbet grandpashabet güncel giriş grandpashabet giriş