/[scripts]/trunk/wifi-bridge.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/wifi-bridge.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 57 - (hide annotations)
Thu Jan 10 20:11:42 2008 UTC (16 years, 2 months ago) by dpavlin
File MIME type: application/x-sh
File size: 1274 byte(s)
setup bridge between eth0 and wifi or other way around

1 dpavlin 57 #!/bin/sh
2    
3     wif=`iwconfig 2>&1 | grep -i 802.11 | cut -d" " -f1`
4    
5     essid=foobar
6     key=s:secret
7     ap=1
8    
9     # doma
10     essid=dreamhouse
11     key=off
12     ap=0
13    
14     test -z "$wif" && (
15     sudo rmmod ath_pci
16     sudo modprobe ath_pci
17     wif=`iwconfig 2>&1 | grep -i 802.11 | cut -d" " -f1`
18     test -z "$wif" && echo "no wifi device" && exit
19     )
20    
21     echo "*** stop interfaces $wif eth0"
22    
23     sudo ifconfig $wif down
24     sudo ifconfig eth0 down
25     sudo ifconfig br0 down
26     sudo brctl delif br0 $wif
27     sudo brctl delif br0 eth0
28     sudo brctl delbr br0
29    
30     if [ $ap == 1 ] ; then
31     mode=ap
32     else
33     mode=managed
34     fi
35    
36     echo "*** setup wifi $mode $essid"
37    
38     sudo wlanconfig $wif destroy || exit
39     sudo wlanconfig $wif create wlandev wifi0 wlanmode $mode || exit
40     wif=`iwconfig 2>&1 | grep -i 802.11 | cut -d" " -f1`
41    
42     test -z "$wif" && echo "no wifi device" && exit
43    
44     echo "*** using wifi $wif $essid"
45    
46     sudo iwconfig $wif essid $essid
47     sudo iwconfig $wif key $key
48    
49     sudo ifconfig $wif up
50     sudo iwconfig $wif
51    
52     echo "*** creating bridge $wif eth0"
53    
54     sudo brctl addbr br0
55     sudo brctl delif br0 eth0
56     sudo brctl delif br0 $wif
57    
58     sudo ifconfig eth0 0.0.0.0 up
59     sudo brctl addif br0 eth0
60     sudo brctl addif br0 $wif
61    
62     echo "*** getting public IP address"
63    
64     sudo dhclient br0
65     sudo ln -sf /etc/resolv.conf.dhclient-new /etc/resolv.conf-upstream
66     sudo /etc/init.d/dnsmasq restart
67    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26