Jump to content
  • 0

Interlude Vanganth and Dynamic IP


Question

Posted

Basically i need to setup a L2OFF server with a dynamic ip(this ip changes every time that the modem restarts)

I have a no-ip service,and vangath files ,so i use a noip of 15 letters (it can't containt more than 15 lettters on the dbo.server table)

Example serv67.ddns.net

So When Hauth Loads the server it says External IP "127.0.0.1" ,why not  serv67.ddns.net?

No problem i tried to log in the server but it get stucked on the server seleccion screen.

Both ports are open

 

 

1555.jpg

11 answers to this question

Recommended Posts

  • 0
Posted
14 hours ago, maxicroma said:

The Hauthd have a reload option ,there its some way to call this function every x time ?

 

Probably there is some way but this is much easier:

#!/usr/bin/env python

from urllib import urlopen
from json import loads
from sys import stderr
from time import sleep
from subprocess import Popen
from socket import inet_aton
from threading import Thread

period = 60.0 # seconds
serverId = 1 # server ID
sqlcmd = "C:\\Program Files (x86)\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\SQLCMD.EXE" # put correct path here!
server = "(local)\SQLExpress" # put correct server string here!
database = "lin2db" # database name
hauthd = "C:\\l2\\auth\\hauthd.exe" # put correct path here!

class HauthdThread(Thread):
	def __init__(self):
		Thread.__init__(self)
		self.hauthdProcess = None
		self.doRun = True

	def run(self):
		while self.doRun:
			self.hauthdProcess = Popen([hauthd])
			self.hauthdProcess.wait()
			self.hauthdProcess = None

	def stop(self):
		self.doRun = False
		if self.hauthdProcess != None: self.hauthdProcess.kill()

	def restart(self):
		self.hauthdProcess.kill()

currentIp = None
ipUpdated = False
hauthdThread = None

try:
	while True:
		try:
			newIp = loads(urlopen("https://api.ipify.org?format=json").read())["ip"]
			if newIp != currentIp:
				inet_aton(newIp) # check IP
				print >> stderr, "New IP address:", newIp
				currentIp = newIp
				isUpdated = False
		except KeyboardInterrupt, e:
			raise
		except:
			print >> stderr, "Couldn't get current IP address, will retry later"
			sleep(period)
			continue

		if isUpdated:
			sleep(period)
			continue

		try:
			popen = Popen([sqlcmd, "-S", server, "-d", database, "-Q", "UPDATE dbo.server SET ip='%s' WHERE id=%s" % (currentIp, serverId, )], shell = True)
			popen.wait()
			isUpdated = True
			if hauthdThread == None:
				hauthdThread = HauthdThread()
				hauthdThread.start()
			else:
				hauthdThread.restart()
		except KeyboardInterrupt, e:
			raise
		except:
			print >> stderr, "Couldn't update IP address, will try later"

		sleep(period)
except:
	hauthdThread.stop()
	hauthdThread.join()
	raise

 

  • 0
Posted

LOL ... in the table place the actual ip of your dedicated.
And point the NO-IP to your dedicated, simple ip.

You do not need to put the ip of your DDNS or NO-IP in the settings, settling to point to pro IP enough.

So simple and they break the head with it!

  • 0
Posted (edited)
#!/usr/bin/env python

from urllib import urlopen
from json import loads
from sys import stderr
from time import sleep
from subprocess import Popen
from socket import inet_aton

period = 60.0 # seconds
serverId = 1 # server ID
sqlcmd = "C:\\Program Files (x86)\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\SQLCMD.EXE" # put correct path here!
server = "(local)\SQLExpress" # put correct server string here!
database = "lin2db" # database name

currentIp = None
ipUpdated = False

while True:
	try:
		newIp = loads(urlopen("https://api.ipify.org?format=json").read())["ip"]
		if newIp != currentIp:
			inet_aton(newIp) # check IP
			print >> stderr, "New IP address:", newIp
			currentIp = newIp
			isUpdated = False
	except KeyboardInterrupt, e:
		raise
	except:
		print >> stderr, "Couldn't get current IP address, will retry later"
		sleep(period)
		continue

	if isUpdated:
		sleep(period)
		continue

	try:
		popen = Popen([sqlcmd, "-S", server, "-d", database, "-Q", "UPDATE dbo.server SET ip='%s' WHERE id=%s" % (currentIp, serverId, )], shell = True)
		popen.wait()
		isUpdated = True
	except KeyboardInterrupt, e:
		raise
	except:
		print >> stderr, "Couldn't update IP address, will try later"

	sleep(period)

 

EDIT: You'll also need to restart hauthd somehow...

Edited by eressea
  • 0
Posted

Pase por el mismo problema con advext64 y te comento como funciona. Tu licencia se asocia a una direccion IP o dominio, ahi es cuando te registras en NO-IP, te dan un dominio gratuito y dentro de la pagina de NO-ip le asignas tu IP de ISP. (cualesmiip)... Esta misma ip la pones en el campo IP en dbo.server.  Ej

 

NO-IP:

hostname: l2xx.ddns.net

IP / TARGET: le pones el ip de tu isp  (cualesmiip).

 

En la base de datos, en IP pones tu ip de ISP tambien. 

  • 0
Posted
5 hours ago, eressea said:

#!/usr/bin/env python

from urllib import urlopen
from json import loads
from sys import stderr
from time import sleep
from subprocess import Popen
from socket import inet_aton

period = 60.0 # seconds
serverId = 1 # server ID
sqlcmd = "C:\\Program Files (x86)\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\SQLCMD.EXE" # put correct path here!
server = "(local)\SQLExpress" # put correct server string here!
database = "lin2db" # database name

currentIp = None
ipUpdated = False

while True:
	try:
		newIp = loads(urlopen("https://api.ipify.org?format=json").read())["ip"]
		if newIp != currentIp:
			inet_aton(newIp) # check IP
			print >> stderr, "New IP address:", newIp
			currentIp = newIp
			isUpdated = False
	except KeyboardInterrupt, e:
		raise
	except:
		print >> stderr, "Couldn't get current IP address, will retry later"
		sleep(period)
		continue

	if isUpdated:
		sleep(period)
		continue

	try:
		popen = Popen([sqlcmd, "-S", server, "-d", database, "-Q", "UPDATE dbo.server SET ip='%s' WHERE id=%s" % (currentIp, serverId, )], shell = True)
		popen.wait()
		isUpdated = True
	except KeyboardInterrupt, e:
		raise
	except:
		print >> stderr, "Couldn't update IP address, will try later"

	sleep(period)

 

EDIT: You'll also need to restart hauthd somehow...

The Hauthd have a reload option ,there its some way to call this function every x time ?

  • 0
Posted
13 hours ago, eressea said:

 

Probably there is some way but this is much easier:


#!/usr/bin/env python

from urllib import urlopen
from json import loads
from sys import stderr
from time import sleep
from subprocess import Popen
from socket import inet_aton
from threading import Thread

period = 60.0 # seconds
serverId = 1 # server ID
sqlcmd = "C:\\Program Files (x86)\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\SQLCMD.EXE" # put correct path here!
server = "(local)\SQLExpress" # put correct server string here!
database = "lin2db" # database name
hauthd = "C:\\l2\\auth\\hauthd.exe" # put correct path here!

class HauthdThread(Thread):
	def __init__(self):
		Thread.__init__(self)
		self.hauthdProcess = None
		self.doRun = True

	def run(self):
		while self.doRun:
			self.hauthdProcess = Popen([hauthd])
			self.hauthdProcess.wait()
			self.hauthdProcess = None

	def stop(self):
		self.doRun = False
		if self.hauthdProcess != None: self.hauthdProcess.kill()

	def restart(self):
		self.hauthdProcess.kill()

currentIp = None
ipUpdated = False
hauthdThread = None

try:
	while True:
		try:
			newIp = loads(urlopen("https://api.ipify.org?format=json").read())["ip"]
			if newIp != currentIp:
				inet_aton(newIp) # check IP
				print >> stderr, "New IP address:", newIp
				currentIp = newIp
				isUpdated = False
		except KeyboardInterrupt, e:
			raise
		except:
			print >> stderr, "Couldn't get current IP address, will retry later"
			sleep(period)
			continue

		if isUpdated:
			sleep(period)
			continue

		try:
			popen = Popen([sqlcmd, "-S", server, "-d", database, "-Q", "UPDATE dbo.server SET ip='%s' WHERE id=%s" % (currentIp, serverId, )], shell = True)
			popen.wait()
			isUpdated = True
			if hauthdThread == None:
				hauthdThread = HauthdThread()
				hauthdThread.start()
			else:
				hauthdThread.restart()
		except KeyboardInterrupt, e:
			raise
		except:
			print >> stderr, "Couldn't update IP address, will try later"

		sleep(period)
except:
	hauthdThread.stop()
	hauthdThread.join()
	raise

 

Great how should i run this script ,(seriously ,have no idea )?

  • 0
Posted
4 hours ago, maxicroma said:

Great how should i run this script ,(seriously ,have no idea )?

 

Download and install Python 2.7 https://www.python.org/downloads/release/python-2715/ - use Windows x86-64 MSI installer.

Then just run the script as if it was normal application.

  • 0
Posted
3 hours ago, eressea said:

 

Download and install Python 2.7 https://www.python.org/downloads/release/python-2715/ - use Windows x86-64 MSI installer.

Then just run the script as if it was normal application.

Awesome its working ,thx you dude :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...