Автоматичен nat-ip ъпдейт за хора с динамично IP

Мнения, препоръки, коментари, въпроси отностно Fewona IRC Мрежата, Уебсайта или Форума.
Всичко свързано с IRC (eggdrops, tcl scripts, bots, irc clients, mirc, kvirc, x-chat, ircd, irc services и тн.)

Автоматичен nat-ip ъпдейт за хора с динамично IP

Postby Rix » January 18th, 2013, 6:59 pm

Ето как да направим да се ъпдейтва автоматично nat-ip, така че да работи dcc (/ctcp bota chat) правилно, когато се смени IP.

cd eggdrop

Създайте файл natip.txt и сложете в него:
Code: Select all
set nat-ip 127.0.0.1


Създайте файл nat.tcl и сложете в него:

Code: Select all
# Script by Rix
# ver 0.02
# Updates nat-ip and restarts the bot
# use eggdrop.conf in order to work

#code begins

set resvar 0
timer 10 checknatip
proc checknatip { } {
global resvar
set myipp [lindex [exec host shells.no-ip.info] 3]
set mynatname "natip.txt"
set qfile [open $mynatname r]
set mycip [lindex [read $qfile] 2]
if { $mycip != $myipp } {
set newnat "set nat-ip " ; append newnat $myipp;
set wfile [open $mynatname w]
puts $wfile $newnat
close $wfile
set resvar 1
}
timer 10 checknatip
close $qfile
if { $resvar } { restart }
}


Отворете eggdrop.conf и коментирайте реда set nat-ip:

Code: Select all
#set nat-ip "91.192.239.125"; #/host shells.no-ip.info and copy paste set nat-ip ""


След това на нов ред пейст това:
Code: Select all
source natip.txt


И в края на конфигурационния файл пейст това:
Code: Select all
source nat.tcl


Забележка: Сменете хоста shells.no-ip.info с вашия домейн.

============

СТАРИЯ НАЧИН (на английски и не се препоръчва):

First make sure your eggdrop configuration file is eggdrop.conf
Then create a file named natip.txt and put this in it:
Code: Select all
set nat-ip 127.0.0.1


Then create file named nat.tcl and put this in it:

Code: Select all
# Script by Rix
# ver 0.01
# Updates nat-ip and restarts the bot
# use eggdrop.conf in order to work

# settings:
set eggdropdir "/home/user/eggdrop/"
set eggdropcommand "./eggdrop"
set pidfilename "pid.eggdrop"

# code:
set myipp [lindex [exec host shells.no-ip.info] 3]
set mynatname $eggdropdir
append mynatname "natip.txt"
set qfile [open $mynatname r]
set mycip [lindex [read $qfile] 2]
if { $mycip != $myipp } {
set newnat "set nat-ip " ; append newnat $myipp;
set wfile [open $mynatname w]
puts $wfile $newnat
close $wfile
set mypidname $eggdropdir
append mypidname $pidfilename
set mypida [exec cat $mypidname ]
exec kill $mypida
set startegg $eggdropdir
append startegg $eggdropcommand
exec $startegg
}
close $qfile


EDIT EGGDROP DIRECTORY AND PID FILE NAME IN THE ABOVE CODE

Then open eggdrop.conf and comment the set nat-ip line:

Code: Select all
#set nat-ip "91.192.239.125"; #/host shells.no-ip.info and copy paste set nat-ip ""


Then in a new line paste this
Code: Select all
source natip.txt


Restart the bot. Put a crontab entry like this (crontab -e):
Code: Select all
*/10 * * * * tclsh8.5 /home/rix/eggdrop/nat.tcl >/dev/null 2>&1

Change the directory to your /home/name/eggdrop/nat.tcl

NOTE:
The bot may not start if the directories in eggdrop.conf are not properly set /home/user/eggdrop
Please use crontab for the eggdrop so that it can be started automatically once killed by the script
Качествен VPS хостинг от http://vpsbg.eu
User avatar
Rix
Tech Mentor
 
Posts: 65
Joined: June 16th, 2012, 1:58 pm
Location: Sofia, Bulgaria

Return to IRC Форум

Who is online

Users browsing this forum: No registered users and 1 guest