loki wrote:
Took me some month :)

It's working.
Here's the setup:

ifconfig.address.lan0:
ONBOOT=yes
IFACE=lan0
SERVICE=ipv4-static
IP=10.0.66.66
PREFIX=16

ifconfig.address.wan0
ONBOOT=yes
IFACE=wan0
SERVICE=ipv4-static
IP=121.211.212.123
PREFIX=28
GATEWAY=121.211.212.113

ifconfig.statroute.lan0
ONBOOT=yes
IFACE=lan0
SERVICE=ipv4-static-route
IP=192.168.0.0
PREFIX=16
STATIC_GATEWAY=10.0.0.254

ifconfig.statroute.wan0
ONBOOT=yes
IFACE=wan0
SERVICE=ipv4-static-route
TYPE=host
IP=36.121.79.0
STATIC_GATEWAY=wan0
PREFIX=25

Very good.  Please try using the attached files and see if it still
works.  If so, I'll commit them to the current boot scripts.

  -- Bruce



ip a:
2: wan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UNKNOWN qlen 1000
     link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
     inet 121.211.212.123/28 scope global wan0
        valid_lft forever preferred_lft forever
3: lan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP qlen 1000
     link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
     inet 10.0.66.66/16 scope global lan0
        valid_lft forever preferred_lft forever

ip r:
default via 121.211.212.113 dev wan0
10.0.0.0/16 dev lan0  proto kernel  scope link  src 10.0.66.66
36.121.79.0/25 dev wan0  scope link
192.168.0.0/16 via 10.0.0.254 dev lan0
121.211.212.112/28 dev wan0  proto kernel  scope link  src
121.211.212.123


Thx...

On Sat, 2013-06-08 at 19:34 -0500, Bruce Dubbs wrote:

loki wrote:
On Fri, 2013-06-07 at 15:53 -0500, Bruce Dubbs wrote:


I think I see what you mean.  What happens if we add a new variable to
the ifconfig script:

STATIC_GATEWAY=10.0.5.5

and change GATEWAY to STATIC_GATEWAY in the ipv4-static-route script?



Sounds good. Will try that as soon as I finish the new server, that is
as soon as I solve the binutils problem.



We could also add a small check to ensure both GATEWAY and
STATIC_GATEWAY are not both defined.  That would cause problems
when using the ipv4-static-route script.


Lost you there. Do you mean if someone puts GATEWAY and STATIC_GATEWAY
vars in the same file?

Yes.  If we use STATIC_GATEWAY in ipv4-static-route, we want to skip the
GATEWAY code in ifup.

    -- Bruce








#!/bin/sh
########################################################################
# Begin /lib/services/ipv4-static-route
#
# Description : IPV4 Static Route Script
#
# Authors     : Kevin P. Fleming - kpflem...@linuxfromscratch.org
#               DJ Lucas - d...@linuxfromscratch.org
# Update      : Bruce Dubbs - bdu...@linuxfromscratch.org
#
# Version     : LFS 7.0
#
########################################################################

. /lib/lsb/init-functions
. ${IFCONFIG}

case "${TYPE}" in
   ("" | "network")
      need_ip=1
      need_gateway=1
   ;;

   ("default")
      need_gateway=1
      args="${args} default"
      desc="default"
   ;;

   ("host")
      need_ip=1
   ;;

   ("unreachable")
      need_ip=1
      args="${args} unreachable"
      desc="unreachable "
   ;;

   (*)
      log_failure_msg "Unknown route type (${TYPE}) in ${IFCONFIG}, cannot 
continue."
      exit 1
   ;;
esac

if [ -n ${GATEWAY} ]; then
   MSG="The GATEWAY variable cannot be set in ${IFCONFIG} for static routes.\n"
   log_failure_msg "$MSG Use STATIC_GATEWAY only, cannot continue"
   exit 1
fi

if [ -n "${need_ip}" ]; then
   if [ -z "${IP}" ]; then
      log_failure_msg "IP variable missing from ${IFCONFIG}, cannot continue."
      exit 1
   fi

   if [ -z "${PREFIX}" ]; then
      log_failure_msg "PREFIX variable missing from ${IFCONFIG}, cannot 
continue." 
      exit 1
   fi
   
   args="${args} ${IP}/${PREFIX}"
   desc="${desc}${IP}/${PREFIX}"
fi

if [ -n "${need_gateway}" ]; then
   if [ -z "${STATIC_GATEWAY}" ]; then
      log_failure_msg "STATIC_GATEWAY variable missing from ${IFCONFIG}, cannot 
continue."
      exit 1
   fi
   args="${args} via ${STATIC_GATEWAY}"
fi

if [ -n "${SOURCE}" ]; then
        args="${args} src ${SOURCE}"
fi

case "${2}" in
   up)
      log_info_msg "Adding '${desc}' route to the ${1} interface..."
      ip route add ${args} dev ${1}
      evaluate_retval
   ;;
   
   down)
      log_info_msg "Removing '${desc}' route from the ${1} interface..."
      ip route del ${args} dev ${1}
      evaluate_retval
   ;;
   
   *)
      echo "Usage: ${0} [interface] {up|down}"
      exit 1
   ;;
esac

# End /lib/services/ipv4-static-route
ifup(8)                                                   ifup(8)

NAME
       ifup - bring a network interface up
       ifdown - take a network interface down

SYNOPSIS
       ifup  IFACE
       ifup -h|--help
       ifup -V|--version

       ifdown IFACE
       ifdown -h|--help
       ifdown -V|--version

DESCRIPTION
       The  ifup  and  ifdown  commands  may be used to configure 
       (or, respectively, deconfigure) a network interface based 
       on interface  definitions in the file 
       /etc/sysconfig/ifconfig.IFACE.

OPTIONS
       A summary of options is included below.

       -h, --help
              Show summary of options.

       -V, --version
              Show version information.

EXAMPLES
       ifup eth0
              Bring up the interface defined in the file 
              /etc/sysconfig/ifconfig.eth0

                ONBOOT=no
                IFACE=eth0
                SERVICE=ipv4-static
                IP=192.168.1.22
                GATEWAY=192.168.1.1
                PREFIX=24
                BROADCAST=192.168.1.255

       ifdown eth0:2
              Bring down the interface defined in the file
              /etc/sysconfig/ifconfig.eth0:2

                ONBOOT=no
                IFACE=eth0:2
                SERVICE=dhcpcd
         
                DHCP_START="--waitip"
                DHCP_STOP="-k"
         
                # Set PRINTIP="yes" to have the script print the DHCP IP address
                PRINTIP="yes"
         
                # Set PRINTALL="yes" to print the DHCP assigned values for
                # IP, SM, DG, and 1st NS. 
                PRINTALL="no"

       ifup br0
              Bring up the interface defined in the file 
              /etc/sysconfig/ifconfig.br0
                    
                ONBOOT=yes
                IFACE=br0
                SERVICE="bridge ipv4-static"
                IP=192.168.1.22
                GATEWAY=192.168.1.1
                PREFIX=24
                BROADCAST=192.168.1.255
                STP=no                      # Spanning tree protocol, default no
                INTERFACE_COMPONENTS=eth0   # Add to IFACE
                IP_FORWARD=true

NOTES
       The program does not configure network interfaces direct-
       ly.  It runs scripts defined by the SERVICE variable in 
       the network configuration file.

       The configuration files must have the following environ-
       ment variables set:

       IFACE   - The interface to configure, e.g. eth0.  It must 
                 be available in /sys/class/net.

       SERVICE - The service script to run to bring up the inter-
                 face.  Standard services are ipv4-static and 
                 ipv4-static-route.  Other services such as dhcp
                 or bridge may be installed.  This value may
                 be a list of services when the interface is a
                 compound device such as a bridge.

       ONBOOT  - If set to 'yes', the specified interface is 
                 configured by the netowrk boot script.

       GATEWAY - The default IP address to use for routing if
                 the destination IP address is not in a static 
                 route or on a local network, e.g., 192.168.1.1.  
                 For secondary IP addresses on an interface, this 
                 parameter should not be specified.  If teh service
                 is ipv4-static-route, this parameter must NOT
                 be set.

       STATIC_GATEWAY - The default IP address to use for routing
                 when setting a static routing address.  

       INTERFACE_COMPONENTS - A list of component interfaces
                 only needed for a compound device such as a bridge.  
                 This list is normally a single value, e.g. eth0, 
                 for use with a virtual host such as kvm.

       Other paramters that are service specific include:

       ipv4-static

         IP        - The IP address of the interface, 
                     e.g. 192.168.1.2.

         PREFIX    - The number of bits that specify the network
                     number of the interface.  The default, if not
                     specified, is 24.
       
         BROADCAST - The brodcast address for this interface, 
                     e.g 192.168.1.255.  If not specified, 
                     the broadcast address will be calculated
                     from the IP and PREFIX.

       ipv4-static-route

         TYPE    -  The type of route, typically 'default', 
                    'network', 'or host'.

         IP      -  The IP address for a network or host, if the
                    TYPE is not 'default'.

         PREFIX  -  The prefix for the associated IP address.

         STATIC_GATEWAY - The IP address for a network route.

         SOURCE  -  The source IP address to prefer when sending 
                    to the destinations covered by the specified
                    route. (optional)

       dhcp/dhclient

         DHCP_START - Optional parameters to pass to the dhcp client
                      at startup.

         DHCP_STOP  - Optional paremeters to pass to the dhcp client 
                      at shutdown.

         PRINTIP    - Flag to print the dhcp address to stdout

         PRINTALL   - Flag to print all obtained dhcp data to stdout

       bridge

         IP_FORWARD - An optional flag to enable the system to forward
                      inbound IP packets received by one interface to 
                      another outbound interface.  

         STP        - Set bridge spanning tree protocol.  Default is no.

FILES
       /etc/sysconfig/ifconfig.*
              definitions of network interfaces 

AUTHORS
       The ifup/ifdown suite was written by Nathan Coulson
       <nat...@linuxfromscratch.org> and Kevin P. Fleming 
       <kpflem...@linuxfromscratch.org>
       and updated by Bruce Dubbs <bdubbs@linuxfromscratch>.

SEE ALSO
       ip(8).

IFUP/IFDOWN                   8 April 2012                 ifup(8)
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to