Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to block ports (just using 21 as an example).
I tried using:
$IPTABLES -A INPUT -i eth0 -p tcp --dport 21 -j DROP
I saw that off an example on another post, I also tried:
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 21 -j denied (also DROP, reject, etc).
When I go to run the firewall again, it runs fine, but on nmaping the machine and also ftping from the outside, it still allows access. Still showing open. I also tried adding an -N denied (DROP, reject, etc) with no luck on that. Can anybody please inform me of how I should go about doing this?
Also another question, how can I allow unrestricted access from a specific subnet?
Is your external (internet) interface eth0 or is that your LAN? If you have the wrong interface, the external scan will still show the port as open. A simpler approach might be to have a default policy of drop for the input chain and then allowing ports as you need them.
The following should drop anything coming in on tcp port 21 on eth0:
Code:
iptables -A INPUT -p tcp --dport 21 -j DROP
However, make sure there are no rules ACCEPTing port 21 before this one. You might want to try -I INPUT to insert it in the input chain at the beginning.
iptables: Chain already exists
iptables: Chain already exists
iptables: Chain already exists
iptables: Chain already exists
iptables: Chain already exists
iptables: No chain/target/match by that name
That's what shows up when I execute the firewall. The last line has come up before this, something else is causing it (I'm too stupid to figure it out). But regardless, adding that command apparently didn't shoot out any other errors, but I can still FTP in from an outside source. I don't believe "DROP" is known to it.
Chain names I have right now are "allowed" "tcp_packets" "udp_packets" and "icmp_packets", don't know if that matters.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.