Router from DAP-1160

Good afternoon, Habr.

I want to share a little practical experience on creating a router from the old DAP-1160 access point. The goal of this task was simple - not to buy a new router for the cottage and save money. Well and also, of course, interest.

Since I had never before encountered alternative firmware, I decided to fix this awkward moment for myself. So, here is the patient himself, an inside view, so to speak.

image

This unit has two LAN outputs and a regular 3 dbi wi-fi antenna, just what you need! We will make one port WAN, the second will remain for LAN. Next, in front of me was the choice of alternative firmware, because native does not work very stable. Therefore, the choice fell on DD-WRT or Open-WRT. But then difficulties arose. Either I didn’t search enough, or I missed something, but it’s a fact: under DAP-1160 I did not find any of the firmware, or rather I did not find the Realtek RTL8186 chip. But on one of the forum threads I was sent to the Wive-NG alternative firmware site. What was my happiness when I saw that one of the firmware supports a chip installed on my access point, and the point itself is listed in the list of supported devices.

So, the choice is made - put Wive-NG.

I must say right away: due to the fact that the access point has very modest characteristics (FLASH - 4 MiB, RAM - 16 MiB), there is no web interface in the firmware and there is only a command line.

Reflash:
For good, you should flash through tftp, but in my case it did not help. Therefore, I will tell you both options.

1. Via tftp.

We install any tftp server and download the archive and firmware. Unpack and find wive.bin, this is our firmware. We connect the LAN connector to the network card of the computer. Next, on the turned off device, hold down reset and turn it on. It should light up and turn off the power LED after a few seconds. Now we become with the device on the same network, for example, ip 192.168.1.88, mask 255.255.255.0. You can use any ip except 192.168.1.6.

Now fill the firmware:

For windows:
 tftp -i 192.168.1.6 put c:\wive.bin 
(the path to the file should be yours).
For Linux:
$ tftp
tftp> connect 192.168.1.6
tftp> mode binary
tftp> put wive.bin


2. The above option did not work for me personally. Therefore, I did the usual firmware update through the native D-Link web interface, indicating the path to wive.bin to it. Oddly enough, everything went without a hitch.

And now the most interesting thing is the setting:

By default, the device has a 10.0.0.0/8 network registered with the address on the router itself 10.200.200.249. We change the IP on the network card to be on the network with the now router. I set IP 10.200.200.248 with a mask of 255.255.255.0. Now we can safely connect via SSH to the router.

image

By default, the router login is root, the password is rtl8186. As you can see from the picture, the firmware version 0.3.18, which is far from the newest, but what can you do, the piece of iron is also not a newcomer. In essence, wive-ng is ordinary Linux and nothing Linux is alien to it. But the developers greatly simplified the lives of users by making a console menu that is called by the menu command, where all the settings of the router are presented.

image

The first thing you were advised to do was change the password to root.

You can do this as:
passwd root
and through menu -> 9) Change Password

So, in front of us we see a lot of menus with numbers. By pressing the number, the corresponding configuration file will open in the vi editor. By editing these files, the router is configured.

Personally, I was confused by the non-standard internal network on the router. Agree, it’s somehow unusual to have the address of the router on 10.200.200.249, so we change it. Go to menu -> 2) Interfaces and find the BR0 interface, then change the line
BR0_IPADDR=10.200.200.249/8
to your network address, I put
BR0_IPADDR=172.16.0.1/24
Also check for the presence of “yes” in the line
BRIDGE_START=yes


image

Here we find the ETH0 interface below and derive it from BR0:
ETH0_IN_BR0=no
The ETH0 interface will correspond to LAN1 on the device, which by output from BR0 will become the WAN interface. Next, you should look into the settings of your provider, namely how it gives you an IP address. If by DHCP, then in yes we write to this line
ETH0_USE_DHCP=yes
and leave this line empty and make it commented out:
#ETH0_IPADDR=
If you have a static IP, then write “no” for DHCP in the line:
ETH0_USE_DHCP=no
And in the next line we write your IP, issued by your provider:
ETH0_IPADDR=ваш ip


If you have one LAN output, then the next line in the ETH1 interface must be changed to
ETH1_ENABLED=no
I have 2 LAN outputs, so I leave it on.

image

Save the changes made and exit with the command
:wq


For now, let's finish the configuration of the interfaces. Let's configure DHCP.

Go to menu -> 8) Extended Menu -> 5) DHCPD .
Here we will write down the settings of our DHCP server.
We will bind the ip distribution to the br0 interface, this will make it possible to distribute ip on all ports connected to this interface (eth1 and wlan0).
Next, we set the range of distributed ip, from which ip distribution of addresses will begin:
start 172.16.0.100
and which will end
end 172.16.0.120

The following line can not be touched:
max_leases   30

We put the dns of the provider through a space or, as in my case, Google’s:
opt dns

We set the size of our network, it must match the size of the network, which you indicated in the line BR0_IPADDR = 172.16.0.1 / 24, i.e. 255.255.255.0.
option subnet 255.255.255.0

We write the gateway that our DHCP server will issue:
opt router   172.16.0.1

The following two lines can be commented out:
#opt wins и #option domain

The backup time ip for the user can be reduced, or left by default - 24 hours:
option lease   86400


image

Save and exit
:wq

We go to menu -> 1) Boot and check that our DHCP server is turned on, line
START_DHCPSERVER=yes


image

Save and exit vi editor
:wq
Now save the settings menu -> 11) Save and reboot the router menu -> 12) Reboot .
After the reboot, we will go into the router under the new ip and should get the address via DHCP. Also, do not forget that LAN1 is no longer in BR0 and you need to switch to LAN2 or connect via wi-fi with the open SSID "SF-WL".

After reconnecting to the router with a new address, we finally go to the settings for connecting to the Internet.

Again, go to menu -> 1) Boot and edit the following lines:
- turn on the router mode
IPV4_FORWARD_ENABLE=yes

- enable NAT in router mode
MASQUERADE=yes

- turn on the firewall
START_IPTABLES=yes

- let the router be a DNS server for the internal network -
START_DNSSERVER=yes


The following option is optional, but on the forums it is recommended to disable it due to the fact that the memory on the device is already so small and it’s a pity to spend it on logs:
SYSLOG_ENABLE=no

Save the changes and go to menu -> 2) Interfaces .
Now we need to choose the type of connection to our provider - PPTP, L2TP, PPOE. If your provider just gives you a static or dynamic ip, then you can skip this item.

I will consider the example of PPOE.

- turn on this type of connection
PPPOE_CALL_START=yes

- your username issued by the provider
PPPOE_USER=
and accordingly password
PPPOE_PASSWORD=
allows the router to automatically register the default route
PPPOE_DEFAULTROUTE=yes
and automatic reconnection
PPPOE_AUTO_REDIAL=yes


image

Save and exit.
Go to menu -> 8) Extended Menu -> 2) Iptables . And add a line here that includes forwarding packets to eth0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


For good, you still need to close the ssh port:
iptables -A INPUT -i eth0 -p tcp --destination-port 22 -j DROP

iptables -A INPUT -i eth0 -p udp --destination-port 22 -j DROP


Save and exit. Save in menu -> 11) Save and do 12) Reboot.

After the reboot, the router should raise the ppp0 interface, check it with the ifconfig command.

image

Trying to ping the world - should work.

5. All that remains for us is to configure wi-fi.
Go to menu -> 3) General and find the WPA line and change it to “yes” thereby turn on the WPA / WPA2 mode
WPA=yes
Find the line and change the name of the network to your
ESSID=ваше название сети

Save and exit.
Now go to menu -> 4) WPA . And turn on the WPA2-mixed mode. Change the line
encryption = 4
on the
encryption = 6

We also find the line and duplicate the name of our wi-fi network there
ssid = "ваше название сети"

And of course the network key itself, change the value in quotation marks to your
psk = "1234567890"

Save and exit.
Now menu -> 11) Save, menu -> 12) Reboot.

After the reboot, it remains for us to find our SSID and connect to it with the password that we set and use the Internet.

Bottom line: in fact, the firmware works much more stable than the native D-Link, for two days now without failures and freezes (it hung once a day or two from the native). But compared to the TL-WR1043N it works much slower, heavy sites are reluctant to open, torrents above 1 MB / s do not even go up the cable. But for the 4 Mb / s tariff plan, for which this router was conceived, it’s completely fine.

Sources: Website ng-wive , Forum-ng wive .

Also popular now: