iptables

नेटवर्क

इस्तेमाल

sudo iptables -L -n -v --line-numbers

चालू पैकेट फ़िल्टर को बदलता है; नियम ऊपर से नीचे जाँचे जाते हैं और पहला मेल जीतता है, इसलिए ACCEPT के बाद जोड़ा गया DROP कभी नहीं चलता, बिना सहेजे नियम रीबूट पर मिट जाते हैं, और पोर्ट 22 खोलने से पहले डिफ़ॉल्ट नीति DROP करने पर दूरस्थ मशीन से आप ही बाहर हो जाते हैं।

आम विकल्प

विकल्पअर्थ
-L -n -v --line-numbersList the rules with counters and the numbers you need for -D.
-A <CHAIN>Append to the end of a chain, where an earlier rule may already have decided.
-I <CHAIN> 1Insert at the top, which is usually what you meant.
-D <CHAIN> <n>Delete rule number n.
-p tcp --dport 22Match protocol and destination port.
-s 10.0.0.0/8Match a source address or range.
-j ACCEPT|DROP|REJECTWhat to do with a matching packet.
-P <CHAIN> DROPSet the default policy, applied when no rule matched.

उदाहरण

sudo iptables -L -n -v --line-numbers

Read the current rules before changing anything.

sudo iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT

Guarantee your own SSH access first.

sudo iptables-save > /etc/iptables/rules.v4

Make the rules survive a reboot.

कनेक्शन न बने तो ये बताते हैं कि बात कहाँ तक पहुँची — नाम हल नहीं हुआ, रास्ता नहीं, या पोर्ट बंद है।

कैसे पढ़ें

  • बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
  • तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
  • विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।

आम सवाल

Q. iptables क्या करता है?

चालू पैकेट फ़िल्टर को बदलता है; नियम ऊपर से नीचे जाँचे जाते हैं और पहला मेल जीतता है, इसलिए ACCEPT के बाद जोड़ा गया DROP कभी नहीं चलता, बिना सहेजे नियम रीबूट पर मिट जाते हैं, और पोर्ट 22 खोलने से पहले डिफ़ॉल्ट नीति DROP करने पर दूरस्थ मशीन से आप ही बाहर हो जाते हैं।

Q. इसे कैसे लिखें?

sudo iptables -L -n -v --line-numbers — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

Q. कितने विकल्प जानने लायक़ हैं?

यहाँ 8 दिए हैं; पूरी सूची man iptables में है। यह कमांड नेटवर्क में आती है।

मिलती-जुलती कमांड

man पेज: man iptables