sometimes it can be a problem when a
host arrives they get locked outside in
the cold Canadian winter because we have
it set up in such a way our studio is
within a massive building and there's a
foyer between us and the outside world
and the foyer gets locked at night and
in order to get into the building I have
to first exit Studio D walk out the Phi
a and unlock the front door to let
somebody in
so when Sasha arrives when Jeff arrives
when Henry Bailey Brown arrives they
usually message me on discord they let
me know that I'm that they're here
sometimes I don't catch that right away
and it's 40 below and it's like freezing
rain out or whatever it may be so that's
my scenario your scenario may be a
little bit different maybe you just want
to be able to walk into your house and
have all of your devices recognize that
hey honey I'm home maybe you want to use
this in an office where if I walked in
the door all of a sudden my time is
being tracked maybe that's a cheap maybe
a free way for you to be able to track
your employees coming and going from the
office maybe well how can we do that
well everybody carries a device I've got
my smartphone my smartphone is connected
to the Wi-Fi as soon as I approach the
studio once I'm here it connects to
Wi-Fi and what does that tell you well I
have an IP address on the LAN now that
I'm connected to the Wi-Fi and if I have
an IP address on the land what can i
presumably have happen to me
I can be pinged can I be pinged well
here's the thing we don't often do this
with a smartphone for example we just
let the DHCP server just dish out IP
addresses and it's all fine and good but
Robbie's here we know and trust Robbie
Robbie is a staff member and when
Robbie's here we want to know about it
Sasha when she arrives maybe we want to
know maybe in
case I want to have a little light come
on that says hey Robby it's time to open
the door walk out through the foyer and
unlock the door let her in maybe in your
office you want to be able to track if
your custody for staff is there on time
and spending the entire shift and
monitoring those maybe it's like who
knows
maybe it's an environment where you just
get paid while you're there or maybe you
just hey we want to have that light come
on when the staff has arrived so how can
we do that well every device has a MAC
address the MAC address is a private
address that's not available on the web
but it's available on the device and
it's available to the DHB dhcp server so
your DHCP server that dishes out the IP
address to every connected device says
all right we're gonna give this the next
address in the DHCP pool 10.0.0.0 seven
could be your phone so get into your
DHCP server whether it's a router or a
Windows DHCP server or maybe you've got
a Linux DHCP server and look at the MAC
address of that device and set up a DHCP
reservation so now every single time I
connect to the Wi-Fi my smart phone is
given the same IP address whatever I've
defined pardon me in my case I've said
dot five zero ping 10.0.0.0 what do you
see hey that's Robbie's phone so what
happens if I pick up my phone and I'm
gonna count down from three I'm gonna
disconnect from the Wi-Fi you ready for
this three two one click I am now off
the Wi-Fi what has happened to your
screen
it's frozen Robbie's now left the
building or he's turned off his Wi-Fi
but why would he do that if this is
being used to track his hours and make
sure that he's paid there you go
destination host unreachable I'm gonna
reestablish my Wi-Fi connection just by
pushing the Wi-Fi button on my phone in
three two one
now and let's see how long it takes so
I've now approached the building and
guess what
Robbie's back right so we know that
that's the case well how can we use that
information for good well easy-peasy
I always make things easy for you head
on over to my github github.com slash
cat5 TV slash Linux tools Linux - tools
I should say and there's a script there
called Wi-Fi check let's do it click on
it click on raw and let's download it
save as and I'm gonna throw that on my
desktop it's calling it txt whatever
I'll rename it and now let's jump into
my terminal go to my desktop move Wi-Fi
check txt to Wi-Fi check dot dot all
right CH mod + X Wi-Fi - check so now
that file is executive all all right so
now I need to create a config file so
I'm gonna call that Wi-Fi - check CFG so
echo and we're gonna go 10.0.0.0 was my
established IP address right so I'm
gonna save that to Wi-Fi - check dot CFG
so now if I nano that file look at this
oh no not Wi-Fi check dot CFG dot C F G
there it is 10 dot 0 dot 0 - 5 0 so if
Sasha brings in her smartphone I'm gonna
assign a static IP address to her which
is going to be 10.0.0.0
okay so let's pretend so I've added that
to the dot CFG file so now if I run that
file Wi-Fi - check what do you see
10.0.0.0 equals 110 dot 0 dot 0 dot 5 1
equals 0 well what does that tell us
ok so we've established Robbie's dot 5 0
Sascha's dot 5 1 do you see Sasha Sasha
was not here Robbie is so Robbie equals
1 Sasha equals 0 1 point 4 Robbie
so now programmatically we can say ok
well we can we can program that we can
change that we can manipulate that to
say ok is Robbie on line and we can run
that as a cron job right okay so
similarily let's take my smart phone and
i'm gonna turn off my Wi-Fi so now my
Wi-Fi is off I'm gonna run that command
again and watch what happens you can
assume what happens but 10.0.0.0 which
we've already established as Robbie he's
going to timeout and it's gonna say zero
so now we know that both Robbie and
Sasha are gone from the building I've
turned on my Wi-Fi and I'm gonna run
that command again and now we can see
Robbie's back Sasha's still not here so
what does that do for me so now
programmatically I can say let's get an
alert let's use a GPIO on a Raspberry Pi
to be able to trigger events so as soon
as Sasha approaches the building and her
phone connects to my Wi-Fi now all of a
sudden a green light above the door
turns on and I know exactly what that is
I'm gonna head over there and open the
door no more standing out in the
Canadian cold winters and we can do we
can program that to be able to log
things to a MySQL database there's no
limit as long as you've got some
creativity and a little know-how you're
gonna be able to do this so let's look
at that source code and see what it's
actually doing so I'm gonna edit Wi-Fi -
check from my get repository so what
it's done is it's open the file the the
config file that I created and it's
grabbing the addresses well they don't
have to be I should say they don't have
to be
IP addresses on a local land I can put
google.ca if I wanted to and then if I
run it it is just so you know so just so
you know the flexibility of this so you
can see google.ca is online it's
responding to a ping so I just want you
to know that it has that flexibility
okay so you can put anything in there
that you want as long as it's a valid
host name a domain name or it could be
an IP address as we're using in the
demonstration today for this particular
use case so then it pings it well that's
all it does it just pings it there it is
ping and it pings the host and if it is
up it responds with one and if it's down
it responds with zero okay well what
good is that if it responds with 1 or 0
you know what what do I do with that
information Robbie well this is why I
wanted to show you the source code
because you can now say okay well I know
that it's echoing out 10.0.0.0 equals 1
why don't we instead wait a minute
why don't I delete that line and say
echo and we're gonna say dollar sign
host dot and remember this is PHP is up
dot PHP oh well all right
and maybe I take this one and I say you
know what maybe there's no else maybe I
can remove the else and say it's only
gonna tell me if it's up so now if I run
that 10.0.0.0 is up right but it doesn't
show me the ones that are down or maybe
I can take that
and I'm only showing you that there's no
limit okay maybe I can say let's just
use a really simple command if dollar
sign host equals equals 10 dot 0 dot 0
dot 5 0 we're gonna say echo Robby's
here
Oh Nita boom okay see what I'm doing and
then I can change this to an else so if
it's not Ravi 10.0.0.0 it's gonna just
echo the host name so now I'm gonna re
add Google to that so you can see cuz
Google's gonna be up watch here Robby's
here yes my phone is online Google is up
I got some syntax issues but that's okay
we can work with that I'm gonna turn off
my Wi-Fi and then run it again notice
Robby's not here however Google is up
and then I watch Google is up and then
I'm gonna get that syntax issue again
I'll fix that don't you worry I know
exactly what's happening there see that
Google is up my config file
I accidentally added an extra carriage
returns that's why it's it's running
against a carriage return
trying to ping nothing so dot slash
Wi-Fi check and it's gonna say nothing
but google.ca
is up now I'm gonna turn on my Wi-Fi and
run the exact same command again Robby
is here google.ca is up so do you see
what I'm doing there so programmatically
I can do anything absolutely anything
and treat people's connectivity to their
smartphone so their smartphone connects
to the Wi-Fi the DHCP server dishes out
the IP addresses based on their
reservation based on their MAC address
now you can control events based on
coming and going of your staff I don't
think I need to say anything more I
think already in your head ideas are
coming I want you to comment below I
want you to tell me what kind of ideas
does that birth what kind of things can
you do with this I think of time
tracking as a great example robbie
checked in robbie signed out here's his
paycheck based upon that information
it's really hard to spoof that right and
i mean if you trust your staff anyways
it's really not a trust thing it's a
it's simply an ease of use thing as soon
as you connect to Wi-Fi guess what I'm
tracking the fact that you are connected
there's no there's no tracking there's
no privacy issue here it's just simply
are you online or are you not online
it's a ping and as long as that device
or that domain or that IP address
replies to ping ICMP then you're gonna
be able to in incorporate that into your
config file cap 5tv
on github you'll find a repository
called linux - tools
you start
[Music]