📜 ⬆️ ⬇️

Home server WiFi router

A home server is just ... a computer running 24 hours, 7 days a week, 365 days a year. What is he doing?
"Distributes" the Internet by wire and by air.
It is a warehouse with round-the-clock access to all of your collections of movies, music, games, programs, backups of important information. him Liked? Do you want to "make" similar at home?
Here I recall the phrase from the anecdote - "The main thing, guys, do not be afraid!".

There are several steps to creating your own home server:


We will understand.

The item number is added only to indicate that you have a choice, but since the orientation of my blog is focused on Linux, in the article, everything will be considered on the basis of this operating system. Perhaps, if it makes sense and it will be needed by people, there will be an option to describe how to create a home server on Windows.
')
Item number two. It should immediately be said that the version of the home server on the Windows OS requires more power from the components than on the Linux OS. In my case, my personal home server is based on a Pentium 4, 1000MHz, 1Gb RAM.

Item number three. It should immediately make a reservation that the article is designed for a “not-quite-new” player, but for users who have communicated with Linux and in general with a computer.

In this article we will consider the home server on the example of the OpenSUSE OS.
What do we do:



Start by installing the system. The process is trivial and simple. Almost how to install Windows.
image
Figure 1. Installing openSUSE 11.4.
Click "Next", select the desired items, language, keyboard layout, and so on. We will not linger separately, this stage is simple.
image
Figure 2. System installation process.
After installing the system, you will get a practically naked system (although, in fact, there is a lot of rubbish and garbage in it, unnecessary programs, libraries). As soon as the system is booted for the first time - reboot, if there are errors, it will immediately come out. Get to work.

To get started, look at the network settings, type in the console:
ifconfig 

and see the output command. Your network interfaces and information about them will be listed there:
image
Figure 3. Output of the ifconfig command
eth0 (internet) and eth1 (lan) - interfaces of the usual network cards, eth0 plug in the cable with the Internet, and from eth1 the cord goes to the switch, wlan0 - the WiFi card interface, lo - the back loop, mon.wlan0 - you will learn about this interface later, in another article or in the same, but below. Now it is immediately necessary to plug the cord from which the Internet flows to that network card (in this article it is eth0), into which it will always be plugged in and not to confuse them. Now, open the console and write:
 nano /etc/sysconfig/network/ifcfg-eth1 

The eth1 interface configuration file will open (the one for the local network), and write the following there:
 BOOTPROTO='static' IFPLUGD_PRIORITY='0' IPADDR='192.168.1.1/24' STARTMODE='ifplugd' USERCONTROL='no' 

Save (key combination Ctrl + O) and open the following file / etc / sysconfig / network / ifcfg-wlan0 - the wireless interface config, write the following there:
 BOOTPROTO='static' IFPLUGD_PRIORITY='0' IPADDR='192.168.2.1/24' 

This completes the preparation of network cards. You can read about these functions in the ifcfg-template file. The same settings can be made from the interface, it is enough to open Start-YAST-Network settings and change the IP addresses and other options for all available interfaces.
All done, good. We proceed to further configuration.

DHCP server. The service is called dhcpd , with the standard installation of the system, it is already included in the repository of the system, it only needs to be included:
 etc/init.d/dhcpd start/ 

The main DHCP server configuration file is located at /etc/dhcpd.conf . It is necessary to edit it. Complete information on the teams, you can get by writing the following in the console:
 man dhcpd 

For editing configuration files [further, config] files I use text editor nano , you can also use vim .

I suggest to look at the working config file of the DHCP server for clarity:
 #   DNS    ,     . option domain-name-servers 77.37.251.33, 77.37.255.30; #    DNS. ddns-update-style none; ddns-updates off; log-facility local7; #  ,   . subnet 192.168.1.0 netmask 255.255.255.0 { #  ,      IP   ,  .   ,   Server -> switch -> #Computer №1,2,3...,    ,  Server -> Computer №1. INTERFACES="eth1"; #   IP    ,    . range 192.168.1.2 192.168.1.10; #    IP   ,           ,    ,   eth1,     . option routers 192.168.1.1; #   (12 ). ,   DHCP    . ,       . default-lease-time 172800; max-lease-time 345600; } #  ,   . subnet 192.168.2.0 netmask 255.255.255.0 { #   IP . range 192.168.2.2 192.168.2.5; #    INTERFACES="wlan0"; #    IP      ,    WiFi,           ,       ,   wlan0, option routers 192.168.2.1; #   (12 ). default-lease-time 172800; max-lease-time 345600; } 

The config file was previously provided with explanatory comments. This is an example of a simple but quite working DHCP server. Also, you need to edit the / etc / sysconfig / dhcpd file, namely one line - DHCPD_INTERFACE = "" , here we enter the interfaces for the wireless subnet and the wired subnet, that is, the very interfaces that we specified in the config file of the DHCP server - / etc /dhcpd.conf in INTERFACES lines = "" . After that, it is necessary to reboot the system.

At this, editing the config file of the DHCP server is complete, if you insert the Internet cable into the server ( eth0 ), and insert the other wire into the switch and from the switch into your computer, the DHCP server will give you the address from the selected range.

HostAP - we begin to configure the distribution of WiFi.

The first thing you need is a wifi-network card company, in this article everything will be described with the condition that the network card is a Realtek company, since it is the most common. You need to download and install the hostapd utility, initially when installing from the repository it is compiled without nl80211 driver support , so you need to compile it from source, with the support of the required driver included (on the atheros network cards - the hostapd should work downloaded from the repository) . You also need to download the binutils utility package , this can be done by running the following command in the terminal:
 zypper in binutils 

After installing the utilities, you must configure the hostapd service, the whole configuration process consists of editing the configuration file /etc/hostapd.conf , the location of this file can be changed in the / etc / default / hostapd file .
 #        WiFi interface=wlan0 #       driver=nl80211 #         logger_syslog=-1 logger_syslog_level=4 logger_stdout=-1 logger_stdout_level=2 #    ssid=myssid #   country_code=RU #    (  b  n) hw_mode=g # ,     channel=3 #     WiFi wpa_passphrase=pass1234 #    wpa=3 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP 


Just above is an example of a working config. Read more about the configuration process and additional options in man'e.
 man hostapd 


The next step is to start the hostapd service in the WiFi distribution mode. To do this, we write a command in the terminal:
 hostapd -B /etc/hostapd.conf 


Voila, we get the output from the console that WiFi distribution is running from such and such MAC address and with such SSID:
 Configuration file: /etc/hostapd.conf Using interface wlan0 with hwaddr 00:17:31:ed:cb:52 and ssid 'myssid' 

Above, you can see the output of the Internet distribution command via WiFi, that is, the successful launch of the hostapd service in “daemon” mode, that is, the background operation of the service does not depend on the open terminal window in which you started the service.

At the moment, you will have a full-fledged WiFi router that can distribute the Internet over the wire and over the air. Next, we will organize file storage available inside the network, outside (from the Internet), semi-automated torrent rocking, also talk about setting up daily / weekly backups of information using the scheduler and much more to improve the functionality of the home server, increase the automation of many processes, but in other articles and notes. Thanks for attention!

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


All Articles