...
 
Commits (35)
.\" -*- nroff -*-
.ds g \" empty
.ds G \" empty
.\" Like TP, but if specified indent is more than half
.\" the current line-length - indent, use the default indent.
.de Tp
.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
.el .TP "\\$1"
..
.TH RC.INET1 8 "12 Nov 2017" "Slackware Version 15.0"
.SH NAME
rc.inet1 \- Slackware network configuration script.
.SH DESCRIPTION
.BR rc.inet1 .
This script configures network interfaces.
Wireless interfaces are configured just like any network device
but accept many more configuration parameters.
.br
rc.inet1 reads its configuration parameters from a file `rc.inet1.conf'.
The `rc.inet1.conf' file contains a series of variable array definitions,
with each array index corresponding to a single network interface.
.SH OPTIONS
The way to start your network (the configuration of your nics and
bringing the interfaces up, and creating a default route if required)
is by running the command:
.LP
.B /etc/rc.d/rc.inet1
.LP
Restarting the whole network (all available network interfaces)
is done in a similar fashion:
.LP
.B /etc/rc.d/rc.inet1 restart
.LP
More generically speaking, you can start/stop/restart any network
interface yourself by running one of the commands:
.LP
.B /etc/rc.d/rc.inet1 INTERFACE_start
.LP
.B /etc/rc.d/rc.inet1 INTERFACE_stop
.LP
.B /etc/rc.d/rc.inet1 INTERFACE_restart
.LP
where
.I `INTERFACE'
is the name of an existing network interface (eth0, wlan0, ...)
.SH WIRELESS
The script
.I rc.wireless
takes care of configuring the wireless parameters for a network
interface. This script does not run independently. Instead, it is executed
by the generic network configuration script
.IR rc.inet1 .
.br
If a wireless interface is detected,
.I rc.wireless
will use
.I iwconfig ,
.I iwpriv
and possibly
.I wpa_supplicant
to associate the card with an access point (in managed mode) or peer it with
another computer (in ad-hoc mode), and enable an encryption modus like WPA.
.SH FILES
.TP 25
.I /etc/rc.d/rc.inet1
network configuration script
.TP
.I /etc/rc.d/rc.inet1.conf
parameter definition file (is being read by rc.inet1 and rc.wireless)
.TP
.I /etc/rc.d/rc.wireless
wireless configuration script
.TP
.I /etc/rc.d/rc.wireless.conf
parameter definition file (
.B deprecated
)
.SH DIAGNOSTICS
If you remove the executable bit from the
.I rc.wireless
script, it will never be executed. This can be beneficial if you have
written your own wireless script and don't want Slackware to mess it up.
.SH CAVEATS
The network interface definitions are stored in variable
.I arrays.
The bash shell has no facilities to retrieve the largest array index used.
Therefore, the
.I rc.inet1
script makes the assumption that array indexes stay below the value of
.BR 6 .
Effectively this means that you can configure up to 6 network interfaces in
rc.inet1.conf by default.
.LP
If you want to configure more than six network interfaces, you will
have to edit the file
.I /etc/rc.d/rc.inet1
and change the value `6' in the line:
.br
.B \ \ MAXNICS=${MAXNICS:-6}
.br
to a value that is larger than the largest index value you use.
.LP
The /etc/rc.d/rc.wireless script is not meant to be run on its own by the user!
.SH AUTHORS
Patrick J. Volkerding <volkerdi@slackware.com>
Eric Hameleers <alien@slackware.com>
Robby Workman <rworkman@slackware.com>
Darren 'Tadgy' Austin <darren@afterdark.org.uk>
.SH "SEE ALSO"
.BR rc.inet1.conf(5),
.BR ip(8),
.BR iwconfig(8),
.BR route(8)
.\" -*- nroff -*-
.ds g \" empty
.ds G \" empty
.\" Like TP, but if specified indent is more than half
.\" the current line-length - indent, use the default indent.
.de Tp
.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
.el .TP "\\$1"
..
.TH RC.INET1.CONF 5 "12 Nov 2017" "Slackware Version 15.0"
.SH NAME
rc.inet1.conf \- Slackware network configuration file.
.SH DESCRIPTION
.B rc.inet1.conf
\. This file contains the configuration settings for network interfaces.
It consists basically of a series of variable array definitions.
Array elements with the same index number will all belong to the same
network interface.
.LP
By default, index number `0' is used for the configuration of interface
.I eth0,
index number `1' is used for
.I eth1
and so forth. The default interface name can be overruled by the use of
the variable
.B IFNAME.
.LP
This is what a typical section of the file looks like for a card that is
configured to use DHCP, showing all array variables with the index number [0]:
.LP
# Config information for eth0:
.br
IPADDR[0]=""
.br
NETMASK[0]=""
.br
IPALIASES[0]=""
.br
USE_DHCP[0]="yes"
.br
DHCP_HOSTNAME[0]=""
.br
DHCP_TIMEOUT[0]=""
.LP
Alternatively, here is an example for a card that uses a static IP address and
has a non-default name (
.I ath0
instead of
.I eth1
), as well as an additional IP address configured on the interface.
The array index is [1] in this case.
.LP
# Config information for ath0 (using static IP address):
.br
IFNAME[1]="ath0"
.br
IPADDR[1]="192.168.3.11"
.br
NETMASK[1]="255.255.255.0"
.br
IPALIASES[1]="192.168.3.100/24"
.br
USE_DHCP[1]=""
.br
DHCP_HOSTNAME[1]=""
.br
GATEWAY="192.168.3.1"
.br
.SH EXAMPLE VIRTUAL INTERFACE CREATION AND SETUP
Virtual interfaces are created before any address configuration or bridge
setup is done, so you may use these interfaces as IFNAME or BRNICS values.
These can be tun or tap interfaces: adjust VIRTIFNAME and VIRTIFTYPE as
needed.
.LP
# Virtual tap interface example
.br
#VIRTIFNAME[0]="tap0"
.br
#VIRTIFTYPE[0]="tap"
.br
#VIRTIFUSER[0]="root"
.br
#VIRTIFGROUP[0]="root"
.br
.SH EXAMPLE BRIDGE CREATION AND SETUP
Note the added "BRNICS" variable which contains a space-separated list
of the physical or virtual network interfaces you want to add to the bridge.
Note that the array index can not be a duplicate of that defined for some
other interface (e.g. eth0 will be index 0 by default).
.LP
IFNAME[0]="br0"
.br
BRNICS[0]="eth0 eth1 tun0"
.br
IPADDR[0]="192.168.0.1"
.br
NETMASK[0]="255.255.255.0"
.br
IPALIASES[0]=""
.br
USE_DHCP[0]=""
.br
DHCP_HOSTNAME[0]=""
.br
.SH GENERAL PARAMETERS
This is a list of network parameters you can set for any card (wired as well
as wired). The example section is for `eth0' by default, i.e.
the array variables all have the array index [0]:
.LP
# Config information for eth0:
.TP 25
IPADDR[0]=""
# Set this value to an actual IP address if you want static IP
address assignment
.TP
NETMASK[0]=""
# With a static IP address, you are required to also set a netmask
(255.255.255.0 is common)
.TP
IPALIASES[0]=""
# Space separated list of additional IP addresses to bind to the
interface after initial configuration is complete. An optional
netmask may be specified after the IP in the form 1.2.3.4/24. If no
netmask is specified the default of /32 will be used. If USE_DHCP
is set to `yes' then additional addresses will only be added if the
dhcp client invocation is successful in obtaining a primary address.
.TP
USE_DHCP[0]="yes"
# If set to "yes", we will run a DHCP client and have the IP address
dynamically assigned
.TP
DHCP_HOSTNAME[0]="mybox"
# Tell the DHCP server what hostname to register
.TP
DHCP_TIMEOUT[0]=15
# The default timeout for the DHCP client to wait for server response is
30 seconds, but you might want a shorter wait.
.TP
IFNAME[0]="usb0"
# Use this to define configuration blocks for interfaces with non-standard
names (this should be rare these days)
.TP
HWADDR[0]="00:01:23:45:67:89"
# Overrule the card's hardware MAC address
.TP
MTU[0]=""
# The default MTU is 1500, but you might need 1360 when you use NAT'ed
IPSec traffic. IPv6 will likely require smaller MTUs as well
.TP
PROMISCUOUS[0]="yes"
# Set promiscuous mode on the interface.
.TP
DHCP_KEEPRESOLV[0]="yes"
# If you do
.B not
want `/etc/resolv.conf' overwritten by the DHCP client
.TP
DHCP_KEEPNTP[0]="yes"
# If you do
.B not
want `/etc/ntp.conf' overwritten by the DHCP client
.TP
DHCP_KEEPGW[0]="yes"
# If you do
.B not
want the DHCP client to change your default gateway
.TP
DHCP_DEBUG[0]="yes"
# Make dhcpcd show verbose diagnostics
.TP
DHCP_NOIPV4LL[0]="yes"
# Do not assign an
.I `ipv4ll'
address when a DHCP server is not found (ipv4 link-local addressing in the IP range 169.254.0.0/16 is also known as
.I `zeroconf'
address assignment)
.TP
DHCP_IPADDR[0]=""
# Request a specific IP address from the DHCP server
.SH WIRELESS PARAMETERS
For wireless cards, several additional parameter definitions are available.
All these parameters (or better, variables) start with the prefix
.B WLAN_ .
.LP
.TP 25
WLAN_ESSID[4]=DARKSTAR
# Your Wireless Access Point's name
.TP
WLAN_MODE[4]=Managed
# "Managed" mode for use with Access Points. "Ad-Hoc" is for
peer-to-peer connections.
.TP
WLAN_RATE[4]="54M auto"
# The transmission rates you want the driver to try ("auto" means
that bandwidth can be variable)
.TP
WLAN_CHANNEL[4]="auto"
# The channel to which the Access Point is tuned ("auto" to let the
driver find out the correct channel)
.TP
WLAN_KEY[4]="D5A31F54ACF0487C2D0B1C10D2"
# Definition of a WEP key
.TP
WLAN_IWPRIV[4]="set AuthMode=WPAPSK | set EncrypType=TKIP | set WPAPSK=the_64_character_key"
# Some drivers require a private ioctl to be set through the iwpriv command.
If more than one is required, you can place them in the
.I IWPRIV
parameter (separated with the pipe (|) character, see the example).
.TP
WLAN_WPA[4]="wpa_supplicant"
# Run wpa_supplicant for WPA support
.TP
WLAN_WPADRIVER[4]="ndiswrapper"
# Tell wpa_supplicant to specifically use the ndiswrapper driver.
If you leave this empty the `wext' driver is used by default; most
modern wireless drivers use 'wext'.
.TP
WLAN_WPAWAIT[4]=30
# In case it takes long for the WPA association to finish, you can
increase the wait time before rc.wireless decides that association
failed (defaults to 10 seconds)
.SH FILES
.TP 25
.I /etc/rc.d/rc.inet1
network configuration script
.TP
.I /etc/rc.d/rc.inet1.conf
configuration parameter file (is being read by rc.inet1 and rc.wireless)
.TP
.I /etc/rc.d/rc.wireless
wireless configuration script
.TP
.I /etc/rc.d/rc.wireless.conf
configuration parameter file (
.B deprecated
)
.SH CAVEATS
The network interface definitions are stored in variable
.I arrays.
The bash shell has no facilities to retrieve the largest array index used.
Therefore, the
.I rc.inet1
script makes the assumption that array indexes stay below the value of
.B 6
\.
.LP
If you want to configure more than six network interfaces, you will
have to edit the file
.I /etc/rc.d/rc.inet1
and change the value `6' in the line
.B MAXNICS=${MAXNICS:-6}
to the number of network interfaces you wish to use.
.SH AUTHORS
Patrick J. Volkerding <volkerdi@slackware.com>
Eric Hameleers <alien@slackware.com>
Robby Workman <rworkman@slackware.com>
Darren 'Tadgy' Austin <darren@afterdark.org.uk>
.SH "SEE ALSO"
.BR rc.inet1(8)
This diff is collapsed.
This diff is collapsed.
......@@ -51,7 +51,7 @@ DEBUG_ETH_UP="no"
# Example of how to configure a bridge:
# Note the added "BRNICS" variable which contains a space-separated list
# of the physical network interfaces you want to add to the bridge.
# of the physical or virtual network interfaces you want to add to the bridge.
#IFNAME[0]="br0"
#BRNICS[0]="eth0"
#IPADDR[0]="192.168.0.1"
......@@ -63,19 +63,29 @@ DEBUG_ETH_UP="no"
# Virtual interfaces to create - these are created before any address
# configuration or bridge setup is done, so you may use these interfaces
# as IFNAME or BRNICS values. These can be tun or tap interfaces:
# adjust VIRTIFNAME and VIRTIFTYPE accordingly
# adjust VIRTIFNAME and VIRTIFTYPE accordingly.
# Starting with VIRTIFNAME[0] is mandatory, and each next one must be
# incremented by one, so VIRTIFNAME[1], VIRTIFNAME[2], and so on.
#
# Virtual tap interface example
#VIRTIFNAME[0]="tap0"
#VIRTIFTYPE[0]="tap"
#VIRTIFUSER[0]="root"
#VIRTIFGROUP[0]="root"
#VIRTIFARGS[0]="user root group root"
#
# Virtual tun interface example
#VIRTIFNAME[1]="tun0"
#VIRTIFTYPE[1]="tun"
#VIRTIFUSER[1]="someuser"
#VIRTIFGROUP[1]="somegroup"
#VIRTIFARGS[1]="user someuser group somegroup"
#
# Virtual 6in4 tunnel example
#VIRTIFNAME[2]="henet0"
#VIRTIFTYPE[2]="tunnel"
#VIRTIFARGS[2]="mode sit remote 216.66.80.26 local 192.168.1.1 ttl 255"
#
# Virtual WireGuard interface example
#VIRTIFNAME[3]="wg0"
#VIRTIFTYPE[3]="wireguard"
#VIRTIFARGS[3]=""
## Example config information for wlan0. Uncomment the lines you need and fill
## in your data. (You may not need all of these for your wireless network)
......@@ -102,12 +112,15 @@ DEBUG_ETH_UP="no"
## Config information for wlan0:
#IFNAME[4]="wlan0" # Use a different interface name instead of
# the default 'eth4'
#IFNAME[4]="eth0:1" # Set up an IP alias.
#IPALIASES[4]="192.168.5.10/24" # Set up an IP alias. A netmask may be given
# with a /<prefix> after the IP address - if
# not supplied, /32 will be used as default.
#HWADDR[4]="00:01:23:45:67:89" # Overrule the card's hardware MAC address
#MTU[4]="" # The default MTU is 1500, but you might need
# 1360 when you use NAT'ed IPSec traffic.
#PROMISCUOUS[4]="yes" # Set promiscuous mode on the interface.
#DHCP_TIMEOUT[4]=15 # The default timeout for the DHCP client to
# wait for server resonse is 10 seconds, but
# wait for server resonse is 15 seconds, but
# you might want a shorter or longer wait.
#DHCP_KEEPRESOLV[4]="yes" # If you don't want /etc/resolv.conf overwritten
#DHCP_KEEPNTP[4]="yes" # If you don't want ntp.conf overwritten
......
......@@ -62,7 +62,7 @@
LOGGER=${LOGGER:-cat}
if [ -z $IFNAME ] ; then
if [ -z "$IFNAME" ] ; then
echo "WARNING: The script 'rc.wireless' must be executed by 'rc.inet1'!" | $LOGGER
echo " You should run the command \"/etc/rc.d/rc.inet1 <your_interface>_start\" yourself." | $LOGGER
return 1 2> /dev/null || exit 1
......@@ -89,11 +89,11 @@ IFCOMMAND="/sbin/ip link set dev ${INTERFACE}"
is_wireless_device ()
{
# Return 0 for a wireless interface, or 1 for a non-wireless interface.
if LC_ALL=C $IWPATH/iwconfig $1 2>&1 | grep -q "IEEE 802.11" ; then
if [ -d /sys/class/net/${1}/wireless ]; then
return 0
elif [ -d /sys/class/net/${1}/wireless ]; then
elif grep -Fxq 'DEVTYPE=wlan' /sys/class/net/${1}/uevent 2>/dev/null; then
return 0
elif [ "$(cat /sys/class/net/${1}/uevent | grep DEVTYPE)" = "DEVTYPE=wlan" ]; then
elif LC_ALL=C $IWPATH/iwconfig $1 2>&1 | grep -q "IEEE 802.11" ; then
return 0
else # all tests failed, assume the device is not wireless (or add a better test :)
return 1
......@@ -110,8 +110,7 @@ is_wireless_device ${INTERFACE} || return 0 2> /dev/null || exit 0
# If we stop a wireless interface using wpa_supplicant,
# we'll kill its wpa_supplicant daemon too and exit this script:
if [ "$2" = "stop" ]; then
WPAPID=$(echo $(ps axww | grep wpa_supplicant | grep i${INTERFACE}) | cut -f1 -d' ')
[ ${WPAPID} ] && kill ${WPAPID}
pkill --full "bin/wpa_supplicant.* -i${INTERFACE}"
return 0
fi
......@@ -124,7 +123,7 @@ $IFCOMMAND up
sleep 3
# Get the MAC address for the interface
HWADDR=$(/sbin/ip link show dev ${INTERFACE} | sed -ne 's/.*link\/ether \(..:..:..:..:..:..\).*/\U\1/p')
HWADDR=$(cat "/sys/class/net/${INTERFACE}/address")
# Empty all wireless parameters- some of them could still be set for a previous interface:
# when rc.inet1 is sourced from rc.M all scripts are run in the same shell.
......@@ -177,7 +176,7 @@ WPACONF=${WLAN_WPACONF[$i]:-${WPACONF:="/etc/wpa_supplicant.conf"}}
WPAWAIT=${WLAN_WPAWAIT[$i]:-${WPAWAIT:="60"}}
[ -n "$VERBOSE" -a -n "$INFO" ] && echo "$0: $1 information: '$INFO'"
[ -n "$VERBOSE" ] && [ -n "$INFO" ] && echo "$0: $1 information: '$INFO'"
###################
# WIRELESS CONFIG #
......@@ -199,7 +198,7 @@ fi
if [ ! -n "$NICKNAME" ] ; then
NICKNAME=$(/bin/hostname)
fi
if [ -n "$ESSID" -o -n "$MODE" ] ; then
if [ -n "$ESSID" ] || [ -n "$MODE" ] ; then
echo "$0: $IWCOMMAND nick $NICKNAME" | $LOGGER
$IWCOMMAND nick $NICKNAME
fi
......@@ -217,7 +216,7 @@ elif [ -n "$CHANNEL" ] ; then
fi
# WEP keys (non-WPA)
if [ -n "$KEY" -a ! -n "$WPA" ] ; then
if [ -n "$KEY" ] && [ ! -n "$WPA" ] ; then
if [ "$KEY" = "off" ]; then
echo "$0: $IWCOMMAND key open" | $LOGGER
$IWCOMMAND key open
......@@ -272,7 +271,7 @@ if [ -n "$IWPRIV" ] ; then
echo "${IWPRIV}|" | \
while read -d '|' iwi; do
if [ -n "$iwi" ]; then
echo "$0: '$IWPRIVCMD $iwi'" | $LOGGER
echo "$0: $IWPRIVCMD $iwi" | $LOGGER
$IWPRIVCMD $iwi
fi
done
......@@ -290,12 +289,11 @@ if [ "$WPA" = "wpa_supplicant" ] || [ "$WPA" = "wpaxsupplicant" ] && [ -x ${SUPP
$IFCOMMAND down
#WPACONF=${WPACONF:-/etc/wpa_supplicant.conf}
WPA_OPTIONS=""
[ ${WPADRIVER} ] && WPA_OPTIONS="-D${WPADRIVER}" # specify the driver
[ ${WPA} = "wpaxsupplicant" ] && WPA_OPTIONS="${WPA_OPTIONS} -e" # Use external xsupplicant (disables the internal supplicant)
[ -n "$WPADRIVER" ] && WPA_OPTIONS="-D${WPADRIVER}" # specify the driver
[ "$WPA" = "wpaxsupplicant" ] && WPA_OPTIONS="${WPA_OPTIONS} -e" # Use external xsupplicant (disables the internal supplicant)
# We leave a running wpa_supplicant process in peace:
WPAPID=$(echo $(ps axww | grep wpa_supplicant | grep i${INTERFACE}) | cut -f1 -d' ')
if [ ${WPAPID} ]; then
if pgrep --full "bin/wpa_supplicant.* -i${INTERFACE}" >/dev/null ; then
echo "$0: wpa_supplicant found running already" | $LOGGER
else
echo "$0: wpa_supplicant -B -c${WPACONF} ${WPA_OPTIONS} -i$INTERFACE" | $LOGGER
......@@ -317,7 +315,7 @@ if [ "$WPA" = "wpa_supplicant" ] || [ "$WPA" = "wpaxsupplicant" ] && [ -x ${SUPP
fi
done
if [ $wi -eq $WPAWAIT ]; then
echo "WPA authentication did not complete, try running '/etc/rc.d/rc.inet1 ${INTERFACE}_start' in a few seconds." | $LOGGER
echo "$0: WPA authentication did not complete, try running '/etc/rc.d/rc.inet1 ${INTERFACE}_start' in a few seconds." | $LOGGER
fi
# Bring interface up to avoid 'not ready' errors when calling iwconfig
$IFCOMMAND up
......