writing an iptable rule
I am a student at ITT tech and am having trouble writing a iptable rule which will allow all incoming connections from 129.71.298.0/255.255.255.0 for services ssh, http, https, dns, dhcp.
|
What have you tried? Which part isn't working?
|
Too new for my own good
I'm afraid I haven't figured what to write or how to even begin to write the command. I'm sure it's not difficult but, for me right now it's Hugh. Any help would be great and I would be very grateful.
|
...and have you read this, which is the best documentation for all things iptables. Now, that might be more information than you wanted, but, on the assumption that after this problem there will be/would have been another problem, it will be worthwhile.
OK, to break it down a bit (I'm not going to answer your question directly), how would you, for example, do anything with http-related packets. What identifying feature would you use that allows you to separate those packets from the rest? Could you do something similar with the other protocols (clue: yes, unclue, ssh might be more difficult, but that might be beyond the scope, depending)? Could you do something that only works on packets from a particular source address range (again, clue: yes). Could you combine the above (clue: yes). Quote:
In any case, if you can write a sequence of rules that does pretty much what you want, it shouldn't be too difficult to come up with something similar (not exactly the same...but with some similarity), but compacted into a single rule. It is difficult to know on what exact point you are stuck until you actually submit something that you have written, with a comment like 'and I don't know how to add this bit...' or '...but this seems to fail in that respect...'. |
Please make a backup copy before editing Iptables Rule
Kindly check the following configuration ( For Centos and RedHat) # iptables -L ( To check) # iptables -F ( To flush ) # iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT # iptables -A INPUT -s 129.71.298.0/24 -p tcp --destination-port 80 -j ACCEPT ( For http ) # iptables -A INPUT -s 129.71.298.0/24 -p tcp --destination-port 22 -j ACCEPT ( For ssh ) # iptables -A INPUT -s 129.71.298.0/24 -p tcp --destination-port 443 -j ACCEPT ( for https ) # iptables -A INPUT -s 129.71.298.0/24 -p tcp --destination-port 53 -j ACCEPT ( For dns tcp ) # iptables -A INPUT -s 129.71.298.0/24 -p udp --destination-port 53 -j ACCEPT ( For dns udp ) # iptables -A INPUT -s 129.71.298.0/24 -p tcp --destination-port 67 -j ACCEPT ( For DHCP ) # iptables -A INPUT -s 129.71.298.0/24 -p tcp --destination-port 68 -j ACCEPT ( For DHCP ) # iptables -P INPUT DROP ( Block other Incoming traffic,if you want ) Now check iptables by # iptables -L If you want to save these iptables rules then, # iptables-save > /etc/sysconfig/iptables # iptables-restore < /etc/sysconfig/iptables Hope this will help you little bit :) |
All times are GMT -5. The time now is 08:04 PM. |