root/floppyfw/files/network.ini

Revision 259, 4.6 KB (checked in by root, 3 years ago)

About time to commit.

Line 
1#!/bin/sh
2
3# $Id: network.ini,v 1.9 2005/08/13 10:02:16 thomasez Exp $
4
5# Remember to set up the network interface card with IRQ and base address
6# in syslinux.cfg if nessesary.
7
8#
9# Grabbing the config.
10#
11. /etc/config
12
13ifconfig lo 127.0.0.1
14
15
16#
17# Brad wanted these next 5 lines.
18#
19cat > /etc/inside.info <<-EOF
20        INSIDE_DEVICE=$INSIDE_DEV
21        INSIDE_IP=$INSIDE_IP
22        INSIDE_NETMASK=$INSIDE_NETMASK
23EOF
24
25#
26# Let's make things easier for the users and find this automagically.
27#
28[ -n "$INSIDE_IP" ] && [ -n "$INSIDE_NETMASK" ] && {
29        eval `ipcalc -n -b $INSIDE_IP $INSIDE_NETMASK`
30        INSIDE_NETWORK=$NETWORK
31        unset NETWORK
32        INSIDE_BROADCAST=$BROADCAST
33        unset BROADCAST
34}
35
36
37cat >> /etc/inside.info <<-EOF
38        INSIDE_NETWORK=$INSIDE_NETWORK
39        INSIDE_BROADCAST=$INSIDE_BROADCAST
40EOF
41
42# Resetting.
43NETWORK=
44BROADCAST=
45
46#
47# Setting up the inside:
48#
49ifconfig $INSIDE_DEV $INSIDE_IP \
50        netmask $INSIDE_NETMASK broadcast $INSIDE_BROADCAST
51
52#
53# setting up /etc/hosts
54#
55echo ""
56echo "$INSIDE_IP $HOSTNAME.$DOMAIN  $HOSTNAME" >> /etc/hosts
57# setting up hostname
58hostname $HOSTNAME
59hostname -d $DOMAIN
60echo "Hostname (fully qualified) set up to `hostname -f`"
61
62#
63# Tip from Jacco Kok. Setting the MAC address to fool
64# some bootp/dhcp servers and arp.
65#
66if [ "$OUTSIDE_MAC" != "" ]
67then
68        echo "Faking MAC address."
69        ifconfig $OUTSIDE_DEV hw ether $OUTSIDE_MAC
70fi
71
72#
73# DMZ Setup. This has to be done before the OUTSIDE stuff since
74# it's the outside stuff that starts firewall.ini
75#
76if [ "$USE_DMZ" = y ]
77then
78        #
79        # Let's make things easier for the users and find this automagically.
80        #
81        echo "Setting up DMZ network."
82        eval `ipcalc -n -b $DMZ_IP $DMZ_NETMASK`
83        DMZ_NETWORK=$NETWORK
84        DMZ_BROADCAST=$BROADCAST
85
86        ifconfig $DMZ_DEV $DMZ_IP netmask $DMZ_NETMASK broadcast $DMZ_BROADCAST
87
88        cat > /etc/dmz.info <<EOF
89DMZ_DEVICE=$DMZ_DEV
90DMZ_IP=$DMZ_IP
91DMZ_NETMASK=$DMZ_NETMASK
92DMZ_NETWORK=$DMZ_NETWORK
93DMZ_BROADCAST=$DMZ_BROADCAST
94EOF
95
96fi
97
98
99#
100# Outside settings basec on the CONNECT_TYPE:
101#
102
103#
104# All connection methods other than the default (STATIC) has to:
105#
106# - Create /etc/outside.info
107# - Create /etc/resolf.conf
108# - Set default gateway
109# - Boot /etc/firewall.ini
110
111
112case "$CONNECT_TYPE" in
113        #
114        # Both PPP and PPPoE is taken care of by the ppp-up.ini script.
115        #
116        PPP|PPPoE|PPPOE)
117                echo "Connetion method is PPP(oE), "
118                echo -n "loading PPP modules."
119                echo -n "slhc "
120                modprobe slhc
121                echo -n "ppp_generic "
122                modprobe ppp_generic
123                echo "ppp_async "
124                modprobe ppp_async
125                /etc/ppp/ppp-up
126                #
127                # Uwe Dippel wanted this one here.
128                #
129                if [ $DEMAND != 'no' ]; then
130                        echo "Demand dialing enabled, running firewall.init"
131                        /etc/firewall.init
132                fi
133                ;;
134        DHCP)
135                echo "Connetion method is DHCP"
136                echo "OUTSIDE_DEVICE=$OUTSIDE_DEV" > /etc/outside.info
137                HARGS=
138                [ "$USER_IDENT" != "" ] && HARGS="-H $USER_IDENT"
139                if /sbin/udhcpc -n -s /etc/udhcpcrenew.sh $HARGS -i $OUTSIDE_DEV
140                then
141                        . /etc/outside.info
142                else
143                        echo "duh!"     # Or some more useful error handling
144                fi
145                ;;
146        EXTERNAL)
147                echo "Connetion method is an External script (/etc/ext-up.ini)"
148                /etc/ext-up.init
149                ;;
150        *)  # STATIC and the rest.
151                echo "Connetion method is the default (STATIC)."
152
153                #
154                # Let's make things easier for the users and
155                # find this automagically.
156                #
157                eval `ipcalc -n -b $OUTSIDE_IP $OUTSIDE_NETMASK`
158                OUTSIDE_NETWORK=$NETWORK
159                OUTSIDE_BROADCAST=$BROADCAST
160
161                ifconfig $OUTSIDE_DEV $OUTSIDE_IP \
162                        netmask $OUTSIDE_NETMASK broadcast $OUTSIDE_BROADCAST
163                route add default gw $DEFAULT_GATEWAY metric 1
164
165                echo "Setting up name server (etc/resolv.conf) "
166
167                echo "search $DOMAIN" >> /etc/resolv.conf
168
169                NAME_SERVER=`echo $OUTSIDE_NAMESERVERS | sed 's/,/ /g'`
170                for i in $NAME_SERVER
171                do
172                        echo "nameserver $i" >> /etc/resolv.conf
173                done
174                unset i
175
176                cat > /etc/outside.info <<EOF
177OUTSIDE_DEVICE=$OUTSIDE_DEV
178OUTSIDE_IP=$OUTSIDE_IP
179OUTSIDE_NETMASK=$OUTSIDE_NETMASK
180OUTSIDE_NETWORK=$OUTSIDE_NETWORK
181OUTSIDE_BROADCAST=$OUTSIDE_BROADCAST
182OUTSIDE_GATEWAY=$DEFAULT_GATEWAY
183EOF
184                # Resetting.
185                NETWORK=
186                BROADCAST=
187
188                echo "Setting up firewall rules: "
189                /etc/firewall.init
190                echo
191                ;;
192esac
193
194
195#
196# No umask so it ends up with 600 with both dhcp and PPPoE
197# I'm lazy and place it here.
198chmod 644 /etc/resolv.conf
199
200#
201# DHCP Daemon and DNS Cache.
202#
203p=`pidof dnsmasq`
204
205DNSMASQ_OPTS="-i $INSIDE_DEV"
206
207if [ "$USE_DMZ" = y ]
208then
209  DNSMASQ_OPTS="$DNSMASQ_OPTS -i $DMZ_DEV"
210fi
211
212if [ "$DHCP_SERVER" = y ]
213then
214        /etc/udhcpd.conf.sh
215        /sbin/udhcpd /etc/udhcpd.conf
216        pidof dnsmasq || /sbin/dnsmasq $DNSMASQ_OPTS 
217else
218        if [ "$DNSMASQ" = y ]
219        then
220                pidof dnsmasq || /sbin/dnsmasq $DNSMASQ_OPTS 
221        fi
222fi
223
224if [ "$DMZ_DHCP_SERVER" = y ]
225then
226        /etc/dmz-udhcpd.conf.sh
227        /sbin/udhcpd /etc/dmz-udhcpd.conf
228        pidof dnsmasq || /sbin/dnsmasq $DNSMASQ_OPTS 
229fi
Note: See TracBrowser for help on using the browser.