NoIp Switch

Roberto

Member
May 14, 2015
42
0
38
Hello,
i have a question my server is under DDOS Attack. Is it possible that my DNS from NoIp automatically switch the ip for the DNS to an Other Server Ip That i have . I have 2 vServer if one is under DDOS Attack and the Ts3 is laggy the Ip Switch and The clients Connect to an other ip. Right now i change the ip manually. I Hope u can understand what i want and sorry for my English
 
Last edited:

iAndrewGG

Member
Mar 9, 2016
34
4
40
You can always redirect traffic from one machine to another. I can help you with that and even identify what's happening within your network. Feel free to PM me.
 

dedmen

TeamSpeak Developer
Contributor
Mar 28, 2016
530
583
157
You can let a script run on your good vServer that constantly pings your main Server.. if mainServer doesnt answer send an API request to noIp
 

Roberto

Member
May 14, 2015
42
0
38
I Think so can i Ping the server but how can i do it the a script send the API Request to change the ip ?
 
Last edited:

0x0539

Retired Staff
Contributor
Jan 30, 2016
1,334
1,146
254
Can a script see the packet loss from ts3
There are scripts that notify you or server chat when your server reaches a certain average packet loss.

Answer to your question: Yes.
 

JoKeR

Member
Apr 21, 2016
73
36
53
Im working on a script which checks average packet loss of an instance and if it reaches a threshold it will automatically adjust tsdns settings.

You will need a tsdns server (or cluster for HA) and two teamspeak servers (or more for higher availability).
 

JoKeR

Member
Apr 21, 2016
73
36
53
I try this first i make a Ping.sh thats Pings the server if Offline its Starts the Update.sh and this is noip2 and after 50 Seconds the Updater Stops but it doesnt work i dont know why
https://gist.github.com/Roberto90/9de5db52058531dd3eb2010bfd3c2293

Did you changed it to no-ip?

Code:
# DynDNS.org
#URL="http://%USER%:%PASS%@members.dyndns.org/nic/update?hostname=$DDNSHOST"
# No-IP.com
URL="http://dynupdate.no-ip.com/dns?username=%USER%&password=%PASS%&hostname=$DDNSHOST"
 

Roberto

Member
May 14, 2015
42
0
38
I Found the mistake Dyndns.org was Select and not noip now its work perfect :)
 

JoKeR

Member
Apr 21, 2016
73
36
53
I Found the mistake Dyndns.org was Select and not noip now its work perfect :)
Keep in mind that several anti-ddos solutions drop ICMP during attack so it will update the DynDNS also if its filtered.
 

Roberto

Member
May 14, 2015
42
0
38
Ok :) How i can do it if the packet loss go over 3% then the file update.sh open to Update the Ip ?
 

Roberto

Member
May 14, 2015
42
0
38
I found this in the forum can i use it. I edit it downt know if it work
PHP:
<?php
/**
* Created by PhpStorm.
* User: DrWhat
* Date: 13/02/2015
* Time: 06:21
* @param $seconds
* @param TeamSpeak3_Adapter_ServerQuery $adapter
* @throws TeamSpeak3_Adapter_Exception
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
*/
function onTimeout($seconds, TeamSpeak3_Adapter_ServerQuery $adapter)
{
  if($adapter->getQueryLastTimestamp() < time() - 300) $adapter->request("clientupdate");

  $server = $adapter->getHost()->serverGetByPort(9987);
  $serverInfo = $server->getInfo();
  $totalPacketLoss = (float)$serverInfo["virtualserver_total_packetloss_total"]->toString() * 100;

  if($totalPacketLoss >= 49.9999) $server->message("[COLOR=red][B]The server is being DDOS'D! (Average packet loss {$totalPacketLoss}%)[/COLOR]") && cd /home/ && ./update.sh && sleep 50 && cd /home/ && ./update.sh stop ;
  else if($totalPacketLoss >= 29.9999) $server->message("[COLOR=red][B]The server is experiencing alot of lagg. (Average packet loss {$totalPacketLoss}%)[/COLOR]")&& cd /home/ && ./update.sh && sleep 50 && cd /home/ && ./update.sh stop;
  else if($totalPacketLoss >= 18.9999) $server->message("[COLOR=orange][B]The server is experiencing moderate lagg. (Average packet loss {$totalPacketLoss}%)[/COLOR]")&& cd /home/ && ./update.sh && sleep 50 && cd /home/ && ./update.sh stop;
  else if($totalPacketLoss >= 9.9999) $server->message("[COLOR=orange][B]The server is experiencing minor lagg. (Average packet loss {$totalPacketLoss}%)[/COLOR]")&& cd /home/ && ./update.sh && sleep 50 && cd /home/ && ./update.sh stop;

  $server->clientListReset();
  $server->channelListReset();
}
 

Derp

Retired Staff
Contributor
Apr 30, 2015
933
1,014
217
.... Why go through all the api/bash script hassle when you can simply use srv records?
IH4fZyx.gif

Read: https://en.wikipedia.org/wiki/SRV_record
 

Roberto

Member
May 14, 2015
42
0
38
I read this but i dont understand how it help me with the packet loss bot ?
 

Derp

Retired Staff
Contributor
Apr 30, 2015
933
1,014
217
That's not about packetloss bot. That's about your "DNS Record Switching" issue
 

Derp

Retired Staff
Contributor
Apr 30, 2015
933
1,014
217
Because of dns propagation time for example?
wot? That's exactly why I brought up the SRV Idea. You don't have to wait for dns propagation each time you update your domain's A record through api calls
You only need to wait for your SRV records to propagate once, and you're done
 

Roberto

Member
May 14, 2015
42
0
38
ddos.php
PHP:
#!/usr/bin/php
<?php
date_default_timezone_set('Asia/Riyadh');

include 'config.php';

$tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);

if($tsAdmin->getElement('success', $tsAdmin->connect())) {

    $tsAdmin->login($ts3_user, $ts3_pass);
    $tsAdmin->selectServer($ts3_port);   
    $tsAdmin->setName($bot_nickname);
   
    $whoami = $tsAdmin->getElement('data', $tsAdmin->whoAmI());
    $tsAdmin->clientMove($whoami['client_id'],$bot_move);
function onTimeout($seconds, TeamSpeak3_Adapter_ServerQuery $adapter)
{
  if($adapter->getQueryLastTimestamp() < time() - 300) $adapter->request("clientupdate");

  $server = $adapter->getHost()->serverGetByPort(9987);
  $serverInfo = $server->getInfo();
  $totalPacketLoss = (float)$serverInfo["virtualserver_total_packetloss_total"]->toString() * 100;

  if($totalPacketLoss >= 10.9999) $server->message("[COLOR=red][B]DDOS! (Paketverlust {$totalPacketLoss}%)[/COLOR]");
  else if($totalPacketLoss >= 2.0000) $server->message("[COLOR=red][B]Server IP Wechselt sich Connectet in 1-5 Minuten Neu zu : XXXXXXXX . (Paketverlust {$totalPacketLoss}%)[/COLOR]");
  else if($totalPacketLoss >= 1.5999) $server->message("[COLOR=orange][B]Der Server ist ziel einens DDOS. (Paketverlust {$totalPacketLoss}%)[/COLOR]");
  else if($totalPacketLoss >= 0.9999) $server->message("[COLOR=orange][B]Der Server Laggt. (Paketverlust {$totalPacketLoss}%)[/COLOR]");

  $server->clientListReset();
  $server->channelListReset();
}
php?>

Config.php

PHP:
<?php

$ts3_ip = 'XX.XX.XX.XX'; #IP Adress

$ts3_queryport = 10110; #Queryport

$ts3_port = 9987; #Port

$ts3_user = 'serveradmin'; #Login Query

$ts3_pass = 'XXXXXXXXX'; #Password Query

$bot_nickname = 'Anti DDOS'; #Name Bot

$bot_move = 7; #ID Channel to move

?>
Now i have this Error :
Code:
PHP Parse error:  syntax error, unexpected end of file in /home/ddos/ddos.php on line 33
I try to fix it but it doesnt work
 
Top