Announcement

Collapse
No announcement yet.

LAPTOP working as wifi-access point ( SOLVED)

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    LAPTOP working as wifi-access point ( SOLVED)

    Some times ago i asked in this board home hints on how make my linux laptop to work as wifi access point.

    After some patience and work i finally made it! So i write here how i did it:


    MY GOAL:
    use my laptop as access point to enable other pc's ( or expecially: my ipod touch :P ) to connect into internet in a place where i have no wifi access.

    In other words, my laptop go to internet using the wired card, and allow other pc's to connect trough wi-fi to my pc that work as gateway.


    little scheme:

    [internet]----(wired network)----[MY LAPTOP]----( wifi network)----( other pc & my ipod touch ).

    For some odds reason on my kubuntu my wired card is named eth1 and the wifi eth0. Usually its the contrary so take care about that when you read the following steps i made.


    Things you need to be avare:

    1)you need some undertanding of networking, dhcp, usage of command line ( dont pretend to use gui).
    2)I did this just for fun, obviusly buy an access poist its easier, faster, but i just wanted to make my ipod touch navigate at work, where i have no wifi networks.
    3)the steps i will describe how i did it, but i do not pretend there are no better ways to do it. So is gome networking guru knows better way to do things, any hint for improvement will be apprecyated.


    STEPS :
    1)make your wifi card to declare a ssid and make them to accept connections
    2)enable ip routing, forwarding and natting
    3)install/configure a dhcp server ( this is just optional )


    STEP 1
    prerequisites: You need to install the “wireless-tools” package, your linux box already detected correctly your wificard, and your wired card is already configured and enabled.

    To check if your network cards are already detected just use command line and type iwconfig:

    i got:
    lo no wireless extensions.

    eth1 no wireless extensions.

    eth0 IEEE 802.11g ESSID:"myfi"
    Mode:Ad-Hoc Frequency:2.422 GHz Cell: 02:16:6F:27:A2:35
    Bit Rate:54 Mb/s Tx-Power=20 dBm Sensitivity=8/0
    Retry limit:7 RTS thrff Fragment thrff
    Encryption key:706C-7574-6F Security mode:restricted
    Power Managementff
    Link Quality=95/100 Signal level=-31 dBm Noise level=-85 dBm
    Rx invalid nwid:0 Rx invalid crypt:18 Rx invalid frag:0
    Tx excessive retries:0 Invalid misc:0 Missed beacon:0

    this mean that my eth0 is the wifi card and is correctly detected ( for a moment dont look the eddis and other parameters.. its just enough that it has been found). You can also see that there is an eth1 card with no wireless extension..so its the wired card lets lock at it if its configured:


    >ifconfig eth1
    eth1 Link encap:Ethernet HWaddr 00:13:a9:30:1b:62
    inet addr:10.212.149.3 Bcast:10.212.149.255 Mask:255.255.255.0
    inet6 addr: fe80::213:a9ff:fe30:1b62/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:95043 errors:0 dropped:0 overruns:0 frame:0
    TX packets:42385 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:43691648 (41.6 MB) TX bytes:4878959 (4.6 MB)

    since it have an ip i guess its all right, if there is no ip be sure to configure your wired card to connect to internet.


    Now we saw the cards are ok, let configure our wifi card. You have to edit ( as root) the interface config file. Do it as the way you prefer .. i use the “vi” command line editor ( vi /etc/network/interfaces ). what i have in my file is :

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    # The loopback network interface
    auto lo
    iface lo inet loopback
    address 127.0.0.1
    netmask 255.0.0.0
    # The primary network interface
    auto eth1
    iface eth1 inet dhcp
    # wireless Ad-HOC mode
    auto eth0
    iface eth0 inet static
    address 192.168.10.1
    netmask 255.255.255.0
    wireless-essid myfi
    wireless-mode Ad-Hoc
    wireless-channel 3
    wireless-keymode restricted
    wireless-key 706c75746f


    the red part is what interest us ( hain ...be carefull, maybe in your case the wifi card is hamed eth1 or wlan 0 and eth0 is just the wired card).

    What those parameters do:

    auto eth0
    iface eth0 inet static
    address 192.168.10.1
    netmask 255.255.255.0


    make the wifi card start at boot, and make them have a static ip ( required since other pc will use it as gateway)

    wireless-essid myfi
    wireless-mode Ad-Hoc

    will make the wifi card declare an ESSID named “my-fy” and and pot the card in Ad-hoc mode instead of the standard (managed) one. This is wequired to make your card accept connection from other wifi card . A word of warning here ... the best option should be “Master” mode and not ad-hoc, but my wifi card does not accept this mode and averything works also this way. Check the man of “iwconfig” for detailed description of those options.

    wireless-channel 3
    You need to use a channel free ( not already claimed by other wi-fi networks ). Use the command “iwlist eth0 scanning” to check channels already claimed.

    wireless-keymode restricted
    wireless-key 706c75746f

    Making it simply .. if you dont use them you will create a free accessible wifi. On other words will not ask any password.. and this is not nice ok? You can ignore those options just for debugging.

    Note on: “wireless-key 706c75746f”.
    This is a hex password and will enable wep encription. Its not the best one ( the best is wpa-psk, but need some more work) . I used the following site to covert my passphrase: http://www.csgnetwork.com/wepgeneratorcalc.html but i had some problems with it. If doesnt work, try using a non protected wifi just to check that problem reside here. Find another pass generator ( there are a lot of them if you google a bit), anyway 706c75746f = “pluto” but i highly suggest you to make a your own password ( and obviusly its not the one im using :-D ).

    Save and close and restart your network ( /etc/init.d/networking restart ).

    At this pot if Everything is fine you should be able to find your wifi network from other pc's.

    STEP 2
    Even if other pc are connected you must enable routing and natting.

    As root:

    iptables -t nat -A POSTROUTING -j MASQUERADE
    echo 1 >> /proc/sys/net/ipv4/ip_forward

    those changes will ne reset ehen you restart the PC so the best idea is to make a script ( and eventually ad it into “/etc/rc.local”

    STEP3( OPTIONAL)
    Usually any wifi access point give to the host an ip. To do that you mus enable a dhcp server on yur laptop. This step is optional since you can simply ip statically put onthe pc that will use your wifi. Just put ip on the same subnet and you can avoid this step. If you will install the dhcp, ist not complicet.

    Install this package: dhcp3-server

    and edit those files:

    /etc/default/dhcp3-server
    add this line:

    INTERFACES=eth0


    put your wifi card in order to make the dhcp server to release ip only trough wifi and not also to wired interfaces.

    /etc/dhcp3/dhcpd.conf
    and add those lines in the end of files:

    subnet 192.168.10.0 netmask 255.255.255.0 {
    allow unknown-clients;
    option domain-name-servers 10.212.129.1;
    range 192.168.10.100 192.168.10.200;
    option routers 192.168.10.1;
    }


    and then :
    /etc/init.d/dhcp3-server restart


    Final notes:
    I this i wrote all basic steps, but dont pretend me to be exaustive. As i wrote at beginning, you need to be quite self sufficient using command line and undertanding network setups. What i did was even not optimal, but as i told before .. i wanted just tu use my ipod :P

    For any question ill try to reply as better as i can , but dont expect too much from me, im not a networking guru.

    Forgive my bad english languange .. im italian guy.
Working...
X