Multiupling routing

Alles rund um Netzwerktechnik und Protokolle
greenrover
Posts: 203
Joined: 2004-12-17 19:34

Multiupling routing

Post by greenrover »

Hoi, ich habe nach dem Tutorial: http://wiki.ubuntuusers.de/Multiple_Uplink_Routing
Alias: http://lartc.org/howto/lartc.rpdb.multiple-links.html

Code: Select all

allow-hotplug eth1
#iface eth1 inet dhcp
iface eth1 inet static
    address 192.168.50.240
    netmask 255.255.255.0
    broadcast 192.168.50.255
    gateway 192.168.50.1

iface eth1:0 inet static
    address 192.168.60.240
    netmask 255.255.255.0
    broadcast 192.168.60.255
    gateway 192.168.60.1

iface eth1:1 inet static
    address 192.168.40.1
    netmask 255.255.255.0
    broadcast 192.168.40.255
Es gibt 2 Inet Gateways:
192.168.50.1
192.168.60.1

Und ich probiere mit:

Code: Select all

#!/bin/sh

export IF1="eth1";
export IP1="192.168.50.240";
export P1="192.168.50.1";
export P1_NET="192.168.50.0";

export IF2="eth1:0";
export IP2="192.168.60.240";
export P2="192.168.60.1";
export P2_NET="192.168.60.0";

export IF0="eth1:1";
export P0_NET="192.168.40.0";

# Das habe ich auch schon probiert:
#export IF0="lo";
#export P0_NET="127.0.0.1";

ip route delete default;
ip route delete default;

ip route add $P1_NET dev $IF1 src $IP1 table T1;
ip route add default via $P1 table T1;
ip route add $P2_NET dev $IF2 src $IP2 table T2;
ip route add default via $P2 table T2;

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

ip rule add from $IP1 table T1;
ip rule add from $IP2 table T2;

ip route add $P0_NET dev $IF0 table T1;
ip route add $P2_NET dev $IF2 table T1;
ip route add 127.0.0.0/8 dev lo table T1;
ip route add $P0_NET dev $IF0 table T2;
ip route add $P1_NET dev $IF1 table T2;
ip route add 127.0.0.0/8 dev lo table T2;

ip route add default scope global nexthop via $P1 dev $IF1 weight 1 nexthop via $P2 dev $IF2 weight 1

echo "done.";

ip route flush cache

exit
Was auch anstandslos genommen wird.
Jedoch kann eine 2te Maschiene mit IP 192.168.40.10 und Gateway 192.168.40.1
zwar auf die 40.1 pingen aber kommt nicht ins Internet.

Die Maschine selber (wget ping... gehen alle über eth1)

Code: Select all

 route -n
Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
192.168.50.0    0.0.0.0         255.255.255.255 UH    0      0        0 eth1
192.168.60.0    0.0.0.0         255.255.255.255 UH    0      0        0 eth1
192.168.50.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.60.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.40.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
0.0.0.0         192.168.50.1    0.0.0.0         UG    0      0        0 eth1

cat /etc/iproute2/rt_tables
#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
1       T1
2       T2

cat /proc/sys/net/ipv4/ip_forward
1
ein eth0 gibt es nicht. Ist eine Vmware Box
Anonymous

Re: Multiupling routing

Post by Anonymous »

Hi, ich habe das ganze auch mit den 2 Anleitungen gemacht, jedoch funktioniert es bei mir auch nicht.

Wäre toll wenn jemand wüsste wie man das Problem lösen könnte.
greenrover
Posts: 203
Joined: 2004-12-17 19:34

Re: Multiupling routing

Post by greenrover »

Ich habe jetzt folgendes..

probiere mal ob das bei dir geht. Bei mir läuft das 2te netz nicht immer ganz sauber.

Legende

Code: Select all

Netz1                      = 192.168.50.0
Gateway1                   = 192.168.50.1
IpDerLinuxMaschieneImNetz1 = 192.168.50.250
NicZuNetz1                 = eth0

Netz2                      = 192.168.60.0
Gateway2                   = 192.168.60.1
IpDerLinuxMaschieneImNetz2 = 192.168.60.250
NicZuNetz2                 = eth0 (weil es bei mir eth0:1 ist)
/etc/rc.local

Code: Select all

#!/bin/sh -e
#
# rc.local
#
route del default
route del default                                        
route del default

ip route add default scope global nexthop via 192.168.50.1 nexthop via 192.168.60.1

nohup /usr/sbin/gwping &
exit 0
/usr/sbin/gwping (musst du erstellen und mit root:root 0755 belegen)

Code: Select all

#!/bin/bash
#Copyright Angsuman Chakraborty, Taragana. Permission is granted for personal, non-commercial use.
#The script may not be re-distributed in any form without written permission from Angsuman Chakraborty ( angsuman@taragana.com ).
#The script may be modified for personal use.
#THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR ACCEPTS NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.

# Conventionally 0 indicates success in this script.

# Time between checks in seconds
SLEEPTIME=10

#IP Address or domain name to ping. The script relies on the domain being 
#pingable and always available
TESTIP=www.switch.ch

#Ping timeout in seconds
TIMEOUT=2

# External interfaces
EXTIF1=eth0
EXTIF2=eth0

#IP address of external interfaces. This is not the gateway address.
IP1=192.168.50.250
IP2=192.168.60.250

#Gateway IP addresses. This is the first (hop) gateway, could be your router IP 
#address if it has been configured as the gateway
GW1=192.168.50.1
GW2=192.168.60.1

# Relative weights of routes. Keep this to a low integer value. I am using 4
# for TATA connection because it is 4 times faster
W1=1
W2=1

# Broadband providers name; use your own names here.
NAME1=BSNL
NAME2=TATA

#No of repeats of success or failure before changing status of connection
SUCCESSREPEATCOUNT=4
FAILUREREPEATCOUNT=1

# Do not change anything below this line

# Last link status indicates the macro status of the link we determined. This is down initially to force routing change upfront. Don't change these values.
LLS1=1
LLS2=1

# Last ping status. Don't change these values.
LPS1=1
LPS2=1

# Current ping status. Don't change these values.
CPS1=1
CPS2=1

# Change link status indicates that the link needs to be changed. Don't change these values.
CLS1=1
CLS2=1

# Count of repeated up status or down status. Don't change these values.
COUNT1=0
COUNT2=0

while : ; do
        ping -W $TIMEOUT -I $IP1 -c 1 $TESTIP > /dev/null  2>&1
        RETVAL=$?

        if [ $RETVAL -ne 0 ]; then
		echo $NAME1 Down
		CPS1=1
        else
		CPS1=0
        fi

	if [ $LPS1 -ne $CPS1 ]; then
		echo Ping status changed for $NAME1 from $LPS1 to $CPS1
		COUNT1=1
	else
		if [ $LPS1 -ne $LLS1 ]; then
			COUNT1=`expr $COUNT1 + 1`
		fi
	fi

        if [[ $COUNT1 -ge $SUCCESSREPEATCOUNT || ($LLS1 -eq 0 && $COUNT1 -ge $FAILUREREPEATCOUNT) ]]; then
		echo Uptime status will be changed for $NAME1 from $LLS1
		CLS1=0
		COUNT1=0
		if [ $LLS1 -eq 1 ]; then
			LLS1=0
		else
			LLS1=1
		fi
	else 
		CLS1=1
        fi

	LPS1=$CPS1

	ping -W $TIMEOUT -I $IP2 -c 1 $TESTIP > /dev/null  2>&1
       	RETVAL=$?

	if [ $RETVAL -ne 0 ]; then
		echo $NAME2 Down
                CPS2=1
        else
                CPS2=0
        fi

        if [ $LPS2 -ne $CPS2 ]; then
		echo Ping status changed for $NAME2 from $LPS2 to $CPS2
                COUNT2=1
        else
                if [ $LPS2 -ne $LLS2 ]; then
                        COUNT2=`expr $COUNT2 + 1`
                fi
        fi

        if [[ $COUNT2 -ge $SUCCESSREPEATCOUNT || ($LLS2 -eq 0 && $COUNT2 -ge $FAILUREREPEATCOUNT) ]]; then
		echo Uptime status will be changed for $NAME2 from $LLS2
		CLS2=0
		COUNT2=0
                if [ $LLS2 -eq 1 ]; then
                        LLS2=0
                else
                        LLS2=1
                fi
	else
		CLS2=1
        fi

	LPS2=$CPS2

	if [[ $CLS1 -eq 0 || $CLS2 -eq 0 ]]; then
		if [[ $LLS1 -eq 1 && $LLS2 -eq 0 ]]; then 
			echo Switching to $NAME2
                        ip route replace default scope global via $GW2 dev $EXTIF2
		elif [[ $LLS1 -eq 0 && $LLS2 -eq 1 ]]; then
			echo Switching to $NAME1
                        ip route replace default scope global via $GW1 dev $EXTIF1
		elif [[ $LLS1 -eq 0 && $LLS2 -eq 0 ]]; then
			echo Restoring default load balancing
                        ip route replace default scope global nexthop via $GW1 dev $EXTIF1 weight $W1 nexthop via $GW2 dev $EXTIF2 weight $W2
		fi
	fi
        sleep $SLEEPTIME
done
Last edited by greenrover on 2009-04-02 14:15, edited 1 time in total.
Anonymous

Re: Multiupling routing

Post by Anonymous »

Bei mir bekomme ich über beide Netzwerke auf dem Router-Computer Internet.
Jedoch wenn ein Client sich anhängt bekommt er eine IP 192.168.10.x und als Standartgateway 192.168.10.1, aber kein Internet.

__Meine Einstellungen:__

Netzwerk1 (InetGW):
IP: 10.221.0.2
Gateway: 10.221.0.1
dev: eth0

Netzwerk2 (InetGW):
IP: 10.219.0.2
Gateway: 10.219.0.1
dev: eth1

Netzwerk3 (LAN):
IP: 192.168.10.1
dev: eth2

Mein Zugriffsscript:

Code: Select all

#!/bin/sh
echo "1" > /proc/sys/net/ipv4/ip_forward

export IF1="eth0";
export IP1="10.221.0.2";
export P1="10.221.0.1";
export P1_NET="10.221.0/16";

export IF2="eth1";
export IP2="10.219.0.2";
export P2="10.219.0.1";
export P2_NET="10.219.0/16";

export IF0="eth2";
export IP0="192.10.0.1";
export P0_NET="192.10.0/16";

ip route delete default;
ip route delete default;

ip route add $P1_NET dev $IF1 src $IP1 table T1;
ip route add default via $P1 table T1;
ip route add $P2_NET dev $IF2 src $IP2 table T2;
ip route add default via $P2 table T2;

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

ip rule add from $IP1 table T1;
ip rule add from $IP2 table T2;

ip route add $P0_NET dev $IF0 table T1;
ip route add $P2_NET dev $IF2 table T1;
ip route add 127.0.0.0/8 dev lo table T1;
ip route add $P0_NET dev $IF0 table T2;
ip route add $P1_NET dev $IF1 table T2;
ip route add 127.0.0.0/8 dev lo table T2;

ip route add default scope global nexthop via $P1 dev $IF1 weight 1 nexthop via $P2 dev $IF2 weight 1

echo "done.";
exit
greenrover
Posts: 203
Joined: 2004-12-17 19:34

Re: Multiupling routing

Post by greenrover »

Versuche mal das aus zu führen und gib feedback:

Code: Select all

T1 und T2 stehen in:
/etc/iproute2/rt_tables
fals nicht:
echo "1 T1" >> /etc/iproute2/rt_tables
echo "2 T2" >> /etc/iproute2/rt_tables

export IF1="eth0";
export IP1="10.221.0.2";
export P1="10.221.0.1";
export P1_NET="10.221.0/16";

export IF2="eth1";
export IP2="10.219.0.2";
export P2="10.219.0.1";
export P2_NET="10.219.0/16";


route del default
route del default                                       
route del default

ip route add default scope global nexthop via $P1 nexthop via $P2
Anonymous

Re: Multiupling routing

Post by Anonymous »

Hi, hab das Script mal probiert beim ausführen kommt:

Code: Select all

SIOCDELRP: No such process
SIOCDELRP: No such process
Im Lan bekomme ich ne IP aber wieder kein Internet.
greenrover
Posts: 203
Joined: 2004-12-17 19:34

Re: Multiupling routing

Post by greenrover »

das
SIOCDELRP: No such process

kommt von route delete default.

hmm und was sagt

iptables -L
ip route

wenn da auch alles auf default ist kann ich dann auch nicht mehr weiter helfen, bin in der Routing Geschichte leider selber noch ziemlich am üben.
Anonymous

Re: Multiupling routing

Post by Anonymous »

Gibt es eig. einen Log womit man sehen kann was mit dem Netzwerk los ist? Habe auch denn Kernelpatch installiert jedoch auch ohne Erfolg.


ip route:

Code: Select all

10.221.0.0/16 dev eth0  proto kernel  scope link  src 10.221.0.2
192.11.0.0/16 dev eth2  proto kernel  scope link  src 192.11.0.1
169.254.0.0/16 dev eth0  scope link  metric 1000
192.10.0.0/16 dev eth2  proto kernel  scope link  src 192.10.0.1
10.219.0.0/16 dev eth1  proto kernel  scope link  src 10.219.0.2
default via 192.10.0.2 dev eth2  metric 100
default via 10.219.0.1 dev eth1  metric 100
default via 10.221.0.1 dev eth0  metric 100
iptables -L

Code: Select all

Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
LOG        all  --  127.0.0.0/8          anywhere            LOG level warning
DROP       all  --  127.0.0.0/8          anywhere
ACCEPT     all  --  anywhere             255.255.255.255
ACCEPT     all  --  192.11.0.0/16        anywhere
ACCEPT    !tcp  --  anywhere             224.0.0.0/4
LOG        all  --  192.11.0.0/16        anywhere            LOG level warning
DROP       all  --  192.11.0.0/16        anywhere
LOG        all  --  192.11.0.0/16        anywhere            LOG level warning
DROP       all  --  192.11.0.0/16        anywhere
LOG        all  --  192.11.0.0/16        anywhere            LOG level warning
DROP       all  --  192.11.0.0/16        anywhere
ACCEPT     all  --  anywhere             255.255.255.255
ACCEPT     all  --  anywhere             255.255.255.255
ACCEPT     all  --  anywhere             255.255.255.255
ACCEPT     all  --  anywhere             10.221.0.2
ACCEPT     all  --  anywhere             10.221.255.255
ACCEPT     all  --  anywhere             10.219.0.2
ACCEPT     all  --  anywhere             10.219.255.255
ACCEPT     all  --  anywhere             Else
ACCEPT     all  --  anywhere             192.10.255.255
DROP       all  --  anywhere             224.0.0.1
LOG        all  --  anywhere             anywhere            LOG level warning
DROP       all  --  anywhere             anywhere

Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  192.11.0.0/16        anywhere
ACCEPT     all  --  192.11.0.0/16        anywhere
ACCEPT     all  --  192.11.0.0/16        anywhere
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
LOG        all  --  anywhere             192.11.0.0/16       LOG level warning
DROP       all  --  anywhere             192.11.0.0/16
LOG        all  --  anywhere             192.11.0.0/16       LOG level warning
DROP       all  --  anywhere             192.11.0.0/16
[/size]
greenrover
Posts: 203
Joined: 2004-12-17 19:34

Re: Multiupling routing

Post by greenrover »

Mach mal nen reboot damit die routing regeln leer sind (ich weis leider nicht wie es anders geht)
und die IPTABLES auch auf default sind und dann probiere es nochmal und mal alle Fehlerquellen aus zu schließen.