hi everyone
my rule ıs /sbin/iptables -A INPUT -p tcp --dport 111 -j DROP
and ı want to forbıd tıll the port no 800.and ı donw want to wirte ıt down one by one.
so ı want to make a loop that wıll change port adress(whıch ıs 111) add port num

so far ı trıed slıcıng and counter=0 and counter +1 ın the loop
ıt gave me error
algorıtm ı treıd ıs

for x in range(800):
for x in iptables:
          counter +=x[39:4]
       print counter

and ıt gıves me error normally

so how can ı make ıt happen

out put should be


/sbin/iptables -A INPUT -p tcp --dport 111 -j DROP
/sbin/iptables -A INPUT -p tcp --dport 112 -j DROP
/sbin/iptables -A INPUT -p tcp --dport 113 -j DROP
/sbin/iptables -A INPUT -p tcp --dport 114 -j DROP
and so on

thanks for your hep

ı want to make a loop that wıll change port adress

Here's a simple loop generating your example output strings between 111 and 115. I'm sure you can figure out how to extend up to 800.

>>> for x in xrange(111, 115):
...     print '/sbin/iptables -A INPUT -p tcp --dport %s -j DROP' % x
...     
/sbin/iptables -A INPUT -p tcp --dport 111 -j DROP
/sbin/iptables -A INPUT -p tcp --dport 112 -j DROP
/sbin/iptables -A INPUT -p tcp --dport 113 -j DROP
/sbin/iptables -A INPUT -p tcp --dport 114 -j DROP
>>>

HTH

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.