IP Filter
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

IP Filter

Started by phalon, 11 November, 2003, 19:43:36

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

phalon

Hi, first of all I would like to thank you for a great board.

I have some problems making my own bot!
As I have been trying to make an ip filter bot.

I need to be able to allow ip addresses (range)
For instance I would like to allow

192.168.101.100 to 192.168.101.199 and
192.168.202.70 to 192.168.205.200

But all other ip would be blocked.

I have been searching for a script like this in this board
But to no avail, if there is one however I apologize

Kind regards
phalon






SaintSinner

#1
QuoteOriginally posted by phalon
Hi, first of all I would like to thank you for a great board.

I have some problems making my own bot!
As I have been trying to make an ip filter bot.

I need to be able to allow ip addresses (range)
For instance I would like to allow

192.168.101.100 to 192.168.101.199 and
192.168.202.70 to 192.168.205.200

But all other ip would be blocked.

I have been searching for a script like this in this board
But to no avail, if there is one however I apologize

Kind regards
phalon


these ip ranges are for your internal home/office network, if you only allow these..the 192.x.x.x ip ranges and block everyone else,...then you just blocked the whole internet.
are you perhaps on a school lan?
   


NightLitch

Here you go look at this...

This should be all you need...  :))

LOGGER by C h i l l a

Click Here...

/NightLitch
//NL

phalon

Thank you for your reply SaintSinner. To answer your question then 192.xxx.xxx.xxx is a "dummy" ip, what i mean is that I could put some ip?s like for instance ip ranges of one isp but not another.

Thank you NightLitch I will take alook at LOGGER

Kind regards
phalon

tezlo

there is also a smaller and faster alternative ;)

phalon

Thank you tezlo, this is what i was looking for

phalon

I want to allow these ip number ranges but exclude all others.

[Og Vodafone]
217.9.128.0 - 217.9.143.255
213.176.128.0 - 213.176.159.255
213.213.128.0 - 213.213.159.255
194.144.0.0 - 194.144.255.255
193.4.0.0 - 193.4.255.255

The problem, i am facing is


There is a user with the ip 194.144.12.128 he can not enter until i change the range 194.144.0.0 - 194.144.255.255 to 194.144.12.0 - 194.144.12.255
it seems that the script only reads the last line of the ip.

Am I missing something or just a little dumb :-), can you please help me?


this is the script

---start---

ipRanges = {}

denyMsg = " You do not belong here! (sendu p?st ? spassi@simnet.is ef ?? ert ?samm?la)"

function compute(ip)
   local s, e, a, b, c, d = strfind(ip, "^(%d+).(%d+).(%d+).(%d+)$")
   if s then return a*16777216 + b*65536 + c*256 + d end return 0
end

function checkrange(table, ip)
   return foreachi(table, function(id, tmp)
      if (%ip >= tmp[1]) and (%ip <= tmp[2]) then return tmp end
   end)
end

function load(name, data)
   ipRanges[name] = ipRanges[name] or {}
   gsub(data, "(%S+) %- (%S+)", function(s, e)
      s, e = compute(s), compute(e)
      tinsert(ipRanges[%name], { s, e })
   end)
end

function Main()
   local f = openfile("ranger.dat", "r") assert(f, "ranger.dat")
   local file = read(f, "*a") closefile(f)   gsub(file, "%[(%S+)%]([%c%d%s%-%.]+)", load)
end

function NewUserConnected(user)
   local ip, isp = compute(user.sIP)
   for name, range in ipRanges do
      if checkrange(range, ip) then return end
   end user:SendData(denyMsg) user:Disconnect()
end

---end---

And this is the content of ranger.dat

---start---

[LOCALHOST]
127.0.0.1 - 127.0.0.255

[LAN]
192.168.0.0 - 192.168.0.255
192.168.1.0 - 192.168.1.255
192.168.2.0 - 192.168.2.255


[Hringi?an ehf]
213.190.96.0 - 213.190.127.255


[?slensk erf?agreining hf]
212.126.224.0 - 212.126.255.255

[Og Vodafone]
217.9.128.0 - 217.9.143.255
213.176.128.0 - 213.176.159.255
213.213.128.0 - 213.213.159.255
194.144.0.0 - 194.144.255.255
193.4.0.0 - 193.4.255.255

[Landss?mi ?slands hf]
157.157.0.0 - 157.157.255.255
192.147.34.0 - 192.147.34.255
194.105.224.0 - 194.105.255.255
212.30.192.0 - 212.30.223.255
213.167.128.0 - 213.167.159.255

[L?naNet]
213.220.64.0 - 213.220.120.0
62.145.128.0 - 62.145.159.255
81.15.0.0 - 81.15.127.255

[Fj?ltengi]
213.220.120.0 - 213.220.127.255

[Margmi?lun Internet ehf]
217.151.160.0 - 217.151.191.255



[Ranns?kna- og H?sk?lanet ?slands]
130.208.0.0 - 130.208.255.255

[Skyggnir hf]
217.28.176.0 - 217.28.180.255

[Sk?rr hf]
82.148.64.0 - 82.148.75.0
82.148.75.0 - 82.148.95.255

[Snerpa ehf]
193.109.16.0 - 193.109.31.255

---end---

SMF spam blocked by CleanTalk