Skip to content
 

Cấm 1 người dùng tạo kết nối ra ngoài bằng Iptables trên Linux!

Iptables

Iptables có 1 module gọi là “owner” (ipt_owner cho kernel <2.6.25 xt_owner cho kernel >=2.6.25) cho phép người quản trị có thể cấm 1 người dụng nhất định trên hệ thống cục bộ  tạo kết nối ra ngoài. Module “owner” chỉ hợp lệ trong chain OUTPUT và POSTROUTING của iptables. Sau đây là cú pháp:

iptables -A OUTPUT -o ethX -m owner –uid-owner {USERNAME} -j DROP|REJECT

Ví dụ: Muốn cấm người dụng có tên là “jenny” có user id là 505 thì rule iptables sẽ như sau:

iptables -A OUTPUT -m owner –uid-owner jenny -j DROP

Hoặc:

iptables -A OUTPUT -m owner –uid-owner 505 -j DROP

Tham số: “uid-owner” : thì sử dụng username hoặc userid đều được.
Cuối cùng nhớ lưu rules iptables lại!
(Ví dụ trên được thực hiện trên Centos 5.5)

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

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Vietnam License.

One Comment

  1. […] This post was mentioned on Twitter by Haiphong-Fc.Com, Hien aka 0daydevilz . Hien aka 0daydevilz said: Cấm 1 người dùng tạo kết nối ra ngoài bằng Iptables trên Linux!: Iptables có 1 module gọi là “owner” (ipt_owner)… http://bit.ly/deVBv6 […]