rutare

Gabos Denes gabosdenes la gmail.com
Dum Oct 14 14:22:34 BST 2007


Salutare la toti utilizatorii Ubuntu

Am o problema legata de rutare. Am 2 provideri de internet si vreau sa 
fac sa mearga netul pe amindoua deodata. Am urmat pasii de pe 
http://lartc.org/howto/lartc.rpdb.multiple-links.html ... si totul merge 
ok inafara de faptul ca din interiorul retelei nu pot accesa serverul pe 
ip-urile externe (nici cu firewallul dat jos :p). Reteaua interna este 
mascaradata pe ambele ip-uri externe.

Aici este scriptul care face rutarea:
P1_NET P2_NET reteaua cu providerii
IP1 IP2 ip-urile externe
P1_GW P2_GW gatewayul de la provideri


#!/bin/sh
ip route del default

#LAN
P0_NET=192.168.0.0
IF0=eth0
IP0=192.168.0.1

#UPC
P1_NET=x.x.134.0
IF1=eth2
IP1=X.X.134.218
P1_GW=X.X.134.1

#RDS
P2_NET=X.X.123.192
IF2=eth1
IP2=X.X.123.220
P2_GW=X.X.123.193

ip route add $P1_NET dev $IF1 src $IP1 table UPC
ip route add default via $P1_GW table UPC
ip route add $P2_NET dev $IF2 src $IP2 table RDS
ip route add default via $P2_GW table RDS

ip route add $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF2 src $IP2

#Next, you set up the routing rules. These actually choose what routing
#table to route with. You want to make sure that you route out a given
#interface if you already have the corresponding source address:
ip rule add from $IP1 table UPC
ip rule add from $IP2 table RDS


#'If $P0_NET is the local network and $IF0 is its interface,
#the following additional entries are desirable:
ip route add $P0_NET     dev $IF0 src $IP0 table UPC
ip route add $P2_NET     dev $IF2 table UPC
ip route add 127.0.0.0/8 dev lo   table UPC
ip route add $P0_NET     dev $IF0 src $IP0 table RDS
ip route add $P1_NET     dev $IF1 table RDS
ip route add 127.0.0.0/8 dev lo   table RDS

ip route del default
ip route add default scope global nexthop via $P1_GW dev eth2 weight 1 
nexthop via $P2_GW dev eth1 weight 1
ip route flush cache




Mai multe informații despre lista de discuții ubuntu-ro