• IP addresses are NOT logged in this forum so there's no point asking. Please note that this forum is full of homophobes, racists, lunatics, schizophrenics & absolute nut jobs with a smattering of geniuses, Chinese chauvinists, Moderate Muslims and last but not least a couple of "know-it-alls" constantly sprouting their dubious wisdom. If you believe that content generated by unsavory characters might cause you offense PLEASE LEAVE NOW! Sammyboy Admin and Staff are not responsible for your hurt feelings should you choose to read any of the content here.

    The OTHER forum is HERE so please stop asking.

If you subscribed 2 opennets got 2 WANs, running Ubuntu, don't have a Load-Balancing Dual-Wan Router - use this bash script

motormafia

Alfrescian
Loyal
Code:
#!/bin/bash
#
# bal_local        Load-balance internet connection over two local links
#
# Version:        1.0.0 - Fri, Sep 26, 2008
#
# Author:        Niels Horn <[email protected]>
#
# Modified:     Motor Mafia <[email protected]> for Ubuntu 18.04 16.Sept 2018
#
# Set devices:
#
#
DEV1=`route -n | grep '^0.0.0.0'|awk '{print $NF}'|awk 'NR==1'`
DEV2=`route -n | grep '^0.0.0.0'|awk '{print $NF}'|awk 'NR==2'`   


# Get IP addresses of our devices:
ip1=`ifconfig $DEV1 | grep inet |grep -v inet6 | sed -e 's/^[[:space:]]*//' |cut -d' ' -f2`
ip2=`ifconfig $DEV2 | grep inet |grep -v inet6 | sed -e 's/^[[:space:]]*//' |cut -d' ' -f2`

# Get default gateway for our devices:
gw1=`route -n | grep $DEV1 | grep '^0.0.0.0' | awk '{ print $2 }'`
gw2=`route -n | grep $DEV2 | grep '^0.0.0.0' | awk '{ print $2 }'`

echo "$DEV1: IP=$ip1 GW=$gw1"
echo "$DEV2: IP=$ip2 GW=$gw2"

### Definition of routes ###

# Check if tables exists, if not -> create them:
if [ -z "`cat /etc/iproute2/rt_tables | grep '^251'`" ] ; then
    echo "251    rt_dev1" >> /etc/iproute2/rt_tables
fi
if [ -z "`cat /etc/iproute2/rt_tables | grep '^252'`" ] ; then
    echo "252    rt_dev2" >> /etc/iproute2/rt_tables
fi

# Define routing tables:
ip route add default via $gw1 table rt_dev1
ip route add default via $gw2 table rt_dev2

# Create rules:
ip rule add from $ip1 table rt_dev1
ip rule add from $ip2 table rt_dev2

# If we already have a 'nexthop' route, delete it:
if [ ! -z "`ip route show table main | grep 'nexthop'`" ] ; then
    ip route del default scope global
fi

# Balance links based on routes:
ip route add default scope global nexthop via $gw1 dev $DEV1 weight 1 nexthop via $gw2 dev $DEV2 weight 1

# Flush cache table:
ip route flush cache

# All done...


ISPs in Pee Sai these days got offer 2X1Gbps fiber broadband. You got 2 wifi routers. You can plug in another 1000BT NIC card into your PC, so 2 LAN cables into your PC, 1 from each router. Then this script RUN ONCE AS ROOT will keep a connection based balanced internet loading for you. I found it written by some Chow Ang Moh, won't work for Ubuntu. I modified 1st 4 lines to get it working.

Why is it good to use 2 WANs? You got 2 public IP addresses instead of 1. So like I am doing some VPN tests or Servers/Clients tests, that need to be realistically simulated, I can put server on 1 WAN, client on the other WAN, I can be fully sure of my tests because they are really 2 separated connections on the real internet. I can test side by side on same desk and be truly sure it will be same when I moved one side to elsewhere on internet.

For this script I tested on firefox opening 10 tabs of youtube full HD videos at the same time. Both WANs loads about 4MB/s. Roughly balanced. Perfect balance can not be expected. if you 2 WANs are different speed / performance or your want to load them at a certain raio, edit the WEIGHTS at Line #53.

Running the script automatically can be done by calling it at /etc/rc.local
https://askubuntu.com/questions/228304/how-do-i-run-a-script-at-start-up


Otherwise the balance setup will be lost after reboot when route tables is rebuilt by system.

I don't start it automatically because I do tests that prefers without balanced WANs some times.
 

motormafia

Alfrescian
Loyal
If you opened only a single youtube video, you can not expect it to be loading 2 WANs. Youtube won't recognize it was you coming form 2 different IPs.
Interesting thing is bit torrent download, even a single movie, it will share different bits / chunks with different people on both WANs. Some of them will see both your IPs some just 1 of them, and they may not recognize you are a single user, and think you were 2 different users in Singapore instead.
 

motormafia

Alfrescian
Loyal
hello motormafia ,
ubuntu 14 can do 3D cube screen rotation by installing compiz .
can ubuntu 18 do this ?


I suppose if you install the same desktop animations yes
I never played with this
You use UNITY or KDE?
You can do distribution UPGRADE and it will keep your existing desktop animation plug in etc
In any case, you can BACKUP whole disk into Tar and restore if you regret upgrading.
 
Last edited:

motormafia

Alfrescian
Loyal
i using Unity.
no need to go though all these trouble lah.
3D cube is not a neccessity.
It was an impressive thing those days when MS Windows were so stupid and boring, crashes to BLUE SCREENS OF DEATH or core dump 20 times daily.

But the there is something even more robust than Linux, it is BSD. I got 3 virtual machines on BDD running nonstop no restart etc for average 15 years. I only suspend them for moving to other servers or backup.

Just pure reliable machines. Serves you and you don't need to serve them.
 
Top