Friday 15 October 2021

Sky IPV6 on Mikrotik

 Sky UK IPv6 

Researching different techniques to make Sky UK use IPv6, this is what I used. After setting up the DHCPv6 client and the options.. the rest got routing working..

 

Setting IPv6 on Mikrotik

If your ISP offers IPv6 and you have Mikrotik router, it would be shame not to make use of it. My setup assumes you get /64 prefix from your ISP (Comcast in my case) via DHCPv6. Also assumed is empty IPv6 configuration.

First I like to disable default neighbor discovery interface. Blasting IPv6 router advertisements on all intefaces is not necessarily a good idea:

/ipv6 nd
set [ find default=yes ] disabled=yes

Next step is to setup DHCP client. Withing a few seconds, you should see the prefix being allocated:

/ipv6 dhcp-client
add add-default-route=yes interface=ether1 pool-name=general-pool6 request=prefix
:delay 5s
print
Flags: D - dynamic, X - disabled, I - invalid
# INTERFACE STATUS REQUEST PREFIX
0 ether1 bound prefix 2601:600:9780:ee2c::/64, 3d14h41m41s

At this time I love to allocate address ending with ::1 to the router itself:

/ipv6 address
add address=::1 from-pool=general-pool6 interface=bridge1 advertise=yes

Now it should be possible to ping its address from external computer (in this example address would be 2601:600:9780:ee2c::1). If this doesn’t work, do check if you have link-local addresses. If none are present, reboot the router and they will be regenerated.

With router reachable, it is time to delegate IPv6 prefix to internal machines too. For this purpose, setup RA (router announcement) over the bridge. While default interval settings are just fine, I like to make them a bit shorter (20-60 seconds):

/ipv6 nd
add interface=bridge1 ra-interval=20s-60s

And that’s all. Now your computers behind the router will have direct IPv6 route to the Internet. Do not forget to setup both router firewall and firewall of individual devices. There is no NAT to save your butt here.

PS: Here is the basic IPv6 firewall allowing all connections out while allowing only established back in:

/ipv6 firewall filter
add chain=input action=drop connection-state=invalid comment="Drop (invalid)"
add chain=input action=accept connection-state=established,related comment="Accept (established, related)"
add chain=input action=accept in-interface=ether1 protocol=udp src-port=547 limit=10,20:packet comment="Accept DHCP (10/sec)"
add chain=input action=drop in-interface=ether1 protocol=udp src-port=547 comment="Drop DHCP (>10/sec)"
add chain=input action=accept in-interface=ether1 protocol=icmpv6 limit=10,20:packet comment="Accept external ICMP (10/sec)"
add chain=input action=drop in-interface=ether1 protocol=icmpv6 comment="Drop external ICMP (>10/sec)"
add chain=input action=accept in-interface=!ether1 protocol=icmpv6 comment="Accept internal ICMP"
add chain=input action=drop in-interface=ether1 comment="Drop external"
add chain=input action=reject comment="Reject everything else"
add chain=output action=accept comment="Accept all"
add chain=forward action=drop connection-state=invalid comment="Drop (invalid)"
add chain=forward action=accept connection-state=established,related comment="Accept (established, related)"
add chain=forward action=accept in-interface=ether1 protocol=icmpv6 limit=20,50:packet comment="Accept external ICMP (20/sec)"
add chain=forward action=drop in-interface=ether1 protocol=icmpv6 comment="Drop external ICMP (>20/sec)"
add chain=forward action=accept in-interface=!ether1 comment="Accept internal"
add chain=forward action=accept out-interface=ether1 comment="Accept outgoing"
add chain=forward action=drop in-interface=ether1 comment="Drop external"
add chain=forward action=reject comment="Reject everything else"

 

Sunday 3 January 2021

HomeAssistant - ESPHome IR Controller SkyQ

 Using ESPHome IR for SkyQ

Using the ESPHome project, the Infrared plugin allows me to control my TV, Soundbox and SkyQ devices quite easily.
 

The Build

A simple build.. two IR transmitters and an optional IR receiver which I used to read the codes from my existing IR remote.

The ESP32 doesn't source enough current to light up the LED's to be useful, but a simple transistor driver solves that. I wont elaborate more as here is a link to a website that explains it better. Driving an IR

The diagram I used

The YAML

 
The IR.YAML link below contains the configuration for many of the keys.
 
Download the file and edit. Set your SSID and password. Customise for your GPIO input/outputs and run.
 
 

HomeAssistant




 

Saturday 2 January 2021

ESP32 Measuring gait symetery for performance - People or Horses

 Gait symmetry analysis using ESP32




Why!

I was pondering a method that could tell if I was favouring one side or the the other when running. For horses, it can tell if its lame as the symmetry whilst trotting will be mismatched.

Design

Using an ESP32, it has a nice MESH feature called ESPNOW. This allows an almost realtime transmission of data between nodes.

For this project, a MAIN node is plugged in to a PC via USB. This node controls the outstations.

NODEs are ESP32 devices with gyro sensors attached. These have the capability to record the X, Y and Z axis of motion,  but for this - I am only using one axis. (Although all 3 can be used as its the difference in the 2 sensors that are used)

Units have batteries, chargers and all the paraphernalia to last a few hours.


Taking measurements

Tucking the units in to my sock, I done a quick few laps of the garden. They weren't comfortable, but thats the nature of the prototype

Data

Making sense of the noise, I picked a simple FFT.  the Data is from myself running in my garden for about 30 seconds. Samples are at 10Hz for left and right leg.

 FFT

Using the data collected, the FFT plots for the left and right leg.