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.
I'm the biggest idiot in the world, the one thing people fear when designing their systems:
I messed around in what I don't understand and now I'm afraid my machines going to be comprimised.
Somebody please help me out and post their iptables config (the /etc/ one) so I can get things back to normal!
All I want is blockstuff from like coming (out? (SSH, http, https, etc. access should be blocked so no remote logins)) but let stuff like web pages get loaded here. (Like let me still surf the 'net or something)
If you want to drop everything that's coming from the net to you, except for what you've started yourself, here's how it goes:
Code:
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
That's the start; you could save that as a shell script, modify it for your needs and run again to "apply" the changes. Oh, and remember to run iptables-save after you're done to save the changes so they're loaded at next boot.
What the above does, is flush all existing rules, remove all user-defined chains (so make the "tables clean"), then set incoming and forwarded traffic to be dropped, outgoing to be accepted; then add a new rule to the incoming traffic that lets stuff come trough that is related to traffic that's already going on, or that you have established. A short, nice start.
If you want to drop everything that's coming from the net to you, except for what you've started yourself, here's how it goes:
Code:
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
That's the start; you could save that as a shell script, modify it for your needs and run again to "apply" the changes. Oh, and remember to run iptables-save after you're done to save the changes so they're loaded at next boot.
What the above does, is flush all existing rules, remove all user-defined chains (so make the "tables clean"), then set incoming and forwarded traffic to be dropped, outgoing to be accepted; then add a new rule to the incoming traffic that lets stuff come trough that is related to traffic that's already going on, or that you have established. A short, nice start.
Does the configuration get updated right away? Or do I need to like modprobe something or restart my computer before things are usable? Will Pidgin still work? And what about gnutella?
Does the configuration get updated right away? Or do I need to like modprobe something or restart my computer before things are usable? Will Pidgin still work? And what about gnutella?
Thanks again!
When you run those iptables commands your active iptables configuration is changed right away.
You can check your active configuration with a:
Code:
iptables -nvL
For this to survive a reboot you need to either add the commands to your startup sequence, or save the configuration to a file (using iptables-save) and have it get loaded at startup by for example calling an iptables-restore via a pre-up in your interfaces file. The rules posted would allow anything that doesn't require open incoming ports to work, as it is a stealth config.
to save changes made to the iptables config file - use
iptables-save >/etc/iptables.conf
to restore from that file - use in shell:
iptables-restore </etc/iptables.conf
obviously you may run above save command to create a second backup copy in case all gets lost again ! example:
iptables-save >/etc/iptables.conf-backup
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.