20101230 iptables for blocking traffic from a box - plembo/onemoretech GitHub Wiki

title: iptables for blocking traffic from a box link: https://onemoretech.wordpress.com/2010/12/30/iptables-for-blocking-traffic-from-a-box/ author: lembobro description: post_id: 91 created: 2010/12/30 11:01:01 created_gmt: 2010/12/30 11:01:01 comment_status: open post_name: iptables-for-blocking-traffic-from-a-box status: publish post_type: post

iptables for blocking traffic from a box

Had a situation today where it would have been useful to be able to block traffic on a certain port from getting off a box.

There’s a great intro to iptables over on the CentOS Wiki, entitled IPTables that explains the syntax you’d need to know on a typical RHEL system.

From what I have gathered so far, to set up an entry to block all outgoing traffic on a particular port you’d issue this command:

iptables -A OUTPUT -p tcp -dport 389 -j DROP

To block only traffic on that port to a particular host, the syntax would be:

iptables -A OUTPUT -p tcp -d 192.168.23.105 -dport 389 -j DROP

Copyright 2004-2019 Phil Lembo