3 # Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4 # Copyright (c) 2011 The FreeBSD Foundation
7 # Portions of this software were developed by Bjoern Zeeb
8 # under sponsorship from the FreeBSD Foundation.
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
13 # 1. Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in the
17 # documentation and/or other materials provided with the distribution.
19 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 # Script which enables networking with specified options
34 ###########################################################################
36 . ${PROGDIR}/backend/functions.sh
37 . ${PROGDIR}/conf/pc-sysinstall.conf
38 . ${BACKEND}/functions-networking.sh
39 . ${BACKEND}/functions-parse.sh
54 echo "ERROR: Usage enable-net <nic> <ip> <netmask> <dns> <gateway> <ipv6> " \
55 "<ipv6gateway> <ipv6dns>"
59 if [ "$NIC" = "AUTO-DHCP" ]
62 elif [ "$NIC" = "IPv6-SLAAC" ]
65 # In addition, if static values were defined, add them as well.
66 # We might not get DNS information from RAs, for example.
67 if [ -n "${IPV6}" ]; then
70 if [ -n "${VAL}" ]; then
71 ifconfig ${VAL} inet6 ${IPV6} alias
75 if [ -n "${IPV6DNS}" ]; then
76 echo "nameserver ${IPV6DNS}" >>/etc/resolv.conf
79 if [ -n "${IPV6GATE}" ]; then
80 # Check if we have a default route already to not overwrite.
81 if ! route -n get -inet6 default > /dev/null 2>&1 ; then
82 route add -inet6 default ${IPV6GATE}
86 echo "Enabling NIC: $NIC"
87 if [ -n "${IP}" ]; then
88 ifconfig ${NIC} inet ${IP} ${NETMASK}
90 if [ -n "${IPV6}" ]; then
91 ifconfig ${NIC} inet6 ${IPV6} alias
94 # Keep default from IPv4-only support times and clear the resolv.conf file.
96 if [ -n "${DNS}" ]; then
97 echo "nameserver ${DNS}" >>/etc/resolv.conf
99 if [ -n "${IPV6DNS}" ]; then
100 echo "nameserver ${IPV6DNS}" >>/etc/resolv.conf
103 if [ -n "${GATE}" ]; then
104 route add -inet default ${GATE}
106 if [ -n "${IPV6GATE}" ]; then
107 route add -inet6 default ${IPV6GATE}
111 case ${MIRRORFETCH} in
112 ON|on|yes|YES) fetch -o /tmp/mirrors-list.txt ${MIRRORLIST} >/dev/null 2>/dev/null;;