My Experience/Excitement/Fun/Fight with Linux

Just another site

Connectify for Linux

Connectify allows a PC to create wireless hotspot. So using this we can share existing wired/wireless internet through a wireless interface.

How to do that in Linux? with single wireless interface/with two wireless interface card

First Rule, we are gonna stick together with the command line tools, so v have to switch off the NetworkManager service, kill nm-applet also

Do everything with root user

ubuntu/debian  users

$ service network-manager stop 


Fedora/Redhat users

$ service NetworkManager stop

First with 2 wireless interface cards

We will be using existing wireless tools in Linux.

Here is the Logic behind this

You have internet connection @ one wireless card which is a Station(Managed) node

The other wireless interface card is going to act as a Access Point(Master) node


To setup the access point we need hostapd package, either install it from your distribution repository or build from the source code

hostapd uses nl80211 driver, to check whether your card was already build with this capability run the following command

Mine is Atheros Wireless Network Adapter, so i am searching of “ath” driver module

lsmod | grep ath

ath9k 118238 0
mac80211 294370 2 ath9k,rtl8187
ath9k_common 13851 1ath9k
ath9k_hw 323077 2ath9k,ath9k_common
ath3k 12713 0
ath 23773 2 ath9k,ath9k_hw
cfg80211 178528 4 ath9k,rtl8187,mac80211,ath

As u see from the above output, my ath9k driver is build with cfg80211 capability,
tat means we can use nl80211 api
If yours is broadcom, probably u should grep for bcm or b43
If yours is not build with cfg80211 capability, try installing the extra kernel modules, i.e kernel wireless backport modules
Now we have to create hostapd configuration file
here is sample hostapd.conf file content
#change wlan0 to your wireless device

this example conf file uses wpa2 personal encryption, replace ssid, wpa_passphrase with your desired value
next to start hostapd service, run the following

$ hostapd /path/to/the/above/conf/file
Using interface wlan0 with hwaddr 00:1e:2a:xx:xx:xx and ssid 'alf-linux'

You will see some message like above if it was successful
Next we have to set ip address for our wlan0 interface, i am gonna use static ip
$ ifconfig wlan0 up

Next step, we have to set up dhcp server which listens on wlan0 interface
i am gonna use udhcpd server for that, so install from ur distro repo

To enable udhcp server, edit the file /etc/default/udhcpd
comment this line to enable the server,

edit the file /etc/udhcpd.conf

since i set ip for my wlan0, i am gonna use subnet,
so start and end should be within that range
opt dns 192.168.x.x
option subnet
opt router
option  domain

DNS is ur organizations DNS ip
router is ur wlan0 ip
domain is ur organizations domain
Having configured ur conf file, its time to start our udhcp server
$ service udhcpd start
$ /etc/init.d/udhcpd start

Hope u know how to connect with existing network for ur other interface using command line
Next we have to enable ip forwarding
$ echo "1" > /proc/sys/net/ipv4/ip_forward

Next, use iptables to do NAT(Network Address Translation)
$ iptables --table nat --append POSTROUTING --out-interface wlan1 -j MASQUERADE
$ iptables --append FORWARD --in-interface wlan0 -j ACCEPT

here wlan1 is connected to internet
wlan0 is our access point
wlan1 - use it for connecting to a existing wireless network
my existing wireless infrastructure in our college campus uses wpa2 enterprise encryption
use wpa_supplicant to connect to existing wireless access point
here is my wpa_supplicant.conf content

eap=PEAP identity="****" 
$ wpa_supplicant -i wlan1 -c /etc/wpa_supplicant.conf

To pull ip address, i am using udhcpc client,
$ udhcpc -i wlan1

So in my case, i have internet connection in my wlan1 interface
thats been shared thro wlan0 interface

The same thing can be done with single wireless interface card.
create a virtual interface for ur existing wireless interface using iw command
remaining are same.

Single Post Navigation

4 thoughts on “Connectify for Linux

  1. Hi, this is a comment.
    To delete a comment, just log in, and view the posts’ comments, there you will have the option to edit or delete them.

  2. It seems you really know a good deal with regards to this particular subject matter and it all exhibits through this specific blog post, named “Connectify for
    Linux My Experience/Excitement/Fun/Fight with Linux”.
    Thanks -Rhea

  3. Can you please be more descriptive?? Infact I had lot of errors in between which i solved my own. I did everything as you said. Now I have a phone, I turned on the wifi in it. I need to connect to the access point on my laptop through which my phone gets internet?

    Could you please explain these steps as well.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: