FlexHub Forum

Flexhub install for linux Step by Step, as promist - HC team 2015 - ;)

Flexhub LINUX install Manuel, the promised step by step manuel,
the easy hub with a easy system..  ;D

Try to help oshter users who`s not familair with linux.
Most of the vps server are using linux to get manual acces and configure a lot software.
Most people are windows cp 1252 based and 'hanging" for years to microsoft.  :'(

Ok every one has the choise but for servers is windows bad because:

- Instable system on ling termine
- Inbuild Connection cap limit from ms 70 connections
- Spyware and unkwown bot software
- Problems with virus scanners etc etc..
- Don`t forget the nsa they inspect you desktop and mail etc etc..
- I have to say goodbye to windows years ago and it helps me

So make linux debian 7 or slackware 14.0 the default system to run a flexhub
(or ptokax, verli watever).   
If you know and understand linux better, you won`t turn to windows ever!!.. ;)

login to vps and do first:

apt-get update
apt-get install build-essential

reboot vps

For linux get terminal an use mc
(midnight commander apt-get install mc)
activate the commander to press mc

On the left site from  mc search for you flexhub download folder
oO the right site from the commander press right and below shell connection
enter machine name root@youvpsip enter en press you passwd

Then go with mc on the left site to you donwloaded flechub folder
Then go to the right site to you vps folder /usr/src/test and copy (f5)
The donwloaded flexhubfile thz into the folder /usr/src/test/
Then quit the commander (mc) and in terminal get connection from the home pc to vps
Activate terminal and do ssh root@vps ip and you passwd,  then step to the test dir
cd /usr/src/test/

Then make sure that the hub is in the directory
if you look at the fileist do ls
ls means list

root@virtual-connect:~# cd /usr/src/test
root@virtual-connect:/usr/src/test# do ls to see the flexhub file: ls
FlexHub_0.2_1469_linux.tgz  <-- so the hub is in there ;)

Unpack the hub:
With the tab butten you can manage the words 
tar xvf F then press the tab butten an voilla ;)

tar xvf FlexHub_0.2_1469_linux.tgz
ok lets go on..
when the hub is unpacked do ls
FlexHub  FlexHub_0.2_1469_linux.tgz


the dir Flexhub is added so get in that dir
cd Flexhub (enter)
chmod +x ./lua ./FlexHub.lua
activate the hub
./lua ./FlexHub.lua --nogui --nick=Ger --pass=xxxx --port=4111 <--Example !

then you see
root@virtual-connect:/usr/src/test/FlexHub# [Mon Jun  1 15:36:57 2015] Paths set to:
   _APPPATH: /usr/src/test/FlexHub/
   _LOGDIR: ./logs/
   _CONFIGDIR : ./settings/
   _IMPORTDIR: ./import/
   _BACKUPDIR: ./backups/

Do ctrl c (at the same time to quit terminal from vps
Now connect to the new Flexhub ..

Open you Dc++ client an fill in you name and passwd an vps ip adress port 4111 (xx.xx.xx.xx:4111)

[21:40] *** Connecting to xx.x.xx.xxx:4111
[21:40] *** Connected
[21:40] <FlexBot> FlexHub Beta 0.2 svn: 1469 - Made by Daywalker, FlipFlop and en_dator.
[21:40] <FlexBot> Currently there are 1 users online and the hub uptime is: 0 day(s) 00:03:20

And there you are as master into the hub welcome ;)

First thing to do is reduse de reconnect time to 5 sec
!set reconnect_timeout 2

First press !set then you see all the settings from the hub
[21:43] <FlexBot> *** !set
[21:43] <FlexBot>

   Available categories:

Then most importend settings:

to activate the hub
!set chatonly false

Then try to tune thinks up ..

!set nmdc_lockwait 0 (hub goes faster)
!set hub_name  -= Virtual Test Hub =-  (or wathever;)
!set reconnect_timeout 2 ( for big hub set to 10 sec)
!set minshare 0
!set minshare_download 1Gb
!set maxusers 2500
!set login_timeout 120      (better for slow conn users)
!set nonrespond_timeout 120    (better for slow conn users)
!set disconnect_timeout 120  (better for slow conn users)
!set ssl_handshaketimeout 120 (better for slow conn users)
!set hub_address (you no-ip adress) (must needed for regging hublist)
!set rd_main yousecondubadres:411
!addports 411 (if you want more ports)

Remember that you only can run ports below 1024 as root user

For hosting note that by 24/7 you cache and connections is filling you memory and open
files from the vps.

To fix that make a little work on the system
Open files for debian are default set to 1024 and its to low for big users and connections
And thats not only for verlihub but for every soft on the pc, every Hubsoft use connections
Login in to the shell as a root user (ssh root@ipvps passwd)

apt-get install nano

then do export EDITOR=nano 
go to you root dir cd /root
open the nano editor, then past this rule into the editor

echo 1 > /proc/sys/vm/drop_caches

then do ctrl o and give it the name memory.sh
chmod 755 memory.sh     ( set permissions)

crontab -e

scroll down,
Past the rule clean cache every 30 min into crontab

*/30 * * * * /root/memory.sh

ctrl o (at the same time) to save the crontab info and hit enter
message >  crontab: installing new crontab ;)
ctrl x to leave the crontab

You can see the memory with the free command and the proces with top command

Setting the system limits from 1024 to higher valeu:

ulimit -n 1024 is the default settings from every system

Add the rule in /etc/security/limits.conf
nano /etc/security/limits.conf

root             soft    nofile          777777
root             hard    nofile          777777

ctro enter (save file) and ctrl x

Add the second rule

nano /etc/pam.d/login

session required /lib/security/pam_limits.so

Reboot vps >>

root@virtual-connect:~# ulimit -n
Then start the Flex hub again >
cd /usr/src/test/FlexHub/

./lua ./FlexHub.lua --nogui --nick=Ger --pass=xxxx --port=4111
The hub is running now, press ctrl c to get out the file.

The hub is running again with mem cache and ulimit fix ;) ..

Don`t forget the iptables have describe it else on the forum..

For ddos protection install iptables and add the rules

iptables -I INPUT -p tcp --dport 411 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 411 -i eth0 -m state --state NEW -m recent --update --seconds 5 --hitcount 60 -j DROP  you can play with this settings 5 sec / not more the 60 connections at 5 sec

to block an attacker: hint you can make a blacklist for attackers and use it to protect.
iptables -A INPUT -s xxx.xxx.xxx.xxx -j DROP
iptables-save > /etc/iptables.up.rules

if you wanna restore
iptables-restore < /etc/iptables.up.rules
reload iptables > service reload iptables or /etc/init.d/iptables reload.

you can check the tables with iptables -L

The first line will Watch the IP connecting to your eth0 interface.
The second line will Check if the connection is new within the last 5 seconds and if the packet flow is higher than ten and if so it will drop the connection.

How to identify the IP that is attacking you
Use the command
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

if you wanna see possible inruders with other ips look at
nano /var/log/daemon.log or /var/log/auth.log

Jun  1 17:39:21 virtual-connect sshd[1942]: Server listening on port 22.
Jun  1 17:39:21 virtual-connect sshd[1942]: Server listening on :: port 22.
Jun  1 17:40:00 virtual-connect sshd[2086]: Accepted password for root from trusted ip port x ssh2

Try to get ssd core 4 vps, they are not expensive and have a quick fast connection,
Ssd works faster for io system speed and also hub speed.
The place in the center of the eu works best, Luxemborg, France or Italie.

Note, when you reboot you vps, you must start the hub again, don`t forget!.

Hope it helps for novice users with linux because the system is more
stable then windows, its worth to use Linux debian or slackware

for a long stable connection,
                                    -=  Happy - Hubbing  =- ;)    -HC team 2015-