Γεια σε ολους τους πορωμένους!
Ειμαι και εγώ ένας από εσάς που αγαπάτε το Linux έστω κι αν καμιά
φορά μας κάνει την ζωή δύσκολη!
Χρησιμοποιώ ένα USB ασύρματο stick με sis163u τσιπάκι.
Δεν υποστηρίζεται από ότι ξέρω natively και έτσι επιτυχώς
και χωρίς το παραμικρό πρόβλημα δουλεύει με ndiwrapper.
Για τυχόν περιπτώσεις που κάποιος έχει ίδιο USB wireless stick
και δεν μπορει να το κάνει να δουλέψει επιτρέψτε μου να συμπεριλάβω
ένα scriptακι που έγραψα. Γίνεται βέβαια πολύ πιο απλά...Απλά
το script προλαμβάνει κάποιες αποτυχείες.
#!/bin/bash
#
# wlan: Wireless networking
# chkconfig: 2345 10 90
# description: Activates/Deactivates SIS163u USB device from Silicon Integrated Systems Corp.
#   ; This device was initialised using ndiswrapper and MS Windows native .sys driver
#
#
# HEX Shared encryption key
EncKey='DEF560B5A0417924D1B60977FB'
# Setting communication channel
NetChannel='7'
# Setting mode of connection
NetMode='Managed'
# Setting essid of wireless network
ESSID='MyNetwork'
# Wireless network device allias according user's preferences
NetDevice=
# Setting $USBDevice as our own device's custom name
USBDeviceName='sis163u'
# Setting $USBDevice as our own device's ID
# Find this by writing lsusb in a konsole
USBDeviceID='0227:0443'
# Setting $USBDevMac as our device's MAC address
USBDevMac='56:22:F2:A2:55:A3'
start()
{
# USBPorts var will hold a text line containing the ID of $USBDevice
# If the ID we are looking for is not pluged in/detected, $USBDeviceInfo will remain unset
USBDeviceInfo=$(lsusb | grep '$USBDeviceID')
# If our device is not found, thus $USBPorts is empty, $USBDeviceInfo will hold the string 'DNF'
# This could but will not be skipped for scripting practice reasons
USBDeviceInfo=${USBDeviceInfo: -'DNF'}
if [ '$USBDeviceInfo' = 'DNF' ]; then
printf 'Η συσκευή '$USBDeviceName' με ID:$USBDeviceID δεν βρέθηκε στο σύστημα
'
exit 1
else
printf 'Εκκίνηση συσκευής '$USBDeviceName' με ID:$USBDeviceID
'
fi
# Checking if /sbin/modprobe exists
if [ -a '/sbin/modprobe' ]; then
#printf 'Η εντολή 'modprobe' βρέθηκε
'
# Checking if module 'ndiswrapper' is loaded
if [ '$(lsmod | grep 'ndiswrapper')' = '' ]; then
printf 'Φόρτωση του module 'ndiswrapper'
'
# The driver assosiated with ndiswrapper is loaded and USB wireless device is activated
modprobe ndiswrapper
else printf 'Το module 'ndiswrapper'είναι ήδη φορτωμένο
'
fi
else printf 'Η εντολή 'modprobe' δεν βρέθηκε
'
exit 1
fi
# Checking if a network device with MAC address $USBDevMac is present and setup
if [ '$(ifconfig -a | grep '$USBDevMac')' = '' ]; then
printf 'Δεν υπάρχει interface με MAC διεύθυνση '$USBDevMac'
'
exit 1
fi
# Device has been successfully detected once we've reached this point
# Line containing $USBDevMac is isolated and interface name is subsequently
# obtained through string manipulation
NetDevice=$(ifconfig -a | grep '$USBDevMac')
NetDevice=${NetDevice% Link*}
# Checking if /sbin/ifconfig exists
if [ -a '/sbin/ifconfig' ]; then
#printf 'Η εντολή 'ifconfig' βρέθηκε
'
# The wireless device is activated. It is sometimes needed in order for the device to
# be activated. It won't harm, though including it in the activation proccess
printf 'Ενεργοποίηση συσκευής '$NetDevice'
'
ifconfig $NetDevice up
else printf 'Η εντολή 'ifconfig' δεν βρέθηκε
'
exit 1
fi
# Checking if /sbin/iwconfig exists
if [ -a '/sbin/iwconfig' ]; then
#printf 'Η εντολή 'iwconfig' βρέθηκε
'
# Sets up a connection with $NetDevice
printf 'Ρύθμιση της συσκευής '$NetDevice'
'
iwconfig $NetDevice essid $ESSID mode $NetMode channel $NetChannel key $EncKey
else printf 'Η εντολή 'iwconfig' δεν βρέθηκε
'
exit 1
fi
# Checking if /sbin/dhclient exists
if [ -a '/sbin/dhclient' ]; then
#printf 'Η εντολή 'dhclient' βρέθηκε
'
# Requests an IP through DHCP
printf 'Αναζήτηση διεύθυνσης IP για την συσκευή '$NetDevice': '
dhclient $NetDevice
else printf 'Η εντολή 'dhclient' δεν βρέθηκε
'
exit 1
fi
# Directing ifconfig's output text into grep so that
OWNIP=$(ifconfig $NetDevice | grep 'inet addr:')
# String's portion that matches the string '   ;inet addr:' is erased
# This string must necessary start at the beginning of the initial string
OWNIP=${OWNIP# &nbs p; inet addr:*}
# String's portion that matches the string ' Bcast' is erased as well as any
# other characters to the right side of the string ' Bcast'
OWNIP=${OWNIP% Bcast*}
printf '${OWNIP}
'
}
stop()
{
# USBPorts var will hold a text line containing the ID of $USBDevice
# If the ID we are looking for is not pluged in/detected, $USBDeviceInfo will remain unset
USBDeviceInfo=$(lsusb | grep '$USBDeviceID')
# If our device is not found, thus $USBPorts is empty, $USBDeviceInfo will hold the string 'DNF'
# This could but will not be skipped for scripting practice reasons
USBDeviceInfo=${USBDeviceInfo: -'DNF'}
if [ '$USBDeviceInfo' = 'DNF' ]; then
printf 'Η συσκευή '$USBDeviceName' με ID:$USBDeviceID δεν βρέθηκε στο σύστημα
'
exit 1
else
printf 'Κλείσιμο συσκευής '$USBDeviceName' με ID:$USBDeviceID
'
fi
# Checking if a network device with MAC address $USBDevMac is present and setup
if [ '$(ifconfig -a | grep '$USBDevMac')' = '' ]; then
printf 'Δεν υπάρχει interface με MAC διεύθυνση '$USBDevMac'
'
exit 1
fi
# Device has been successfully detected once we've reached this point
# Line containing $USBDevMac is isolated and interface name is subsequently
# obtained through string manipulation
NetDevice=$(ifconfig -a | grep '$USBDevMac')
NetDevice=${NetDevice% Link*}
# Checking if /sbin/dhclient exists
if [ -a '/sbin/dhclient' ]; then
#printf 'Η εντολή 'dhclient' βρέθηκε
'
# Releases the IP obtained
printf 'Απελευθέρωση της διεύθυνσης IP της συσκευής '$NetDevice'
'
dhclient $NetDevice -r
else printf 'Η εντολή 'dhclient' δεν βρέθηκε
'
exit 1
fi
# Checking if /sbin/ifconfig exists
if [ -a '/sbin/ifconfig' ]; then
#printf 'Η εντολή 'ifconfig' βρέθηκε
'
# The wireless device is deactivated.
printf 'Απενεργοποίηση συσκευής '$NetDevice'
'
ifconfig $NetDevice down
else printf 'Η εντολή 'ifconfig' δεν βρέθηκε
'
exit 1
fi
# Checking if /sbin/iwconfig exists
if [ -a '/sbin/iwconfig' ]; then
#printf 'Η εντολή 'iwconfig' βρέθηκε
'
# Sets down a connection with $NetDevice
iwconfig $NetDevice txpower 0
else printf 'Η εντολή 'iwconfig' δεν βρέθηκε
'
exit 1
fi
# Checking if /sbin/modprobe exists
if [ -a '/sbin/modprobe' ]; then
#printf 'Η εντολή 'modprobe' βρέθηκε
'
# Checking if module 'ndiswrapper' is loaded
if [ '$(lsmod | grep 'ndiswrapper')' != '' ]; then
printf 'Εκφόρτωση του module 'ndiswrapper'
'
# The driver assosiated with ndiswrapper is unloaded and USB wireless device is deactivated
modprobe ndiswrapper -r
else printf 'To Module 'ndiswrapper' είναι ήδη φορτωμένο
'
fi
else printf 'Η εντολή 'modprobe' δεν βρέθηκε
'
exit 1
fi
}
status()
{ clear
# Line containing $USBDevMac is isolated and interface name is subsequently
# obtained through string manipulation
NetDevice=$(ifconfig -a | grep '$USBDevMac')
NetDevice=${NetDevice% Link*}
# Checking if /sbin/ifconfig exists
if [ -a '/sbin/ifconfig' ]; then
# Directing ifconfig's output text into grep so that line containning
# IP address of $NetDevice can be found and isolated
OWNIP=$(ifco nfig $NetDevice | grep 'inet addr:')
# String's portion that matches the string '   ;inet addr:' is erased
# This string must necessary start at the beginning of the initial string
OWNIP=${OWNIP# &nbs p; inet addr:*}
# String's portion that matches the string ' Bcast' is erased as well as any
# other characters to the right side of the string ' Bcast'
OWNIP=${OWNIP% Bcast*}
if [ ! $OWNIP ]; then
printf 'Η συσκευή '$NetDevice' είναι απενεργοποιημένη.
'
exit 1
else printf 'Η συσκευή '$NetDevice' είναι ενεργοποιημένη.
'
fi
printf 'Διεύθυνση IP για την συσκευή '$NetDevice': $OWNIP
'
fi
}
case '$1' in
start)
printf '
========================================================= ====
'
start
printf '=========================================================== ==
'
;;
stop)
printf '
========================================================= ====
'
stop
printf '=========================================================== ==
'
;;
restart|reload)
printf '
========================================================= ====
'
stop
printf '=========================================================== ==
'
start
printf '=========================================================== ==
'
;;
status)
status
;;
*)
echo $'Χρήση εντολής $0 {start|stop|restart|reload}'
exit 1
esac
exit 0
1) Αποθηκεύστε το σε ένα αρχείο κειμένου όνομα...ασ' πούμε: wireless
2) Μετα κάντε το εκτελέσιμο με chmod +x wireless
3) Αντιγράψτε το στο /etc/init.d/
4) Συμπεριλάβετέ το στα services με chkconfig --add wireless
Μπορείτε τώρα να το δοκιμάσετε αν δώσετε:
/etc/init.d/wireless start ή stop ή restart ή reload
========================================================
Ας πάμε τώρα σε αυτό που θέλω να ρωτήσώ:
Το παραπάνω σενάριο μπορεί κάλιστα να αντικατασταθεί
με 2 αρχειάκια που θα περιέχουν τα εξής:
/etc/sysconfig/networking/devices/ifcfg-wlan0
---------------------------------------------------------
# Silicon Integrated Systems Corp.
DEVICE=wlan0
BOOTPROTO=none
HWADDR=00:40:f4:e2:74:a9
ONBOOT=yes
TYPE=Wireless
GATEWAY=192.168.1.1
IPADDR=192.168.1.50
NETMASK=255.255.255.0
TYPE=Wireless
MODE=Managed
ESSID=Naftilos76
CHANNEL=7
DOMAIN=
USERCTL=no
PEERDNS=no
IPV6INIT=no
RATE=Auto
DHCP_HOSTNAME=
---------------------------------------------------------
/etc/sysconfig/networking/devices/keys-wlan0
---------------------------------------------------------
KEY=04DEA01794972F60B5615BD7FB
---------------------------------------------------------
Αφου αποθηκεύσετε τα δύο αρχειάκια, θα μπορείτε να διαχειριστείτε
το wlan0 σας μέσα από τα μενού Σύστημα/Δίκτυο-Ρύθμιση δικτύου.
Όσον αφορά τον δεύτερο τρόπο....
/*********************************************************** *************************/
Η ερώτηση μου είναι:
Υπάρχει τρόπος να ρυθμίσουμε το δίκτυο μεσω WPA1 ή 2 με PSK ;
/*********************************************************** *************************/
Ευχαριστώ προκαταβολικά...
Για τυχόν ερωτήσεις - πολυ ευχαρίστως να βοηθήσω...
[email protected]
- Συνδεθείτε ή εγγραφείτε για να σχολιάσετε
Σχόλια
Καλησπέρα φίλος.Έχω ένα Dlink DWL-G132 usbάκι για να συνδέομαι στο ΝΕΤ.Αντέγραψα τα sys, bin και inf στο φάκελο usr/local/bin. και με το ndiswrapper δουλεύει αλλά κάθε φορά που το αποσυνδέω ή κάθε φορά που κάνω boot στο laptop πρέπει για να δουλέψει (μέσω του ndiswrapper) να απεγκαταστήσω και να ξαναεγκαταστήσω το inf. ξέρεις μήπως τον τρόπο ωστε να αποφύγω να το κάνω αυτό κάθε φορα????
Ευχαριστώ..
Απλώς Υπέροχο.
Προς: jim1900dz
1)Αν το DWL-G132 είναι γραμμένο σωστά και δεν είναι
DWL-G122 και όπως λες δουλεύει με ndiswrapper, τότε
δεν χρειάζεσαι το αρχείο .bin .Το ndiswrapper θέλει
μόνο ένα .sys και ένα .inf.
Στην εγκατάσταση του ndiswrapper τα έκανες σωστά;
1) ndiswrapper -i xxxxx.inf
2) ndiswrapper -m
3) modprobe ndiswrapper
4) ifconfig -a (για να δεις όλα τα if)
Το δικό σου θα είναι μάλλον wlan0
5) ifconfig wlan0 (ή όποιο είναι το if σου)
6) iwconfig wlan0 essid [όνομα δυκτίου].......
(θέλει κι άλλα.... δες τα μέσω man iwconfig)
7) dhclient για να πάρεις IP μέσω dhclient server
2)Αν το USB stick σου είναι DWL-G122 τότε θές μόνο το
αρχείο .bin. Το αντιγράφεις στο
folder /lib/firmware,ενεργοποιείς το knetworkmanager
στις υπηρεσείες και όταν το φορητό σου κάνει boot, το
USB stick θα ενεργοποιηθεί.Από εκεί και πέρα βάζεις
κωδικούς και έχεις πρόσβαση!
Λογικά πρέπει να αυτο-φορτώνεται και το module που
υποστηρίζει το chipset που έχει το DWL-G122 το οποίο
είναι το rt73usb. Αν δεν, τότε φόρτωσέ το εσύ με το
modprobe rt73usb
Για ότι άλλο χρειαστείς, εδώ είμαστε!
Skype nick name: naftilos76