View Single Post
Posts: 42 | Thanked: 27 times | Joined on Jun 2010
#175
Hi all, first message on forums

I have been playing with my n900, trying to get it to work as an acces point.

I am using power kernel and iptables packages.

I've managed to make route to internet, with wifi on ad-hoc mode and wep key. Also, with usbip, but the first one is the problematic for me.

As I said, it already works, but there is just some thing that annoys me, I'll explain...

Code:
#!/bin/sh
         
GATEWAY="gprs0"
INTERFACE="wlan0"
IP="192.168.201.1"
KEY="1234567890123"
ESSID="test"       
IGNORE_INTERFACE="lo usb0"
                          
if [[ -f /tmp/dnsmasq.${INTERFACE}.pid ]]; then
        echo "dnsmasq pid found, killing it"
        kill $(cat /tmp/dnsmasq.${INTERFACE}.pid)
fi                                               
  
ifconfig ${INTERFACE} down
iwconfig ${INTERFACE} mode ad-hoc
iwconfig ${INTERFACE} channel auto
ifconfig ${INTERFACE} up          
ifconfig ${INTERFACE} ${IP}
iwconfig ${INTERFACE} key s:${KEY}
iwconfig ${INTERFACE} essid ${ESSID}
                                    
dnsmasq -a ${IP} -d -i ${INTERFACE} -z -C /etc/dnsmasq.${INTERFACE}.conf $(for i in ${IGNORE_INTERFACE}; d
                                                                                                         
iptables -t nat -A POSTROUTING -o ${GATEWAY} -j MASQUERADE                                               
                                                          
PID=${!}                                                  
echo ${PID} > /tmp/dnsmasq.${INTERFACE}.pid
When I launch this script (it puts wlan0 in adhoc, starts a dhcp server on it, and tells iptables to do the natting), I can go to the outside with my laptop, but there are some annoyances.

- with gprs0 down, when I launch the script, I can freely comunicate between laptop and n900.

- with gprs0 up, I can also go to the outside, but i cannot ping from my laptop to the n900, neither from n900 to its own wlan0 address. I can ssh to it, ask for dhcp, get routed... but cannot ping.

- for the script to work, I must first connect to gprs, otherwise, changing the connection status of gprs (from connected to disconnected, or from disconnected to connected) makes the wifi stop working on the n900, and so I must re-run the script to set it up.

I would be glad if somebody knows why some of these things happen, these things make this solution not completely automated.

If somebody wants to try this script, the clean and sure way to go with it is:

- turn wifi down, and up again (for example with wifi switcher)
- connect to gprs
- start the script

I've made something similar with usbip, which is easier, as connection does not get killed with grps connection changes.

Last edited by jormartr; 2010-06-13 at 03:52.