Create a Load Balancing Router Using Ubuntu Jaunty (9.04)


With its increasingly complex network, we sometimes have some connection to the Internet simultaneously. My own home has two (2) connection to the Internet at once, ie, ADSL Speedy and RT/RW-net. To have a second connection to the Internet can be used maximally, we need to do load balancing with 2 connections in parallel in order to access the Internet can be done.

Specifications/network topology that I use at home are as follows:

ADSL connection through eth2 IP address 192.168.1.222 with a gateway to the ADSL router IP 192.168.1.1.

Connections RT / RW-net via eth0 IP address 10.0.148.48 via WiFi / Wireless with gateway 10.0.148.254.

LAN connection via eth1 IP address 192.168.0.222.

Router installation steps are as follows.

Enter the CD / DVD Ubuntu installer, choose "install a command line system"

Set the root password so that we can run the command "su" command through


$ sudo passwd root

Moving into Super User mode


$ su --

Edit the information on the interface /etc/network/interfaces, can be done using gedit
 

$ gedit /etc/network/interfaces

Important information on the need to edit the file interfaces is

auto eth0 iface eth0 inet static address 10.0.148.48 netmask 255.255.255.0 auto eth1 iface eth1 inet static address 192.168.0.222 netmask 255.255.255.0
auto eth2 iface eth2 inet static address 192.168.1.222 netmask 255.255.255.0

Install some applications that support your life easier, such as
 

$ apt-get install openssh-server $ /Etc/init.d/ssh restart

Next we need to set up routing and load balancing which is simply as follows


/sbin/ip link set lo up /sbin/ip link set eth0 up / sbin/ip link set eth1 up /sbin/ip link set eth2 up

/sbin/ip route flush table adsl /sbin/ip route flush table rtrwnet /sbin/ip route flush table internet

/sbin/ip addr add 127.0.0.1/8 brd 127.0.0.255 dev lo

/sbin/ip addr add 192.168.1.222/24 brd 192.168.1.255 dev eth2 # /Sbin/ip addr add 10.0.148.48/24 brd 10.0.148.255 dev eth0 /sbin/ip addr add 192.168.0.222/24 brd 192.168.0.255 dev eth1

/sbin/ip rule add prio 10 table main /sbin/ip rule add prio 20 table adsl /sbin/ip rule add prio 30 table rtrwnet /sbin/ip rule add prio 40 table internet /sbin/ip route del default table main /sbin/ip route del default table adsl /sbin/ip route del default table rtrwnet /sbin/ip route del default table internet

/sbin/ip rule add prio 20 from 192.168.1.0/24 table adsl /sbin/ip route add default via 192.168.1.1 dev eth2 src 192.168.1.222 table static Proto adsl /sbin/ip route append prohibit default table adsl Proto static metric 1 /sbin/ip rule add prio 30 table rtrwnet from 10.0.148.0/24 /sbin/ip route add default via 10.0.148.254 dev eth0 src 10.0.148.48 Proto static table rtrwnet /sbin/ip route append prohibit default table rtrwnet Proto static metric 5

Set up load balancing gateways
/sbin/ip rule add prio 40 table internet /sbin/ip route add default Proto static table internet \ nexthop via 192.168.1.1 dev eth2 weight 1 \ nexthop via 10.0.148.254 dev eth0 weight 1

The above configuration requires three (3) additional routing table, namely, adsl, internet rtrwnet and our entry in the file /etc/iproute2/rt_tables, its content is approximately as follows,


120 adsl
121 rtrwnet
123 internet

Next we need to set up NAT/proxy that can do NAT at the same time to two (2) the interface is different, ie, 192.168.1.222 and 10.0.148.48. The command is as follows,


/bin/echo 1> /proc/sys/net/ipv4/ip_forward

/sbin/iptables-F
/sbin/iptables-P INPUT DROP
/sbin/iptables-A INPUT-i eth1-j ACCEPT
/sbin/iptables-A INPUT-i eth0-p tcp-s 0/0-DPort 25-j ACCEPT
/sbin/iptables-A INPUT-i eth2-p tcp-s 0/0-DPort 25-j ACCEPT
/sbin/iptables-A INPUT-m state-state established, RELATED-j ACCEPT
/sbin/iptables-A INPUT-p tcp-i eth0-j reject-reject-with tcp-reset
/sbin/iptables-A INPUT-p tcp-i eth2-j reject-reject-with tcp-reset
/sbin/iptables-A INPUT-p UDP-i eth0-j reject-reject-with ICMP port-unreachable
/sbin/iptables-A INPUT-p UDP-i eth2-j reject-reject-with ICMP port-unreachable

/sbin/iptables-t nat-A POSTROUTING-o eth2-j SNAT-to 192.168.1.222
/sbin/iptables-t nat-A POSTROUTING-o eth0-j SNAT-to 10.0.148.48


So Confused...!!!

Happy Testing.

Article By : Ono W. Purbo, Thanks Brother...!!!

5 comments:

  1. I truly love your site.. Pleasant colors & theme.
    Did you build this amazing site yourself? Please
    reply back as I'm wanting to create my own blog and want to find out where you got this from or just what the theme is called. Appreciate it!

    Feel free to visit my site :: pleasant holiday vacation

    ReplyDelete
  2. There's definately a great deal to know about this subject. I really like all the points you have made.

    Check out my blog post :: import Car insurance

    ReplyDelete
  3. It's very trouble-free
    to find out any matter on net as compared to textbooks, as I found this article at this website.

    Also visit my homepage :: 0 interest ()

    ReplyDelete
  4. There's certainly a great deal to learn about this issue. I like all the points you have made.

    my web site - crystal chandelier ()

    ReplyDelete

Please Comment...!!