Днес се чудих
как да се включва компютър със Slackware Linux 13.0 към отворена безжична мрежа (с неизвестно ESSID и без да се ползват графични инструменти) така, че връзката да се прави автоматично при включване на компютъра.
Взех файла rc.inet1 от Slax:
GeSHi (Bash):
#! /bin/sh
# /etc/rc.d/rc.inet1
# This script is used to bring up the various network interfaces.
#
# Modified for SLAX by Tomas M. <http://slax.linux-live.org>
#
if [ "$1" = "start" -o "$1" = "" ]; then
ifconfig lo down 2>/dev/null
/sbin/ifconfig lo 127.0.0.1 2>/dev/null
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo 2>/dev/null
# here is how to setup winfi device easily.
# First type 'iwconfig' command to see which devices are WIFI-enabled
#
# find out which device is WIFI-enabled
# eth=$(iwconfig 2>&1 | grep IEEE | cut -d " " -f 1)
# ifconfig $eth down
# mac address of your access point
# iwconfig $eth ap 11:23:b5:13:43:16
# channel value. You may skip this one, but some drives require this
# iwconfig $eth channel 11
# security key for WEP, if you are using it
# iwconfig $eth key a43b436a3c6236b4a3c5d2b5a3
# your network name
# iwconfig $eth essid my_network
# now enable the device so dhcpcd can see it in the next step
# ifconfig $eth up
#
# end of wifi sample configuration
for eth in `ls /sys/class/net | grep -v sit`; do
# bring all interfaces up and start dhcpcd for all of them
# use -t 0 to keep it running indefinitely
if [ "$eth" != "lo" ]; then
echo "Auto Configure IP address for $eth: /sbin/dhcpcd -t 60 $eth &"
kill $(cat /etc/dhcpc/dhcpcd-$eth.pid 2>/dev/null) 2>/dev/null
rm -f /etc/dhcpc/dhcpcd-$eth.pid
/sbin/ifconfig $eth up 2>/dev/null
/sbin/dhcpcd -t 0 $eth >/dev/null 2>&1 &
fi
done
fi
if [ "$1" = "stop" ]; then
killall dhcpcd
fi
Промених няколко реда:
GeSHi (Bash):
#! /bin/sh
# /etc/rc.d/rc.inet1
# This script is used to bring up the various network interfaces.
#
# Modified for SLAX by Tomas M. <http://slax.linux-live.org>
#
if [ "$1" = "start" -o "$1" = "" ]; then
ifconfig lo down 2>/dev/null
/sbin/ifconfig lo 127.0.0.1 2>/dev/null
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo 2>/dev/null
# here is how to setup winfi device easily.
# First type 'iwconfig' command to see which devices are WIFI-enabled
#
# find out which device is WIFI-enabled
eth=$(iwconfig 2>&1 | grep IEEE | cut -d " " -f 1) # променен ред
ifconfig $eth down # променен ред
# mac address of your access point
# iwconfig $eth ap 11:23:b5:13:43:16
# channel value. You may skip this one, but some drives require this
# iwconfig $eth channel 11
# security key for WEP, if you are using it
# iwconfig $eth key a43b436a3c6236b4a3c5d2b5a3
# your network name
iwconfig $eth essid any # променен ред
# now enable the device so dhcpcd can see it in the next step
ifconfig $eth up # променен ред
#
# end of wifi sample configuration
for eth in `ls /sys/class/net | grep -v sit`; do
# bring all interfaces up and start dhcpcd for all of them
# use -t 0 to keep it running indefinitely
if [ "$eth" != "lo" ]; then
echo "Auto Configure IP address for $eth: /sbin/dhcpcd -t 60 $eth &"
kill $(cat /etc/dhcpc/dhcpcd-$eth.pid 2>/dev/null) 2>/dev/null
rm -f /etc/dhcpc/dhcpcd-$eth.pid
/sbin/ifconfig $eth up 2>/dev/null
/sbin/dhcpcd -t 0 $eth >/dev/null 2>&1 &
fi
done
fi
if [ "$1" = "stop" ]; then
killall dhcpcd
fi
Това "any" е много важно, защото
не се знае коя ще бъде мрежата.
Всичко заработи без други настройки. Скриптът поддържа и жична мрежа с DHCP.
Използван хардуер при тестовете:
Canyon CN-WF518
Linksys WRT54GL
Продължение: WPA/WPA2 WiFi мрежа и Slackware 13 ($2)
Внимание! Преди да редактирате файла /etc/rc.d/rc.inet1 направете резервно копие. Същите настройки вероятно може да се направят и както пише в документацията за Slackware (чрез редакция на rc.inet1.conf). След редакция на файла /etc/rc.d/rc.inet1
мрежовите настройки, които сте направили преди това (записани в rc.inet1.conf) няма да важат и мрежата няма да работи! Този скрипт е подходящ повече за вграждане в живи дистрибуции ($2) отколкото за инсталирани системи.