📜 ⬆️ ⬇️

How to connect PC and smartphone via WiFi Ad-Hoc

Sometimes you need to connect your phone to the Internet, but not via GPRS, but, for example, through a home provider. You can install GNUBox on your smartphone and try to take the Internet from your home computer via Bluetooth. True, they say, after GNUBox on smartforn the usual connections start to fail. You can put a router with WiFi - and connect a smartphone to it.

If you don’t want to deal with GNUBox or buy a WiFi router, you can set up a WiFi Ad-Hoc connection on your home computer. Having set up Ad-Hoc WiFi between a home computer and a smartphone, I got the opportunity to call from home through the SIP-client of my mobile phone. But the main thing is that I was able to get my daughter to call someone else’s mobiles not from her home MGTS phone, but through the SIP of her Nokia E70 (it was unreal to force the child to put on headphones and call from the computer - she used to ride around the apartment, talking on the phone for hours). Savings amounted to almost a thousand per month :)

Described below, I did, having:
- computer with Fedora 7;
- WiFi dongle ASUS WL-169gE;
- Nokia E61 smartphone.

If your computer does not have a built-in WiFi module, we will buy an external USB WiFi adapter and wiggle it over the drivers. If the WiFi module is built in and determined by the system (as in my case), go to the item on setting up a network connection .
')
INSTALLING DRIVER
To connect my USB WiFi adapter ASUS WL-169gE, I used the ndiswrapper utility, which I installed as follows (I note that at the beginning of the installation, the WiFi adapter MUST NOT be connected to the computer):
# yum install ndiswrapper kmod-ndiswrapper

The drivers coming with the adapter on the CD are not suitable, so I had to download the latest version from www.asus.com and unpack the driver for Windows XP. Install these drivers using ndiswrapper (instructions for installing this and other adapters can be found at ndiswrapper.sourceforge.net/joomla/index.php?/component/option , com_openwiki / Itemid, 33 / id, list_a /):
# / usr / sbin / ndiswrapper -i bcmrndis.inf
# cp RNDISMPK.sys /etc/ndiswrapper/bcmrndis/rndismpk.sys
# cp usb8023k.sys / etc / ndiswrapper / bcmrndis /

Let's look at the status of the newly installed driver:
# / usr / sbin / ndiswrapper -l
bcmrndis: driver installed

Now let's write in the /etc/udev/rules.d/99-custom.rules file (if this file is missing, create it) the line:
BUS == "usb", SYSFS {idProduct} == "1717", SYSFS {idVendor} == "0B05", RUN + = "/ bin / sh -c 'echo 1> / sys / $ devpath / device / bConfigurationValue' "

Connect the WiFi-stick to the USB-port.
Load the ndiswrapper into memory:
# / sbin / modprobe -v ndiswrapper

In general, this command should be registered in rc.local .
By team
# / sbin / iwconfig
You can see the configuration of the wireless card.

To make the device connect at boot, add the following line to /etc/modprobe.conf :
alias wlan0 ndiswrapper

Now, when the system boots, it will locate and initialize the WiFi adapter.

CONFIGURING A NETWORK CONNECTION ON A COMPUTER

Create 6 files on your computer. On the computer to which I connected external WiFi, the system identified the WiFi adapter as a device named wlan0 . On a laptop with a built-in WiFi module, it bears the “system name” eth1 . Accordingly, for my computer with external WiFi, the name of the first file listed below is / etc / sysconfig / network-scripts / ifcfg-wlan0 (this file was not in the system, I created it), and for a laptop with a built-in module, / etc / sysconfig / network-scripts / ifcfg-eth1 (this file already existed, and I just edited it, making a copy of the old file just in case). So, here are 6 files that define the network connection configuration:
/ etc / sysconfig / network-scripts / ifcfg- name of the WiFi adapter
/ etc / sysconfig / network-scripts / keys- name of the WiFi adapter
/ etc / sysconfig / networking / devices / ifcfg- name of the WiFi adapter
/ etc / sysconfig / networking / devices / keys - name of the WiFi adapter
/ etc / sysconfig / networking / profiles / default / ifcfg- name of the WiFi adapter
/ etc / sysconfig / networking / profiles / default / keys- name of the WiFi adapter

In the keys- files , the name of the WiFi adapter is to write a line (enter here your 13 digits, which will be used as a key for network access):
KEY = s: 1234567890123

And in the ifcfg file, the name of the WiFi adapter is the configuration of the WiFi adapter by assigning it the IP address 10.0.0.1, and the WiFi network the name my_wifi:
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
ONBOOT = yes
USERCTL = yes
IPV6INIT = no
PEERDNS = yes
TYPE = Wireless
DEVICE = name of the WiFi adapter
HWADDR =
BOOTPROTO = none
DOMAIN =
ESSID = my_wifi
CHANNEL = 3
MODE = Ad-Hoc
RATE = Auto
NETMASK = 255.255.255.0
DHCP_HOSTNAME =
IpadDR = 10.0.0.1

Reboot or turn on the settings you just made without rebooting, having commanded:
# / sbin / ifup wlan0

SETUP OF NETWORK CONNECTION ON SMARTPHONE

Communication -> Disp. -> Available WLAN . The newly created my_wifi should appear in the list of detected networks. Close the list of networks and go to the "desktop" phone. Now Menu -> Tools -> Settings -> Connections -> Access Points . Functions -> New access point -> Use. std options . Fill in the appeared connection settings fields:
Connection Name: my_wifi
Data Channel: WLAN
WLAN network name: network name search
Network Status: Open
WLAN network mode: Peer to Peer
WLAN security mode: WEP
Par WLAN protection:
Current WEP Key: # 1
Authentication type: Open
Param WEP key:
WEP encryption: 64 bits
WEP key format: ASCII
WEP key: 1234567890123 (here you need to register those 13 digits that we previously indicated in the keys-wlan0 files)

Now assign the phone IP:
Functions -> Advanced Parameters -> IPv4 Settings
Phone IP Address: 10.0.0.2
Subnet Mask: 255.255.255.0
Default Gateway: 10.0.0.1
DNS address: here we write the addresses of DNS servers that are listed in on the computer in the Internet connection settings .

Now, having launched PuTTY, a browser or an FTP client on a smartphone, we can respectively work on a computer in a text console and access it as a Web or FTP server. The main thing is to have Apache and some FTP server spinning on the computer (I already wrote about the simplest setting up of a computer as a server).

SETTING UP WORKS WITH CYRILLES FOR PuTTY

Since my default is the ru_RU.UTF-8 locale (you can check the locale with the $ locale command), so that when entering with the smartphone PuTTY all characters were readable, and not just Latin, you had to add to the end of the file ~ /. bashrc following commands:
if [["$ TERM" = "xterm"]] && [["$ LANG" = * .UTF-8]]; then
# putty needs it to enable utf-8
echo -ne '\ e% G'
fi

GO TO THE INTERNET

On the computer, create the file /opt/iptables.txt and enter the following text into it. Attention: in the text below, replace in three places the address 130.234.201.155 with the IP address of your computer on the local network (home or work, through which your computer can access the Internet), for example, at 192.168.1.2 , and the pair that occurs once is 130.234 .0.0 / 255.255.0.0 to the data corresponding to the settings of your network, for example, 192.168.1.0/255.255.255.0 ):

# Generated by iptables-save v1.3.5 on Tue Dec 12 06:08:26 2006
* nat
: PREROUTING ACCEPT [102343: 16097956]
: POSTROUTING ACCEPT [11574: 715293]
: OUTPUT ACCEPT [11574: 715293]
-A POSTROUTING -s 10.0.0.0/255.255.255.0 -o eth0 -j SNAT --to-source 130.234.201.155
COMMIT
# Completed on Tue Dec 12 06:08:26 2006
# Generated by iptables-save v1.3.5 on Tue Dec 12 06:08:26 2006
* filter
: INPUT ACCEPT [746408: 376053423]
: FORWARD ACCEPT [69495: 52803710]
: OUTPUT ACCEPT [314025: 40294091]
-A INPUT -s 130.234.0.0/255.255.0.0 -d 130.234.201.155 -p tcp -m tcp --sport 513: 65535 --dport 22 -m state --state NEW, ESTABLISHED -j ACCEPT
-A INPUT -d 130.234.201.155 -p tcp -m tcp --sport 513: 65535 --dport 22 -m state --state NEW, ESTABLISHED -j DROP
COMMIT
# Completed on Tue Dec 12 06:08:26 2006

Let's launch our Ad-Hoc network, having commanded:
# / sbin / sysctl -w net.ipv4.ip_forward = 1
# / sbin / iptables-restore ./iptables.txt

Now the smartphone can connect not only to Web-based and FTP-servers installed on NK, but also go to Internet sites, connect to FTP-servers of the “large” network.

Original of my article in LJ

Source: https://habr.com/ru/post/45897/


All Articles