This topic has been raised more than once, but I never found any good and easy instructions.
This article is intended for beginners in the Linux world, so the easiest setting methods are used here.
For a start we put the packages:
sudo apt-get install wireless-tools dhcp3-server
Next, create a network through an applet, for example, the name “My Wifi”
And configure the interface (use the iwconfig command to define the interface)
We write in the console from under root
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 channel 1
iwconfig wlan0 Bit 54Mb/s
iwconfig wlan0 essid 'My Wifi'
ifconfig wlan0 10.42.43.1 netmask 255.255.255.0 up
iwconfig wlan0
ifconfig wlan0 up
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Let's look at the steps:
- ifconfig wlan0 down - disable the interface.
- iwconfig wlan0 mode ad-hoc - set Ad-hoc mode
- iwconfig wlan0 channel 1 - we put ad-hoc channel
- iwconfig wlan0 Bit 54Mb / s - speed (standard 11Mb / s)
- iwconfig wlan0 essid 'My Wifi' - the name of our created network
- ifconfig wlan0 10.42.43.1 netmask 255.255.255.0 up - IP address of the computer and subnet mask
- iwconfig wlan0 - check settings
Here are mine:
wlan0 IEEE 802.11bg ESSID:"Bupyc"
Mode:Ad-Hoc Frequency:2.412 GHz Cell: 8A:BF:88:4B:4E:60
Tx-Power=11 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
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
- ifconfig wlan0 up - we start the interface
- echo 1> / proc / sys / net / ipv4 / ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
We configure distribution of the Internet through NAT
Do not forget to substitute your interface and IP addresses.
These commands can be added to autoload, for these settings are sometimes reset.
Configure dhcp to distribute ip addresses.
sudo gedit /etc/dhcp3/dhcpd.conf
We erase everything there (if not needed) and write
ddns-update-style ad-hoc;
default-lease-time 3600;
max-lease-time 9000;
authoritative;
log-facility local7;
subnet 10.42.43.0 netmask 255.255.255.0 {
interface wlan0;
range 10.42.43.2 10.42.43.255;
option domain-name-servers 195.34.32.116; # dns , dns
option routers 10.42.43.1;
option broadcast-address 10.42.43.0;
}
sudo gedit /etc/default/dhcp3-server
There we write the interface where the Internet comes from.
INTERFACES="eth0"
Restart dhcp
sudo /etc/init.d/dhcp3-server restart
Also, for automatic configuration, you can set all parameters in the / etc / network / interfaces file.
sudo gedit /etc/network/interfaces
auto wlan0
iface wlan0 inet static
address 10.42.43.1
netmask 255.255.255.0
broadcast 10.42.43.255
network 10.42.43.0
wireless-essid Bupyc
wireless-mode ad-hoc
wireless-channel 11
wireless-rate 54Mb/s
Now it is enough to connect from any device to this network and the Internet will work.
This is my first article on Habré, so do not judge strictly.