CCNA DevNet Notes

1) Python Requests status code checks:

r.status_code == requests.codes.ok

2) Docker publish ports:

$ docker run -p 127.0.0.1:80:8080/tcp ubuntu bash

This binds port 8080 of the container to TCP port 80 on 127.0.0.1 of the host machine. You can also specify udp and sctp ports. The Docker User Guide explains in detail how to manipulate ports in Docker.

3) HTTP status codes:

1xx informational
2xx Successful
 201 created
 204 no content (post received by server)
3xx Redirect
 301 moved permanently - future requests should be directed to the given URI
 302 found - requested resource resides temporally under a different URI
 304 not modified
4xx Client Error
 400 bad request
 401 unauthorized (user not authenticated or failed)
 403 forbidden (need permissions)
 404 not found
5xx Server Error
 500 internal server err - generic error message
 501 not implemented
 503 service unavailable

4) Python dictionary filters:

my_dict = {8:'u',4:'t',9:'z',10:'j',5:'k',3:'s'}

# filter(function,iterables)
new_dict = dict(filter(lambda val: val[0] % 3 == 0, my_dict.items()))

print("Filter dictionary:",new_filt)

5) HTTP Authentication

Basic: For "Basic" authentication the credentials are constructed by first combining the username and the password with a colon (aladdin:opensesame), and then by encoding the resulting string in base64 (YWxhZGRpbjpvcGVuc2VzYW1l).

Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l

---
auth_type = 'Basic'
creds = '{}:{}'.format(user,pass)
creds_b64 = base64.b64encode(creds)
header = {'Authorization': '{}{}'.format(auth_type,creds_b64)}

Bearer:

Authorization: Bearer <TOKEN>

6) “diff -u file1.txt file2.txt”. link1 link2

The unified format is an option you can add to display output without any redundant context lines

$ diff -u file1.txt file2.txt                                                                                                            
--- file1.txt   2018-01-11 10:39:38.237464052 +0000                                                                                              
+++ file2.txt   2018-01-11 10:40:00.323423021 +0000                                                                                              
@@ -1,4 +1,4 @@                                                                                                                                  
 cat                                                                                                                                             
-mv                                                                                                                                              
-comm                                                                                                                                            
 cp                                                                                                                                              
+diff                                                                                                                                            
+comm
  • The first file is indicated by —
  • The second file is indicated by +++
  • The first two lines of this output show us information about file 1 and file 2. It lists the file name, modification date, and modification time of each of our files, one per line. 
  • The lines below display the content of the files and how to modify file1.txt to make it identical to file2.txt.
  • - (minus) – it needs to be deleted from the first file.
    + (plus) – it needs to be added to the first file.
  • The next line has two at sign @ followed by a line range from the first file (in our case lines 1 through 4, separated by a comma) prefixed by “-“ and then space and then again followed by a line range from the second file prefixed by “+” and at the end two at sign @. Followed by the file content in output tells us which line remain unchanged and which lines needs to added or deleted(indicated by symbols) in the file 1 to make it identical to file 2

7) Python Testing: Assertions

.assertEqual(a, b)	a == b
.assertTrue(x)	        bool(x) is True
.assertFalse(x)	        bool(x) is False
.assertIs(a, b)	        a is b
.assertIsNone(x)	x is None
.assertIn(a, b)	        a in b
.assertIsInstance(a, b)	isinstance(a, b)

*** .assertIs(), .assertIsNone(), .assertIn(), and .assertIsInstance() all have opposite methods, named .assertIsNot(), and so forth.

Pinza Veneta

This is a typical cake from the Veneto region in Italy. I tasted it in Venice and wanted to try myself at some point, and that happened this weekend.

I used this video and this blog as inspiration.

Ingredients:

  • 1 litre whole milk (have some more extra just in case)
  • 200g corn flour (semolina)
  • 70g 00′ flour (plain can work too)
  • 80g butter
  • 100g sugar
  • 50g walnuts (chopped) – optional
  • 70ml Sambuca (didnt have Grappa)
    • 1 tsp fennel seeds (I used caraway as I didnt have fennel)
    • 1 tsp anis seeds
    • 1 orange: zest + juice
    • 1 lemon: zest
    • 2 apples chopped in small pieces
  • 8 dried figs chopped
  • 50g raisins

Process:

  • Pre-heat the oven at 180C.
  • Prepare a tray and spread some butter.
  • Soak the raisins, seeds, orange and lemon zest, juice and figs in Sambuca
  • In a big pan, bring to boil the milk. Immediately add corn and flour whisking without stopping to avoid lumps. Put at low heat now!
  • If it is too thick, you can add more milk. (I think I used 1.2l milk at the end and still quite thick!!!)
  • Cook for a couple of minutes at low heat, keep whisking, don’t burn it!
    • Remove from heat and add butter, sugar, and the mix fruit with sambuca. Add walnuts.
    • Mix all well with a spoon.
    • Pour in the tray. Level it with the spoon.
    • Put in the oven for 50-60 minutes.
    • Should be brown on top and quite moist inside if you dip a knife on it. The knife shouldnt come out clean.
    • Remove from oven and let it cool down for 1h at least before trying. The polenta is very moist so it takes time to get “solid”. Next day is even better taste!

This is the result!

It wasnt as the one I tasted in Venice but still was pretty good!

ARP Storms – EVPN

We have had an issue with broadcast storms in our network. Checking the CoPP setup in the switches, we could see massive drops of ARP. This is a good link to know how to check CoPP drops in NXOS.

N9K:# show copp status
N9K# show policy-map interface control-plane | grep 'dropped [1-9]' | diff

Having so many ARP drops by CoPP is bad because very likely good ARP requests are going to be dropped.

Initially i thought it was related to ARP problems in EVPN like this link. But after taking a packet capture in a switch from an interface connected to a server, I could see that over 90% ARP traffic coming from the server was not getting a reply…. Checking in different switches, I could see the same pattern all over the place.

So why the server was making so many ARP requests?

After some time, managed to help help from a sysadmin with access to the servers so could troubleshoot the problem.

But, how do you find the process that is triggering the ARP requests? I didnt make the effort to think about it and started to search for an easy answer. This post gave me a clue.

ss does show you connections that have not yet been resolved by arp. They are in state SYN-SENT. The problem is that such a state is only held for a few seconds then the connection fails, so you may not see it. You could try rapid polling for it with

while ! ss -p state syn-sent | grep 1.1.1.100; do sleep .1; done

Somehow I couldnt see anything anything with “ss” so tried netstat as it shows you too the status of the TCP connection (I wonder what would happen is the connection was UDP instead???)

Initially I tried “netstat -a” and it was too slow to show me “SYN-SENT” status

Shame on me, I had to search how to get to show the ports quickly here:

watch netstat -ntup | grep -i syn_sent | awk '{print $4,$5,$6,$7}'

It was slow because it was trying to resolve all IPs to hostname…. :facepalm. Tha is fixed with “-n” (no-resolve)

Anyway, with the command above, finally managed to see the process that were in “SYN_SENT” state

This is not the real thing, just an example:

#  netstat -ntup | grep -i syn_sent 
tcp        0      1 192.168.1.203:35460     4.4.4.4:23              SYN_SENT    98690/telnet        
# 

We could see that the destination port was TCP 179, so something in the node was trying to talk BGP! They were “bird” processes. As the node belonged to a kubernetes cluster, we could see a calico container as CNI. Then we connected to the container and tried to check the bird config. We could see clearly the IPs that dont get ARP reply were configured there.

So in summary, basic TCP:

Very summarize, TCP is L4, then goes down to L3 IP. For getting to L2, you need to know the MAC of the IP, so that triggers the ARP request. Once the MAC is learned, it is cached for the next request. For that reason the first time you make a connection is slow (ping, traceroute, etc)

Now we need to workout why the calico/bird config is that way. Fix it to only use IPs of real BGP speakers and then verify the ARP storms stop.

Hopefully, I will learn a bit about calico.

Notes for UDP:

If I generate an UDP connection to a non-existing IP

$ nc -u 4.4.4.4 4000

netstat tells me the UDP connection is established and I can’t see anything in the ARP table for an external IP, for an internal IP (in my own network) I can see an incomplete entry. Why?

#  netstat -ntup | grep -i 4.4.4.4
udp        0      0 192.168.1.203:42653     4.4.4.4:4000            ESTABLISHED 102014/nc           
# 
#  netstat -ntup | grep -i '192.168.1.2:'
udp        0      0 192.168.1.203:44576     192.168.1.2:4000        ESTABLISHED 102369/nc           
# 
#
# arp -a
? (192.168.1.2) at <incomplete> on wlp2s0
something.mynet (192.168.1.1) at xx:xx:xx:yy:yy:zz [ether] on wlp2s0
# 

# tcpdump -i wlp2s0 host 4.4.4.4
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on wlp2s0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
23:35:45.081819 IP 192.168.1.203.50186 > 4.4.4.4.4000: UDP, length 1
23:35:45.081850 IP 192.168.1.203.50186 > 4.4.4.4.4000: UDP, length 1
23:35:46.082075 IP 192.168.1.203.50186 > 4.4.4.4.4000: UDP, length 1
23:35:47.082294 IP 192.168.1.203.50186 > 4.4.4.4.4000: UDP, length 1
23:35:48.082504 IP 192.168.1.203.50186 > 4.4.4.4.4000: UDP, length 1
^C
5 packets captured
5 packets received by filter
0 packets dropped by kernel
# 
  • UDP is stateless so we can’t have states…. so it is always going to be “established”. Basic TCP/UDP
  • When trying to open an UDP connection to an external IP, you need to “route” so my laptop knows it needs to send the UDP connection to the default gateway, so when getting to L2, the destination MAC address is not 4.4.4.4 is the default gateway MAC. BASIC ROUTING !!!! For that reason you dont see 4.4.4.4 in ARP table
    • When trying to open an UDP connection to a local IP, my laptop knows it is in the same network so it should be able to find the destination MAC address using ARP.

Blue Zones

I read this paper about “Blue Zones” regarding life expectancy and what have in common those areas. One interesting thing, checking the map, those blue zones are not in extreme weather regions and three of them are islands.

So these are the 9 points those communities have in common:

  • Move naturally (no climbing 🙁 )
  • Purpose
  • Downshift (disconnect)
  • 80% rule (dont get full)
  • Wine
  • Belong (faith, philosophy)
  • Loved one first
  • (Correct) Social network

So all those points are very nice. I like them, but they dont fit in our current cut-throat capitalism world.

Would I live in a similar community? I think I could. I would have to adapt though (technology?)

Dal

I tried Dal from this place and I was amazed. It was so good that I wanted to try and some time later I found this recipe. I failed miserably. Again I tried last week using a different recipe, that doesn’t looks like very authentic after reading others but still I went for it.

Ingredients

  • 3/4 cup of lentils put in water the night before
  • 1 can of beans (mixed, kidney, etc)
  • 1 large onion finely chopped
  • 1 tbsp garlic chopped
  • 1 tbsp ginger grated
  • 2 tbsp medium curry powder
  • ping of chilli paste.
  • 75g butter
  • 1 can full fat coconut milk
  • 1 can chopped tomatoes
  • salt, pepper
  • 150g spinach
  • 3/4 cup of rice + 1 star anise

Process:

  • Put same amount of rice and boiling water in a pan at medium heat. Put the star anise in the middle.
  • After a couple of minutes reduce to low heat the rice. Dont stir and check from time to time to avoid getting burn.
  • In a medium-heat frying pan, put half of butter, onion, garlic, ginger, curry powder and chilli paste. Cook until the onions are soft.
  • Pour the coconut milk and tomatoes, season with salt/pepper. Bring to boil and then to simmer.
  • Add beans, lentils and remaining butter. Simmer for 30 minutes or so.
  • Taste it! When ready, add the spinach and stir.
  • Ready to eat with the rice!

Spiced Banana Bread

Ingredients:

  • 3 wheat biscuits, crumbled (aprox 50gr)
  • 100gr sultanas or prunes
  • 150ml milk
  • 250gr dark brown sugar
  • 2 large free range eggs
  • 2 large ripe bananas mashed
  • 120g butter melted
  • 150g self-raising flour
  • 1 tsp bicarbonate of soda
  • 1 tsb ground cinnamon
  • 1 tsb groud ginger

Process:

  • Pre-heat oven at 170C.
  • Prepare a loaf tin and grease it with a bit of butter.
  • In a bowl, mix the wheat biscuits, milk and sultanas. Set aside.
  • In another bowl, whisk sugar and eggs until pale.
  • Then add banana, butter, flour, bicarbonate, cinnamon and ginger. Mix well.
  • Then add to the banana mix, the wheat mix. Mix properly with a spoon.
  • Pour the mix into the tin. Bake for 1h or until top is golden and a skewer inserted in the center comes out clean.
  • Let it cool down in a rack.

Very tasty and moist (although the pic is not great…) cake. It is super quick to do too.

Lemon Tart

Pastry Ingredients:

  • 175g plain flour
  • 100g cold butter in small cubes
  • 25g icing sugar
  • 1 egg yolk + pinch salt
  • 1 tbsp cold water

Filling Ingredients:

  • 125ml free range eggs (2.5 eggs aprox)
  • 62.5ml double cream
  • 112gr caster sugar
  • Juice of 2 lemons (do a syrup with the zest)
  • icing sugar for dusting

Process

  • Start with the pastry. Rub the flour, butter and icing sugar until you get something like breadcrumbs. You shouldn’t have lumps of butter. Tip the bowl and check the surface.
  • Add the egg yolk and cold water. Form a dough, flat it a bit and wrap in cling film. Rest in fridge for 1h.
  • Pre-heat oven at 220C. Prepare a try with baking paper (just to cover the tin!) and the tin on it. The tin can be from 16 to 20cm diameter. The dough will cover all.
  • Take the pastry out of the fridge. With your fingers, bend the edges of the pastry as they will be hard due to the butter.
  • In a lightly dusted surface, roll the pastry with a pin. Add flour to the pin not the dough. Roll until you have 0.5cm thick (or so). Clean excess of flour.
  • Roll the dough with the pin and then lay it over the tin. Gently push the pastry into the tin with your fingers. Be sure there are not air pockets between the tin and the pastry.
  • Trim the top excess with the rolling pin. Then with your thumbs be sure the side of the tin are the same thickness with dough everywhere. Dont make it too thin!
  • With a knife, trim the top, be sure that cut is even.
  • With your thumbs nail, go through the top an separate a bit the pastry from the tin.
  • With cling film or baking paper, cover the pastry. Then fill the pastry with rice, beans or similar. Be sure it is properly full.
  • Bake for 20 minutes at 175C. Be sure the edges are golden brown.
  • Remove beans/rice and bake for 5-10 minutes until bottom is baked.
  • Remove from oven and leave to cool down.
  • Leave the oven at 120C
  • Prepare lemon filling. In a bowl, whisk sugar and lemon juice.
  • Add the eggs, mix with a spoon. DONT WHISK! You dont want bubbles.
  • Pour the cream and keep mixing with the spoon.
  • Pass the lemon mix through a strainer so the mix is super smooth and there are not bits of anything. You can taste it 🙂
  • Put the lemon in the mix if the base is not cool down.
  • Once the base is ready, put the tray half way in the oven so you can pour the lemon filling. Stir the filling before pouring if it was in the fridge!!!!
  • Pour slowly the filling, until it nearly reaches the top.
  • Bake for 25 minutes aprox at 120C.
  • Be sure the filling is set, just a slight wobble in the center, before removing from oven.
  • Let it rest for 15 minutes, remove the tin.
  • Dust the top with icing sugar.

This is the result!

Still the edges are not even…. but it is tasty 🙂

Stock Syrup:

  • 50% water
  • 50% sugar

Process

  • Mix water and sugar. Then heat until boil.
  • Add the lemon peel or any fruit peel you dont want to through away.
  • Let it at low heat for 30 minutes.
  • Remove from heat.
  • You can taste the syrup and even the peels!

Broccoli Peanut Stew

Watched this video and I liked the broccoli dish so I tried!

Ingredients:

  • 2/3 cup of chopped peanuts (any nuts to be honest)
  • 1 big broccoli
  • 8-9 garlic cloves.
  • Optiona: 1 can of chickpeas.
  • 25ml soy sauce aprox
  • 2 tsp of chilli sauce
  • 1 tsp of corn flour
  • 1 cup of couscous.

Process:

  • Chop the nuts
  • Chop the broccoli head. Put apart
  • Chop the broccoli stalks. Put apart (nothing wasted!)
  • Chop the garlic cloves.
  • Boil a cup of water.
  • Add the cup of water to the couscous and put apart. You can add some mint, butter, etc.
  • In a small bowl, mix the soy sauce, chilli sauce and corn flour. Put apart
  • In a big pan, at medium heat. Add a gulp of olive oil.
  • Add the garlic, saute for a bit.
  • Add the broccoli stalks. Cook for a bit.
  • Optional, add the chickpeas.
  • Add the broccoli floretees and the soy mix.
  • Cook for 5 minutes.
  • Add the nuts and mix for a bit.
  • Taste it, broccoli should be crunchy!

Ready to serve!

My broccoli was quite dark because I used dark soy sauce.

To be honest quite easy recipe, and tasty!

Eclairs

Pastry Cream (creme patissiere) Ingredients

  • 250ml milk
  • 1 egg
  • 2 yolks
  • 62g caster sugar
  • 37g plain flour
  • 8g butter
  • 1/2 tsp vanilla paste

Process:

  • In a sauce pan, put the milk until boil. Pour a bit of sugar and dont stir!!!
  • In a bowl, mix egg, yolks, sugar and vanilla until smooth. Then add flour.
  • Add the boiling milk gradually to the egg mix. Whisk properly.
  • Return the mix to the heat. Stir until thickens. Dont stop stirring! You should see bubbles.
  • Remove from heat and add the butter. Mix properly.
  • In a clean tray, pour the mix, wrap with cling film and let it rest in the fridge.

Chox pastry Ingredients

  • 250ml water
  • 100g butter in cubes
  • 150g plain flour
  • 4 eggs
  • 1 tsp sugar
  • 1 tsp salt

Process:

  • In a saucepan, heat the water until boil. Add sugar and salt.
  • Melt the butter in the boiling water.
  • Remove the pan from the heat and add the flour. Whish properly and return to the heat.
  • Keep stirring the mix until if stops sticking to the pan. Be sure is properly cooked the flour.
  • Spread the mix in a cold surface to cool down a bit.
  • Using the back of a tray, wash it with a bit of melted butter and then dust some flour. Smack the tray in a side so the excess flour falls. You should have a neat unti-stick proof tray.
  • With a block of butter, pinch it with your thumb and index finger. Your index finger should touch the edge of the tray. Use this method to make a straight line in each side of the tray.
  • Beat the 4 eggs.
  • Pre-heat oven at 190C
  • Take the dough back into a bowl. This is a critical point! Add a bit of egg at each time. You should stop adding egg once you can create a solid “V” when dropping a big dollop of the mix with the spoon 2-3 times in a row. Maybe you need to bit an extra egg or dont need to add the 4 eggs. So keep it in mind.
  • Prepare a piping bag. Twist the bag with a finger, fold the bag around half and add the mix. Tight the bag carefully, twisting it. Hands on the bottom.
  • Over the tray where you made the two vertical lines, pipe in each side a small line between the edge of the tray and the vertical line. Leave space between each eclair as they will raise.
  • With a fork, dip it in egg wash, an score the top of each eclair length way
  • Bake for 35 minutes, they should raise and be golden brown. Then drop to 120C for a couple of minutes before removing from the oven.
  • Let the eclairs to cool down in a racket.
  • Take the cream from the fridge, put it back in a bowl and whisk until became a cream again.
  • Prepare a new piping bag. As usual, use the index finger to twist the bag, fold until half and then pour the cream. Tight the bag twisting carefully.
  • Once the eclairs are cold. Using a small knife, on the bottom of the eclair, make two holes in each edge. You will pipe the cream through those holes:

  • Be sure the tip of the piping bag is big enough to fit in the hole. If the tip is too small, is very likely the piping bag will break.
  • Once piping, you need to feel the eclair filling and become heavy. Try to pipe through both holes.

Chocolate Foundant Ingredients:

  • 100g of dark cooking chocolate (at least 65% cocoa)
  • Sugar glass for decoration

Process:

  • Melt the chocolate using bain-marie.
  • Dip the top of the eclairs in the melted chocolate. Use your thumb and index fingers. Try to dip just a third of the eclair. Till the eclair so the chocolate drops by one side and then with a finger smooth the chocolate run so it stops and looks smooth.
  • Let the eclairs rest until the chocolate settles.
  • Powder a bit of sugar glass on top of the dry chocolate.

Ready to eat!

They were tasty and not bad for the first time. The pastry didnt raise much to be honest. It seems the oven needs a bit of steam for that.

Chocolate Tart

Pastry Ingredients:

  • 175g plain flour
  • 100g cold butter in small cubes
  • 25g icing sugar
  • 1 egg yolk + pinch salt
  • 1 tbsp cold water

Filling Ingredients:

  • 200g dark chocolate finely chopped (min 60% cocoa solids)
  • 75ml full fat milk
  • 125ml whipping cream
  • 1 egg lightly beaten

Process

  • Start with the pastry. Rub the flour, butter and icing sugar until you get like breadcrumbs. You shouldn’t have lumps of butter. Tip the bowl and check the surface.
  • Add the egg yolk and cold water. Form a dough, flat it a bit and wrap in cling film. Rest in fridge for 1h.
  • Pre-heat oven at 220C. Prepare a try with baking paper and the tin on it. The tin can be from 20-28cm. The dough will cover all.
  • Take the pastry out of the fridge. With your fingers, bend the edges of the pastry as they will be hard due to the butter.
  • In a lightly dusted surface, roll the pastry with a pin. Add flour to the pin not the dough. Roll until you have 0.5cm thick (or so). Clean excess of flour.
  • Roll the dough with the pin and then lay it over the tin. Gently push the pastry into the tin with your fingers. Be sure there are not air pockets between the tin and the pastry.
  • Trim the top excess with the rolling pin. Then with your thumbs be sure the side of the tin are the same thickness with dough everywhere. Dont make it too thin!
  • With a knife, trim the top, be sure that cut is even. Again with the edge of the knife, go through the top an separate a bit the pastry from the tin.
  • With cling film or baking paper, cover the pastry. Then fill the pastry with rice, beans or similar. Be sure it is properly full.
  • Bake for 15 minutes at 175C. Be sure the edges are golden brown.
  • Remove beans/rice and bake for 5-10 minutes until bottom is baked.
  • Remove from oven and leave to cool down.
  • Prepare chocolate filling. Melt the chocolate using bain-marie.
  • In another bowl, heat the milk and cream until boil.
  • Pour the milk mix on to the chocolate. Whisk well until you have a smooth, glossy mix. Then add the egg and mix.
  • Pour the chocolate mix into the tart and bake at 175C for 20-25m.
  • It is ready when you tip the tart and the center hardly move. As well, the chocolate filling will raise a bit. Dont over bake it, the chocolate will break.
  • Let it rest for 10 minutes until the chocolate is even with the tart. Remove the tin.
  • Dust the top with icing sugar.

“Vuala”!

It was tasty. Although my “edges” were not great.