Hi all!
Im looking for a script that ONLY allows specified ip-ranges to access the hub, and all others to be disconnected from the hub.
I only want to allow ip-addresses from a number of specified ISP:s to enter my hub.
I have looked around to find some but i have only found scripts that blocks specified ip-ranges.
Thanks in advance.
here.. again
-- easyranger
-- tezlo
ipRanges = {}
denyMsg = " You dont belong here."
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
youll need ranger.dat in this form..
[LAN]
192.168.0.0 - 192.168.0.255
192.168.2.0 - 192.168.2.255
[LOCAL]
127.0.0.1 - 127.0.0.255
...
a question, will this work:
192.168.0.0 - 192.168.5.255
or do i have to write every subnet?
any valid range will work :)
Works great!
Thx for the script!
Should it be like this in the .dat file??
192.168.2.0 - 192.168.2.255
127.0.0.1 - 127.0.0.255
Are there more IP ranges , Ip ranges from fast T1,T2,T3 connections.?
Lets here about it.