]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/net/common/ipv4-static
a9d89a1dd1fdc446b519d73d6e102a8e6d6c5bef
2 ########################################################################
3 # Begin $network_devices/services/ipv4-static
5 # Description : IPV4 Static Boot Script
7 # Authors : Nathan Coulson - nathan@linuxfromscratch.org
8 # Kevin P. Fleming - kpfleming@linuxfromscratch.org
9 # Michael Tremer - mitch@ipfire.org
10 # Maniacikarus - Maniacikarus@ipfire.org
16 ########################################################################
20 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
22 if [ -z "${BROADCAST}" ]; then
23 boot_mesg
"BROADCAST variable missing from input, cannot continue." ${FAILURE}
28 if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then
29 PREFIX
=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-`
30 args
="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}"
32 boot_mesg
"ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE}
39 boot_mesg
"Adding IPv4 address ${ADDRESS} to the ${1} interface..."
40 ip addr add
${args} dev
${1}
43 if [ -n "${GATEWAY}" ]; then
44 if ip route |
grep -q default
; then
45 boot_mesg
"Gateway already setup; skipping." ${WARNING}
47 elif [ "${CONFIG_TYPE}" == "0" ] || [ "${CONFIG_TYPE}" == "" ] && [ "${GATEWAY}" != "" ]; then
48 boot_mesg
"Setting up default gateway for green only..."
49 ip route add default via
${GATEWAY} dev
${1}
51 if [ "${DNS1}" != "" ];then
52 boot_mesg
"Registering DNS Server for green only..."
53 echo "nameserver $DNS1" > /etc
/resolv.conf
55 if [ "${DNS2}" != "" ];then
56 echo "nameserver $DNS2" >> /etc
/resolv.conf
59 boot_mesg
"Setting up default gateway..."
60 echo $DEFAULT_GATEWAY > /var
/ipfire
/red
/remote-ipaddress
61 ip route add default via
${GATEWAY} dev
${1}
63 boot_mesg
"Registering DNS server..."
64 echo $DNS1 > /var
/ipfire
/red
/dns1
65 echo $DNS2 > /var
/ipfire
/red
/dns2
66 echo "nameserver 127.0.0.1" > /etc
/resolv.conf
67 echo $ADDRESS > /var
/ipfire
/red
/local-ipaddress
74 if [ -n "${GATEWAY}" ]; then
75 boot_mesg
"Removing default gateway..."
80 boot_mesg
"Removing IPv4 address ${ADDRESS} from the ${1} interface..."
81 ip addr del
${args} dev
${1}
86 echo "Usage: ${0} [interface] {up|down}"
91 # End $network_devices/services/ipv4-static