📜 ⬆️ ⬇️

Setting up Wifi on Linux with Adhoc using Ubuntu as an example

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:

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.

')

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


All Articles