root/floppyfw-3.0/scripts/network.ini

Revision 273, 4.7 KB (checked in by root, 10 months ago)

Various fixes I should have synced earlier and one new feature (!).

Now it will attept to save and then use the last address it got from the DHCP server through reboots.

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