Originally Posted by qwefgh
...in this homework...
You will be aware that the statute of limitations for this site says that any answer to a homework question can be misleading, funny and/or educational but must not be something the the OP can submit for marks (paraphrasing a lot)?
I tried to write the codes in applications --> accessories --> Terminal
I don't know why you think it should be, unless you are thinking of some other operating system? Thinking of another operating system is often unhelpful.
Does that rule out using an 'easy' (well, graphical) front-end to iptables? There is no end of them, and some education can be gleaned by spelunking (looking through) the code that they produce?
What about 'apropos iptables'? Does that give you any clues as to things you might want to look through with 'man'? (Extra clue: start on 'save' and 'restore' before 'man iptables' itself; they should take you a bit further on your quest for knowledge, particularly the bit about instantiating and removing rule sets.)
My suspicion is that when you have looked through these, you will have a better idea about putting in place and removing rule sets, but little idea about appropriate rules. If that is true and if you can show some specific example of the confusion you are now in, ask again.