Linux routing help needed

the code in a script file gave this:

test: 2: [[: not found
false

Your code or mine?

Yours had a tiny syntax error - there has to be a space between "/32" and ]], at least on my system.

if [[ "192.124.234.221/32" =~ "/32" ]] ; then echo true >> /etc/ppp/routes.log; else echo false >> /etc/ppp/routes.log; fi;

Our shells are definitely behaving differently though. run sh --version:

GNU bash, version 3.1.17(1)-release (i686-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
 
Gentoo. That said, ASS_SAZiN` is running Ubuntu as well and everything works for him.

Do you have bash installed?

run /bin/bash --version

also do this:
ls -l /bin/sh

and tell me what it says.
 
GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

and the second one:
lrwxrwxrwx 1 root root 4 2006-11-03 00:16 /bin/sh -> dash
 
ok, in the script file. This works, outputting true

if [ "/32" = "/32" ]; then echo true >> /etc/ppp/routes.log; else echo false >> /etc/ppp/routes.log; fi;

but this outputs false:

if [ "1/32" =~ "/32" ]; then echo true >> /etc/ppp/routes.log; else echo false >> /etc/ppp/routes.log; fi;
 
GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

and the second one:
lrwxrwxrwx 1 root root 4 2006-11-03 00:16 /bin/sh -> dash

How dash became your default shell I do not know. Do this:

sudo rm /bin/sh
sudo ln -s /bin/bash /bin/sh
 
OMG!!

i did that, and it works!

finally!!

Thank you so much eremos.

btw, how did my default shell change??
 
I'm not sure. There was apparently a proposal to make it the Ubuntu default, perhaps they adopted that for Eft.

There's probably a way to tweak the script to make it work on dash, which just doesn't seem to like the =~ operator. I will have a look around.

I'm glad it finally works, lol. *phew*
 
lol. you can say *phew* again.

it took forever and in the end it was as simple as the wrong shell :/

Thanks for your help dude
 
To get an updated route list, and assuming you have netcat installed:

echo -e "terminal length 0\nshow ip bgp\nexit" | nc route-server.is.co.za 23 | grep ^* | awk '{print $2}' > routes.txt

- twiga

Twiga - how on earth did you find that service?
Is this something special that only IS do?
Pretty cool source of info.
 
Credit for the discovery of route-server.is.co.za goes to TheRoDent. Not sure where he found out about it.

It's quite a cool and usefull service, as you noted. The router isn't just limited to providing BGP output, you can also use it to do pings and traceroutes from IS's network.

- twiga
 
Ok I have had this running for some time now and its pretty cool but I need some extra stuff to make it useful. I still use the old way of using the file with ips for local routing and not the bgp server however thats not a big problem.

Anyways, what I have done so far is making 2 extra routing tables, so that I can route outgoing packets for incoming connections on the same interface they came in.

So lets say a local connection came in from my saix uncapped account, I change routing on those packets to go out on the same saix account, otherwise it just wont work as you can imagine someone connecting to you on your saix account and all of a sudden you reply via the IS account and thus the remote pc who made the connection to you dont understand what the hell is going on.

So here is my ip-up script:
Code:
noir:~# cat /etc/ppp/ip-up
#!/bin/sh
#
# $Id: ip-up,v 1.2 1998/02/10 21:25:34 phil Exp $
#
# This script is run by the pppd after the link is established.
# It uses run-parts to run scripts in /etc/ppp/ip-up.d, so to add routes,
# set IP address, run the mailq etc. you should create script(s) there.
#
# Be aware that other packages may include /etc/ppp/ip-up.d scripts (named
# after that package), so choose local script names with that in mind.
#
# This script is called with the following arguments:
#    Arg  Name                          Example
#    $1   Interface name                ppp0
#    $2   The tty                       ttyS1
#    $3   The link speed                38400
#    $4   Local IP number               12.34.56.78
#    $5   Peer  IP number               12.34.56.99
#    $6   Optional ``ipparam'' value    foo

# The  environment is cleared before executing this script
# so the path must be reset
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
export PATH
# These variables are for the use of the scripts run by run-parts
PPP_IFACE="$1"
PPP_TTY="$2"
PPP_SPEED="$3"
PPP_LOCAL="$4"
PPP_REMOTE="$5"
PPP_IPPARAM="$6"
export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM


# as an additional convenience, $PPP_TTYNAME is set to the tty name,
# stripped of /dev/ (if present) for easier matching.
PPP_TTYNAME=`/usr/bin/basename "$2"`
export PPP_TTYNAME

# Main Script starts here

#if($1 == "ppp1") { run-parts /etc/ppp/ip-up.d }
#if($1 == "ppp0")
#{
#    /sbin/route add -net 196.25.66.50 netmask 255.255.255.255 dev ppp0
#}

case $4 in
196.*)
#route local
for i in `cat /etc/ppp/localroutes.dat`; do
echo ``route add -net `echo $i | sed s/\,/\ netmask\ /g` gw $4 `` ;
``route add -net `echo $i | sed s/\,/\ netmask\ /g` gw $4 `` ;
done
``ip route add 0.0.0.0 dev $1 src $4 table T1``
``ip route add default via $5 table T1``
``ip rule add from $4 table T1``
#run-part /etc/ppp/ip-up.d
;;

41.*)
#international
#route add default gw $1
``ip route add 0.0.0.0 dev $1 src $4 table T2``
``ip route add default via $5 table T2``
``ip rule add from $4 table T2``
run-part /etc/ppp/ip-up.d
;;
esac

# last line

Now something that still iritate me is this:
Code:
Tracing route to www.yahoo-ht2.akadns.net [209.73.186.238]
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  noir.restricted.co.za [10.0.0.2]
  2    11 ms    11 ms    11 ms  dsl-241-128-01.telkomadsl.co.za [41.241.128.1]
  3     *        *        *     Request timed out.
  4     *        *        *     Request timed out.
  5     *        *        *     Request timed out.
  6     *        *        *     Request timed out.
  7   526 ms   529 ms   532 ms  213.228.221.202
  8   543 ms   529 ms   523 ms  so-4-1-0.pat2.dce.yahoo.com [216.115.101.146]
  9   543 ms   534 ms   528 ms  ge-2-1-0-p141.msr1.re1.yahoo.com [216.115.108.19]
 10   528 ms   496 ms   533 ms  ge-1-30.bas-a2.re3.yahoo.com [66.196.112.37]
 11   520 ms   489 ms   499 ms  f1.www.vip.re3.yahoo.com [209.73.186.238]

Trace complete.

How can I add a "ip route 2" rule so that when I do a traceroute, all the packets go out on the same interface. For the above example, I want all the icmp packets in that case go out on the saix interface so that I can do a proper trace route.

Last note, just for those who are curious, my file for the extra tables to make the actual ip-up script work:
Code:
noir:~# cat /etc/iproute2/rt_tables
#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
1       inr.ruhep
101     T1
102     T2

Thank you for any help.
 
Top
Sign up to the MyBroadband newsletter
X