#! /bin/sh
#
# netconfig	This shell script boots up or shuts down the base INET system.
#
# Version:	@(#)/etc/init.d/netconfig 1.00 96-03-31 patrol Exp $
#               customized for sinux
#

HOSTNAME=`hostname`

case "$1" in
  start)
    echo Configuring network interfaces...
    # Attach the loopback device.
    /sbin/ifconfig lo 127.0.0.1
    /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 dev lo

    # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the 
    # eth0 interface. If you're only using loopback or SLIP, don't include the
    # rest of the lines in this file.

    # Edit for your setup.
    # IPADDR="195.39.17.1"      # REPLACE with YOUR IP address!
    IPADDR="192.168.2.1"
    IPADDR2="192.168.1.5"
    # NETMASK="255.255.255.0"   # REPLACE with YOUR netmask!
    NETMASK="255.255.255.0"
    NETMASK2="255.255.255.0"
    # NETWORK="195.39.17.0"     # REPLACE with YOUR network address!
    NETWORK="192.168.2.0"
    NETWORK2="192.168.1.0"
    # BROADCAST="195.39.17.255" # REPLACE with YOUR broadcast address!
    BROADCAST="192.168.2.255"
    BROADCAST2="192.168.1.255"
    # GATEWAY="195.39.17.8"     # REPLACE with YOUR gateway address!
    GATEWAY="192.168.1.4"

    # Configure the ethernet adaptor.
    /sbin/ifconfig eth0 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK}
    /sbin/ifconfig eth1 ${IPADDR2} broadcast ${BROADCAST2} netmask ${NETMASK2}

    # For a lonely host, configure loopback (dummy) driver
    # /sbin/ifconfig dummy0 192.168.1.1 broadcast 192.168.1.255 netmask 255.255.255.0

    # Set the network route to the ethernet network.
    #/sbin/route add -net ${NETWORK} netmask ${NETMASK} dev eth0
    #/sbin/route add -net ${NETWORK2} netmask ${NETMASK2} dev eth1

    # Set the default gateway, if one exists
    /sbin/route add default gw ${GATEWAY}

    # Make local host accessible via its ethernet address
    /sbin/route -n add ${IPADDR} gw 127.0.0.1 #194.213.33.1
    /sbin/route -n add ${IPADDR2} gw 127.0.0.1 #194.213.33.1

    # Enable gatewaying under 2.1
    echo 1 >/proc/sys/net/ipv4/ip_forward
    # Enable source routing
    echo 1 >/proc/sys/net/ipv4/conf/all/accept_source_route

    # Set up IPChains
#    /sbin/modprobe ip_masq_ftp
#    /sbin/ipchains -A forward -s libra.sinus.cz -i eth1 -j MASQ
    /sbin/ipchains -A input -i eth1 
    /sbin/ipchains -A output -i eth1 
    
    # PUT OTHER CONFIGURATION COMMANDS HERE (as starting SLIP or PPP fixed lines)
    ;;

  stop)
    # These commands are executed when the network has to be shut down.
    echo Unconfiguring network interfaces...
    /sbin/ifconfig eth0 down
    /sbin/ifconfig eth1 down
#    /sbin/ifconfig dummy0 down
    /sbin/ifconfig lo down

    ;;
  *)
    echo "Usage: netconfig {start|stop}"
    exit 1
  ;;
esac
exit 0
# End of netconfig
