-   Linux - Networking (
-   -   Sharing internet connection via wireless (

gugamare 01-22-2009 07:28 AM

Sharing internet connection via wireless
Hey guys,

I'm looking for a cool way to share my internet connection between my desktop running debian (lenny) and a laptop running Windows XP. Here is my situation: I plug my desktop's wired Ethernet card to a DLS modem on the wall. The desktop has a separate wireless Ethernet card, which is currently not being used for anything.

I'd like to share the connection with the laptop using the desktop's wireless card. Kind of turning my desktop into a wireless router:) I've looked into the Zebra, and Quagga projects and they seem to provide the functionality for this.

The problem is that I'm not too savvy with all the networking lingo. I'm not sure I got the right equipment, and I'm afraid to turn my computer into a bloated food processor instead of a wireless router.

So here are my questions:

1- Is this even possible or am I wasting my time?

2- If possible, is this a monstrous task or no so much?

3- Am I on the right track with Zebra/Quagga or are there more appropriate (easier to use) tools?

4- Finally, can any one recommend an article or tutorial where I can get some step-by-step instructions in achieving my objective?

Thank you all in advance.

vladmihaisima 01-22-2009 11:41 AM

I did somnething similar and it works quite well. As far I remember I used just the iptables from the kernel. I will post additional info when I'm back at that computer.

One important point. What wireless card do you have on the desktop ? You should be able to put it into ad-hoc mode (I was not able to configure mine to be an AP, but the ad-hoc mode worked well)


So this is what I did. Providing your wireless driver supports I issued this commands:

ifconfig wlan0 down
iwconfig wlan0 essid phoenix
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 key s:vvvvv
ifconfig wlan0 up

For configuring iptables you can do:


# First we flush our current rules
iptables -F
iptables -t nat -F

# Setup default policies to handle unmatched traffic
iptables -P INPUT ACCEPT

# Copy and paste these examples ...
export LAN=wlan0
export WAN=eth0

echo Adding input rules
iptables -I INPUT 1 -i ${LAN} -j ACCEPT
iptables -I INPUT 1 -i lo -j ACCEPT

echo Adding ssh input rule
iptables -A INPUT -p TCP --dport ssh -i ${WAN} -j ACCEPT

echo Adding forward tables
iptables -A FORWARD -i ${LAN} -s -j ACCEPT
iptables -A FORWARD -i ${WAN} -d -j ACCEPT

echo Adding nat tables
iptables -t nat -A POSTROUTING -o ${WAN} -j MASQUERADE
# Tell the kernel that ip forwarding is OK
echo 1 > /proc/sys/net/ipv4/ip_forward
for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done

You will also need a simple DNS server on the 'router' machine. I use dnsmasq for that, so, after all of the above I also do:


/etc/init.d/dnsmasq start
I didn't write this by myself, I copied them from somewhere, but I do not remember where. The only problem would be that you would need to configure the needed things in the kernel (like iptables and the necesssary targets). With some google-ing you should be able to do that, if you do not manage I can lookup the kernel configuration I have...

gugamare 01-23-2009 08:39 PM

Thanks allot Vlad. I'll try this out.

gugamare 01-27-2009 04:02 PM

Hey Vlad,

I've tried your suggestion but I can't seem to get it working.

When I issue the command


ifconfig wlan0 up
I get a message


SIOCSIFFLAGS: Operation not supported
Do you have any suggestions?


Some more data on my system. Im running a debian lenny, kernel 2.6.26-amd64.

When I issue lspci my wireless cards show as


Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8185 IEEE 802.11a/b/g Wireless LAN Controller (rev 20)
iwconfig gives me


wlan0    IEEE 802.11  ESSID:"phoenix" 
          Mode:Ad-Hoc  Frequency:2.412 GHz  Cell: BA:4F:45:84:79:CF 
          Tx-Power=20 dBm 
          Retry min limit:7  RTS thr:off  Fragment thr=2352 B 
          Encryption key:7676-7676-76
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0  Missed beacon:0

Thanks again

vladmihaisima 01-28-2009 03:54 AM

I think you can ignore the message of the 'ifconfig up' command, as what you posted later is looking ok.

Now, you should be able to connect from the other computer to the 'phoenix' network in adhoc mode. (the default search is for AP mode). I am not sure how you dod that on windows, I used a special program that came with the wireless adapter. For my case after setting it it took something like 1-2 minutes to connect (so, it was not 'instant')

All times are GMT -5. The time now is 12:15 AM.