Allow only specified ip-range
 

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

Allow only specified ip-range

Started by Vaderv, 27 October, 2003, 14:47:18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Vaderv

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.

tezlo

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
...

Vaderv

a question, will this work:

192.168.0.0 - 192.168.5.255

or do i have to write every subnet?

tezlo

any valid range will work :)

Vaderv

Works great!

Thx for the script!

blackwings

#5
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


[NL]Portal

Are there more IP ranges , Ip ranges from fast T1,T2,T3 connections.?

Lets here about it.
Owner of the MoviePalace Europe

Master : [NL]Portal
Adress : moviepalace.sytes.net:411
Website : None

Min share : 1 GB
Min slots : 1
Max slots : 30

See ya
Thanx for a reaction Back

SMF spam blocked by CleanTalk