Автор Тема: отворена WiFi мрежа и Slackware 13 [РЕШЕН]  (Прочетена 2572 пъти)

vstoykov

  • Напреднали
  • *****
  • Публикации: 1286
  • Distribution: Ubuntu
  • Window Manager: Fluxbox
    • Профил
    • WWW
Днес се чудих как да се включва компютър със Slackware Linux 13.0 към отворена безжична мрежа (с неизвестно ESSID и без да се ползват графични инструменти) така, че връзката да се прави автоматично при включване на компютъра.

Взех файла rc.inet1 от Slax:

Код
GeSHi (Bash):
  1. #! /bin/sh                                          
  2. # /etc/rc.d/rc.inet1                                
  3. # This script is used to bring up the various network interfaces.
  4. #                                                                
  5. # Modified for SLAX by Tomas M. <http://slax.linux-live.org>    
  6. #                                                                
  7.  
  8. if [ "$1" = "start" -o "$1" = "" ]; then
  9.  
  10.   ifconfig lo down 2>/dev/null
  11.   /sbin/ifconfig lo 127.0.0.1 2>/dev/null
  12.   /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo 2>/dev/null
  13.  
  14.   # here is how to setup winfi device easily.
  15.   # First type 'iwconfig' command to see which devices are WIFI-enabled
  16.   #                                                                    
  17.       # find out which device is WIFI-enabled                          
  18.       #   eth=$(iwconfig 2>&1 | grep IEEE | cut -d " " -f 1)          
  19.       #   ifconfig $eth down                                          
  20.  
  21.       # mac address of your access point
  22.       #   iwconfig $eth ap 11:23:b5:13:43:16
  23.  
  24.       # channel value. You may skip this one, but some drives require this
  25.       #   iwconfig $eth channel 11
  26.  
  27.       # security key for WEP, if you are using it
  28.       #   iwconfig $eth key a43b436a3c6236b4a3c5d2b5a3
  29.  
  30.       # your network name
  31.       #   iwconfig $eth essid my_network
  32.  
  33.       # now enable the device so dhcpcd can see it in the next step
  34.       #   ifconfig $eth up
  35.   #
  36.   # end of wifi sample configuration
  37.  
  38.   for eth in `ls /sys/class/net | grep -v sit`; do
  39.      # bring all interfaces up and start dhcpcd for all of them
  40.      # use -t 0 to keep it running indefinitely
  41.      if [ "$eth" != "lo" ]; then
  42.         echo "Auto Configure IP address for $eth: /sbin/dhcpcd -t 60 $eth &"
  43.         kill $(cat /etc/dhcpc/dhcpcd-$eth.pid 2>/dev/null) 2>/dev/null
  44.         rm -f /etc/dhcpc/dhcpcd-$eth.pid
  45.         /sbin/ifconfig $eth up 2>/dev/null
  46.         /sbin/dhcpcd -t 0 $eth >/dev/null 2>&1 &
  47.      fi
  48.   done
  49.  
  50. fi
  51.  
  52. if [ "$1" = "stop" ]; then
  53.   killall dhcpcd
  54. fi
  55.  

Промених няколко реда:

Код
GeSHi (Bash):
  1. #! /bin/sh                          
  2. # /etc/rc.d/rc.inet1                
  3. # This script is used to bring up the various network interfaces.
  4. #                                                                
  5. # Modified for SLAX by Tomas M. <http://slax.linux-live.org>    
  6. #                                                                
  7.  
  8. if [ "$1" = "start" -o "$1" = "" ]; then
  9.  
  10.   ifconfig lo down 2>/dev/null
  11.   /sbin/ifconfig lo 127.0.0.1 2>/dev/null
  12.   /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo 2>/dev/null
  13.  
  14.   # here is how to setup winfi device easily.
  15.   # First type 'iwconfig' command to see which devices are WIFI-enabled
  16.   #                                                                    
  17.       # find out which device is WIFI-enabled                          
  18.          eth=$(iwconfig 2>&1 | grep IEEE | cut -d " " -f 1)                        # променен ред
  19.          ifconfig $eth down                                                                  # променен ред
  20.  
  21.       # mac address of your access point
  22.       #   iwconfig $eth ap 11:23:b5:13:43:16
  23.  
  24.       # channel value. You may skip this one, but some drives require this
  25.       #   iwconfig $eth channel 11
  26.  
  27.       # security key for WEP, if you are using it
  28.       #   iwconfig $eth key a43b436a3c6236b4a3c5d2b5a3
  29.  
  30.       # your network name
  31.          iwconfig $eth essid any                                                            # променен ред
  32.  
  33.       # now enable the device so dhcpcd can see it in the next step
  34.          ifconfig $eth up                                                                        # променен ред
  35.   #
  36.   # end of wifi sample configuration
  37.  
  38.   for eth in `ls /sys/class/net | grep -v sit`; do
  39.      # bring all interfaces up and start dhcpcd for all of them
  40.      # use -t 0 to keep it running indefinitely
  41.      if [ "$eth" != "lo" ]; then
  42.         echo "Auto Configure IP address for $eth: /sbin/dhcpcd -t 60 $eth &"
  43.         kill $(cat /etc/dhcpc/dhcpcd-$eth.pid 2>/dev/null) 2>/dev/null
  44.         rm -f /etc/dhcpc/dhcpcd-$eth.pid
  45.         /sbin/ifconfig $eth up 2>/dev/null
  46.         /sbin/dhcpcd -t 0 $eth >/dev/null 2>&1 &
  47.      fi
  48.   done
  49.  
  50. fi
  51.  
  52. if [ "$1" = "stop" ]; then
  53.   killall dhcpcd
  54. fi
  55.  

Това "any" е много важно, защото не се знае коя ще бъде мрежата.

Всичко заработи без други настройки. Скриптът поддържа и жична мрежа с DHCP.

Използван хардуер при тестовете:
Canyon CN-WF518
Linksys WRT54GL

Продължение: WPA/WPA2 WiFi мрежа и Slackware 13

Внимание! Преди да редактирате файла /etc/rc.d/rc.inet1 направете резервно копие. Същите настройки вероятно може да се направят и както пише в документацията за Slackware (чрез редакция на rc.inet1.conf). След редакция на файла /etc/rc.d/rc.inet1 мрежовите настройки, които сте направили преди това (записани в rc.inet1.conf) няма да важат и мрежата няма да работи! Този скрипт е подходящ повече за вграждане в живи дистрибуции отколкото за инсталирани системи.
« Последна редакция: Jun 02, 2010, 03:03 от vstoykov »
Активен