routes from ippool.conf

Victor M. Blood freebsd at masm.elcom.ru
Sat Nov 10 18:23:21 PST 2007


Hi, All.

I need to adding static routes from some tables in /etc/ippool.conf,
may be it's require for any one and may be adding to rc scripts "for
use"... sorry for my programming for /bin/sh .

in /etc/rc.conf I added two lines
ippool_static_routes="<table name> <table name> ... "
ippool_static_routes_gw="<addr for route>"

May be need to add more what one GW? or addign in one line, as
<tablename> <GW> <tablename> <GW> ... ?, sorry, I don't know how to do
it. :(

The file ippool.conf should be formatted as follows:

...
#Net num 1
table role = ipf type = tree name = table1 {
      #may be comment
      1.2.3.4/5;
      ...
};
...
scripts read /etc/ippool.conf (can be changed in /etc/rc.d/routing)
and search for ONLY TABLE NAME! may be need to search full line to
prevent errors?

patch to /etc/rc.d/routing:

--- /root/backup/routing        2007-11-11 04:33:08.000000000 +0300
+++ ./routing   2007-11-11 05:21:18.000000000 +0300
@@ -48,6 +48,35 @@
                        route add ${route_args}
                done
        fi
+       # Setup static routes from ippool.conf 
+       ippool_file="/etc/ippool.conf"
+
+       if [ \( -n "${ippool_static_routes}" \) -a \( -n "${ippool_static_routes_gw}" \) -a \( -f "${ippool_file}" \) ]; then
+#              tn_prefix="table role = ipf type = tree name = "
+#              tn_postfix=" }"
+               ippool_cnt=`cat ${ippool_file}`
+               process=0
+               collected=""
+
+               for i in ${ippool_static_routes}; do
+                       for k in ${ippool_cnt}; do
+                               if [ $process -eq 1 ]; then
+                                       if [ "${k}" = "};" ]; then
+                                               process=0
+                                               break
+                                       elif [ "${k}" = "{" ]; then
+                                       else 
+                                               val=$(echo $k | grep -Go '[0-9]*.[0-9]*.[0-9]*.[0-9]*/[0-9]*')
+                                               if [ -n "${val}" ]; then 
+                                                       route add ${val} ${ippool_static_routes_gw}
+                                               fi
+                                       fi
+                               elif [ "${i}" = "${k}" ]; then 
+                                       process=1
+                               fi
+                       done
+               done
+       fi
        # Now ATM static routes
        #
        if [ -n "${natm_static_routes}" ]; then
@@ -56,6 +85,7 @@
                        atmconfig natm add ${route_args}
                done
        fi
+       
 }
 
 options_start()

-- 
With all regards, Victor M. Blood.     mailto: freebsd at masm.elcom.ru
FTN: 2:5024/1.95 at Fidonet.org, ICQ#3567656






More information about the freebsd-current mailing list