Skip to content

Linux box as an IPv6 router with SLAAC and DHCPv6-PD

Linux box as an IPv6 router with SLAAC and DHCPv6-PD published on 3 Comments on Linux box as an IPv6 router with SLAAC and DHCPv6-PD

Some time ago I replaced my Mikrotik router with linux box which is working as a router for my home network and as a server for some services.
I had to spend some time to set up IPv6 on linux in such way, that everything was working automatically and without need to configuring anything in statically way. This post will be only about IPv6 part of router configurations.
I omit IPv4 part and configurations of network interfaces, because it is well documented in internet.

My router is running on linux openSUSE leap 42.2. The configurations are the same for other distros but file paths of config files may be different.
eth0 – wan interface of the router
eth1 – lan interface of the router
To make the router working, I had to:

  • change some sysctls to obtain IPv6 address on wan interface of my router by Stateless autoconfiguration (SLAAC).
  • I used wide-dhcpv6-client client to obtain IPv6 adresses pool (DHCPv6-PD) to redistribute addresses from pool on my devices in home network.
  • Redistributing addresses is done by dnsmasq.

First step – sysctls:
Part of my /etc/sysctl.conf confgured to obtain IPv6 address from Stateless autoconfiguration (SLAAC) on wan interface – eth0:

After reboot I can see that my wan interface has public IPv6 address:

Second step – wide-dhcpv6-client:
Configuration of wide-dhcpv6-client which will be obtaining IPv6 address pool (DHCPv6-PD) for lan interface (eth1)

Unfortunately package of wide-dhcpv6-client does not provide configuration file for systemd. To start up wide-dhcpv6-client by systemd I created wide-dhcpv6.service entry:

Enable it on system startup:

After reboot I can see that my lan interface (eth1) has assignment IPv6 address with prefix:

Last step – dnsmasq:
Part of configuration of dnsmasq (/etc/dnsmasq.conf) to redistributing IPv6 addresses in home network. Dnsmasq will also work as dns cache. :

Enable dnsmasq on system startup:

After reboot, devices in home network should be able to use internet by IPv6 🙂

But now, devices in home network are avaible from outside. Each of device has own public IPv6 address which is awailable from outside (internet).
We have to secure it, by allowing only for connections which are initialized from our internal network. It can be done by ip6tables.

It’s all, described configuration works flawlessly for me for days 🙂

Securing ssh by iptables rules

Securing ssh by iptables rules published on 3 Comments on Securing ssh by iptables rules

I secured my ssh server in simple way – with iptables rules which will be blocking attackers. I setup my iptables in such way, that it is allowing only one tcp syn packet to ssh port per minute from one ip address. With aditional configuration of sshd daemon the rules will allowing for once login attempt per hour.
iptables rules:

After we reaches this one new connection per hour, the hashlimit-htable-expire rule starts to counting 60 minutes (3600000ms). In this time you can not connect again to ssh.

MaxAuthTries in /etc/ssh/sshd_config – this is important, with this, sshd will be closing ssh connections after authentication failure, thus attacker will have to create new ssh connection (and tcp connection) to try again. This fact (new syn packet) will by noticed by iptables.

If you use only public key authentication, you can set MaxAuthTries to 1 because this is first authentication method provided by OpenSSH server, also ssh clients firstly tries authenticate through public key. Other authentication methods are on further places.

debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey

With MaxAuthTries set to 1 only fist authentication method will work –  usually publickey.

You can check the blocked addresses:

This rules very limited strength of attacks on my ssh.

Please test this first with another server access!

NanoPi NEO as remote SDR server for RTL2832u

NanoPi NEO as remote SDR server for RTL2832u published on No Comments on NanoPi NEO as remote SDR server for RTL2832u

Hi!
Today I will show how to make remote SDR radio server for RTL2832u dongle with very small and cheap device such as NanoPi NEO.

The main purpose of this is that I want place the NanoPI with RTL dongle and antenna attached to it on remote location – on high building 250 meters far away from my home. I have wireless bridge connecting my home with this place.

Notice: Wireless have to be able to send about 16Mb/s of tcp trafic from NanoPi to PC. 

On NanoPi I installed Armian Linux. After that I was set up rtl_tcp server:
900001 – this is lowest sample-rate which can be used, I used lowest because my wireless bridge wasn’t able to pass more traffic.

The next step was to setup and start gqrx on my home computer:
Notice: Input rate must be the same as set on rtl_tcp server. 192.168.51.30 – this is IP address of my NanoPi.

And now, we can hear everything around us 🙂

Raspberry Pi 2b as a home router with Cisco switch and VLANs

Raspberry Pi 2b as a home router with Cisco switch and VLANs published on 5 Comments on Raspberry Pi 2b as a home router with Cisco switch and VLANs

Hi!

Some time ago I configured my Raspberry Pi as a home router. Below, in short brief is shown my configuration.
raspberry_cisco_switch

On the Cisco switch, I have created two vlans:
vlan10 – WAN (Internet connection)
vlan20 – LAN (Home network)

The first port of the Cisco switch is connected to the the Internet, and is configured as access port for vlan10. The second port is connected to the Raspberry Pi as trunk port – traffic from vlan10 and vlan20 is tagged on this port. Third port is in access mode and is connected to the home access point.

Network configuration on Raspberry Pi looks as follows:

On eth0 interface I have set 192.168.100.1 address for management purpose in case of problems with access to the Raspberry Pi from vlan’s side. On vlan10 interface I have to set the custom mac address to obtain IP address from my internet provider. Vlan20 with addresses 192.168.50.1/24 is for my home network.
The rest of my configuration like NAT, dhcp, dns is pretty standard and will not be posted about it here. If you have questions, I will be happy to answer in the comments 🙂

How Raspberry Pi performs as a router on my 100/50 Mb/s internet connection? Quite nicely for a network card supported by USB – which has Raspberry.
4931071421