• No results found

Load Balancing - Single Multipath Route HOWTO

N/A
N/A
Protected

Academic year: 2021

Share "Load Balancing - Single Multipath Route HOWTO"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

Load Balancing - Single Multipath Route

HOWTO

Shakthi Kannan, shaks_wants_no_spam_at_shakthimaan_dot_com

January 5, 2007

(2)

Abstract

(3)

1 Network Diagram

-| R o u t e r -| -| 1 9 2 . 1 6 8 . 2 0 1 . 1 | ( et h 0 ) -| S w i t c h -| -| | 1 9 2 . 1 6 8 . 2 0 1 . 1 1 | | 1 9 2 . 1 6 8 . 2 0 1 . 1 3 ( e t h 1 ) - - - ( e t h 2 ) | PC2 | -1 9 2 . -1 6 8 . 0 . -1 | ( e t h 0 ) | | | 1 9 2 . 1 6 8 . 0 . 4 | ( e t h 0 ) -| PC1 |

-1.1 Install the kernel sources

Redhat 9.0 is used for testing, and the kernel sources are not installed by default. Redhat

9.0 uses the 2.4.20-8 kernel. You can get the:

kernel - source - 2 . 4 . 2 0 - 8 . i 3 86 . rpm

from the 2nd installation CD and install it using:

rpm - ivh kernel - source - 2 . 4 . 2 0 - 8 . i 3 8 6 . rpm

The kernel sources will get installed in /usr/src/linux-2.4.20-8.

1.2 Build iptables

The iptables version present in Redhat 9.0 does not have the –to-source option for SNAT.

Hence, you need to download iptables v1.2.11. Extract the same and run the following

in its sources directory:

m a k e K E R N E L _ D I R =/ usr / src / linux - 2 . 4 . 2 0 - 8

m a k e i n s t a l l K E R N E L _ D I R =/ usr / src / linux - 2 . 4 . 2 0 - 8

(4)

1.3 Run patch-o-matic

patch-o-matic-ng does not work with 2.4.20 Linux kernels. Hence, you need to download

patch-o-matic-20031219.tar.bz2. Extract the same and do:

K E R N E L _ D I R =/ usr / src / linux - 2 . 4 . 2 0 - 8 \

I P T A B L E S _ D I R =/ p a t h / to / i p t a b l e s / s o u r c e s ./ r u n m e b a s e

It will prompt for applying various patches. Say N to all, except for the random.patch.

1.4 Recompile the kernel

The 2.4.20-8custom kernel will be built when you recompile the kernel.

m a k e c l e a n m a k e dep m a k e b z I m a g e m a k e m o d u l e s m a k e m o d u l e s _ i n s t a l l cp ar c h / i 3 86 / b o o t / b z I m a g e / b o o t / vmlinuz - 2 . 4 . 2 0 - 8 c u s t o m m k i n i t r d / b o o t / initrd - 2 . 4 . 2 0 - 8 c u s t o m . img 2. 4 . 2 0 - 8 c u s t o m

1.5 Update grub

Update the grub boot-loader, /boot/grub/menu.lst file:

t i t l e R e d h a t GNU / L i n u x ( 2 . 4 . 2 0 - 8 c u s t o m ) r o o t ( hd0 ,0)

k e r n e l / vmlinuz - 2 . 4 . 2 0 - 8 c u s t o m ro r o o t = L A B E L =/ i n i t r d / initrd - 2 . 4 . 2 0 - 8 c u s t o m . img

Reboot into the new kernel.

(5)

1.7 Load the driver modules

Check if the network driver modules are loaded, else load them using modprobe or

insmod. Load the ip_tables.o and ipt_random.o drivers.

1.8 iptables script

Create the loadbalance.sh script.

(6)

$ I P T A B L E S - t m a n g l e - A E T H 2 - p tcp - j LOG - - log - p r e f i x \ " M A N G L E _ T C P _ E T H 2 " $ I P T A B L E S - t m a n g l e - A E T H 2 - p i c mp - j LOG - - log - p r e f i x \ " M A N G L E _ I C M P _ E T H 2 " $ I P T A B L E S - t m a n g l e - A E T H 2 - j M A RK - - set - m a r k 2 $ I P T A B L E S - t nat - N S P O O F _ E T H 1 $ I P T A B L E S - t nat - F S P O O F _ E T H 1

$ I P T A B L E S - t nat - A S P O O F _ E T H 1 - j LOG - - log - p r e f i x \ " S P O O F _ E T H 1 "

$ I P T A B L E S - t nat - A S P O O F _ E T H 1 - j S N A T - - to - s o u r c e \ 1 9 2 . 1 6 8 . 2 0 1 . 1 1

$ I P T A B L E S - t nat - N S P O O F _ E T H 2 $ I P T A B L E S - t nat - F S P O O F _ E T H 2

$ I P T A B L E S - t nat - A S P O O F _ E T H 2 - j LOG - - log - p r e f i x \ " S P O O F _ E T H 2 " $ I P T A B L E S - t nat - A S P O O F _ E T H 2 - j S N A T - - to - s o u r c e \ 1 9 2 . 1 6 8 . 2 0 1 . 1 3 e c h o " S e t t i n g s o me l o c a l n e t w o r k r u l e s . . . " $ I P T A B L E S - A I N P U T - p i c m p - s 1 9 2 . 1 6 8 . 0 . 0 / 2 4 - d 1 9 2 . 1 6 8 . 0 . 1 \ - j A C C E P T e c h o " S e t t i n g M a n g l e r u l e s for e t h 1 . . ." $ I P T A B L E S - t m a n g l e - A O U T P U T - o ! e t h 0 - m r a n d o m - - a v e r a g e 50 \ - j ET H 1 $ I P T A B L E S - t m a n g l e - A P R E R O U T I N G - i e t h 0 - m r a n d o m - - a v e r a g e 50 \ - j ET H 1

ip ro add t a b l e 10 d e f a u l t via 1 9 2 . 1 6 8 . 2 0 1 . 1 dev e th 1 ip ru add f w m a r k 1 t a b l e 10 ip ro fl ca e c h o " S e t t i n g M a n g l e r u l e s for e t h 2 . . ." $ I P T A B L E S - t m a n g l e - A O U T P U T - o ! e t h 0 - m r a n d o m - - a v e r a g e 50 \ - j ET H 2 $ I P T A B L E S - t m a n g l e - A P R E R O U T I N G - i e t h 0 - m r a n d o m - - a v e r a g e 50 \ - j ET H 2

(7)

ip ro fl ca

e c h o " S e t t i n g up s p o o f i n g r u l e s . . . "

$ I P T A B L E S - t nat - A P O S T R O U T I N G - o e t h 1 - j S P O O F _ E T H 1 $ I P T A B L E S - t nat - A P O S T R O U T I N G - o e t h 2 - j S P O O F _ E T H 2

e c h o " A d d i n g d e f a u l t r o u t e . . . "

ip ro add d e f a u l t n e x t h o p via 1 9 2 . 1 6 8 . 2 0 1 . 1 dev e t h1 w e i g h t 1 \ n e x t h o p via 1 9 2 . 1 6 8 . 2 0 1 . 1 dev e th 2 w e i g h t 1 e c h o " D i s a b l i n g R e v e r s e P a t h F i l t e r i n g . . . " e c h o 0 > / p ro c / sys / net / i pv 4 / c o n f / e t h 1 / r p _ f i l t e r e c h o 0 > / p ro c / sys / net / i pv 4 / c o n f / e t h 2 / r p _ f i l t e r e c h o " E n a b l i n g I Pv 4 P a c k e t f o r w a r d i n g .. . " e c h o "1" > / p r o c / sys / net / i p v 4 / i p _ f o r w a r d

Run it.

sh l o a d b a l a n c e . sh

1.9 Testing

Add a default route for PC2 from PC1:

r o u t e add d e f a u l t gw 1 9 2 . 1 6 8 . 0 . 1 et h 0

Ping the gateway IP address from PC1:

p i n g 1 9 2 . 1 6 8 . 2 0 1 . 1

You should see packets going out from eth1 and eth2.

2 Bibliography

Hisham . Hisham Mardam Bey. July 26, 2004. Load Balancing across Multiple Links.

http://www.linux.com.lb/wiki/index.pl?node=HOW-TOs.

Chris . Chris Lowth. April 1, 2004. The Hidden Treasures of iptables. http://www.linuxjournal.com/

article/7180.

References

Related documents

Themes of time perception, social influence of decision-making, climate risks, and soil management are emphasized to discover how past personal experiences and

For example, a study in England found that children of incarcerated parents were more than twice as likely as children in the general population to experience significant

Secondly, presence of private schools in villages with access to better public infrastructure tends to give rise to higher average pass rates while presence of local private

outside of family care in an institution or on the streets, de facto child headed and grandparent headed families, where parents are away for extended periods

Thanks to the cam adjustment the rear closing wheels tail can be finely aligned with furrow guaranteeing a perfect seed covering in every soil conditions... COMFORT

With the introduction of large-scale online education, the need for integration between LMS systems and student management systems increases. The analyses revealed a general lack

The provisions to be considered are the product (service) defi nitions, specifi cation of the production practices and agricultural inputs to be used, payment systems,