Summary
Stuff I getted asked about on interviews. It’s a compilation of things I learned across talking to many folks about paying me to do what I find interesting and am passionate about. I can never directly thank these people stumping me and prompting me to keep on learning and growing and getting better … THANK YOU !!!
TODOs
There are no “TODOs” I can think of on 01APR2019MON:
- One
Networking
Never ever have I talked with somebody and not had an exciting conversation about the various “network models” and “name the protocol” 🙂
Protocols
ICMP is a control protocol, meaning that it designed to not carry application data, but rather information about the status of the network itself. The best known example of ICMP in practice is the ping utility, that uses ICMP to probe remote hosts for responsiveness and overall round-trip time of the probe messages.
Both Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are transportation protocols, they are used to pass the actual data. The main difference between TCP and UDP is that TCP is a connection oriented protocol, it guarantees that all sent packets will reach the destination in the correct order.
UDP, on the other hand, is a connection-less protocol. Communication is datagram oriented, so the integrity is guaranteed only on the single datagram. Datagrams reach destination and can arrive out of order or don’t arrive at all. It’s generally used for real time communication, where a little percentage of packet loss rate is preferable to the overhead of a TCP connection.
Internet protocol suite
Application layer
BGP DHCP DNS FTP HTTP HTTPS IMAP LDAP MGCP MQTT NNTP NTP POP ONC/RPC RTP RTSP RIP SIP SMTP SNMP SSH Telnet TLS/SSL XMPP more…
Transport layer
TCP UDP DCCP SCTP RSVP more…
Internet layer
IP IPv4 IPv6 ICMP ICMPv6 ECN IGMP IPsec more…
Link layer
ARP NDP OSPF Tunnels L2TP PPP MAC Ethernet Wi-Fi DSL ISDN FDDI
ICMP
Internet Control Message Protocol
- ping
UDP
User Datagram Protocol
- Domain Name System (DNS)
- Simple Network Management Protocol (SNMP)
- Routing Information Protocol (RIP)
- Dynamic Host Configuration Protocol (DHCP)
TCP
Transmission Control Protocol
- World Wide Web (WWW)
- File Transfer Protocol
- Secure Shell
- peer-to-peer file sharing
- streaming media
Classless Inter Domain Routing
CIDR – Classless Inter Domain Routing
Classless InterDomain Routing (CIDR) was invented to keep the Internet from running out of IP Addresses. The use of a CIDR notated address can easily represent classful addresses (Class A = /8, Class B = /16, and Class C = /24).
Private Addresses
There exist “ranges” of IP addresses that are reserved and you should know them in case you’re debugging stuff and you see for instance 192.168.1.100 which can’t be a “service on the web”.
| RFC1918 name | IP address range | number of addresses | largest CIDR block (subnet mask) | host id size | mask bits | classful description |
|---|---|---|---|---|---|---|
| 24-bit block | 10.0.0.0 – 10.255.255.255 | 16,777,216 | 10.0.0.0/8 (255.0.0.0) | 24 bits | 8 bits | single class A network |
| 20-bit block | 172.16.0.0 – 172.31.255.255 | 1,048,576 | 172.16.0.0/12 (255.240.0.0) | 20 bits | 12 bits | 16 contiguous class B networks |
| 16-bit block | 192.168.0.0 – 192.168.255.255 | 65,536 | 192.168.0.0/16 (255.255.0.0) | 16 bits | 16 bits | 256 contiguous class C networks |
Should you be so inclined you can use sipcalc (will probably have to install) to generate the ranges of IPs above like:
sipcalc 10.0.0.0/8 sipcalc 172.16.0.0/12 sipcalc 192.168.0.0/16
In April 2012, IANA allocated 100.64.0.0/10 for use in dedicated carrier-grade NAT scenarios.
Personally I think “localhost” (“home”) at 127.0.0.1 is private. Actually, any IPv4 address in 127.0.0.0/8 is a loopback address.
Additionally .0 (network space) and .255 (broadcast address) can’t be used. It’s slight more complicated and “addresses ending in 0 or 255” goes into greater detail.
And finally there is a largish set of addresses considered “special-use addresses“.
Linux
Load
Never ever have I talked with somebody and not had an exciting conversation about “load average” 🙂
Put very simply if you “magically” had all available CPU[s] 100% running process[es] (one process per CPU) and nothing else was wanting/needing those CPU[s] (unlikely but go with me here) then “load would equal the number of CPU[s]“.
Let’s make this real easy and forget the “average” part. It’s over 1, 5 and 15 minutes and uses a gnarly formula “exponentially damped/weighted moving average”1 and it doesn’t matter for the explanation.
Simply put “load” is “number of processes using or wanting to use the CPU[s]”. More specifically here are the possible “CPU states” (from man top search on Process Status) and the first three highlighted count towards “load”:
- D = uninterruptible sleep
- I = idle
- R = running
- S = sleeping
- T = stopped by job control signal
- t = stopped by debugger during trace
- Z = zombie
Here’s a link2 that shows the addition of “the origin of uninterruptible”.
The OS computes it and iterally stores it in file /proc/loadavg. man 5 proc and search on (go figure) /proc/loadavg for details.
By the way an easy way to get the number of CPUs is nproc. There are a bunch of other ways that a web search on linux number of cpu will be helpful.
Servers In Virtualized Environments
Fundamentals Of Scripting Languages
Boot Process
I definitely would not use this as the “end all of knowledge” for this. I use this to review stuff before I interview.
By the way this is found at man bootup 7 but it’s not the easiest to decipher in my opinion.
Here’s the basics3:
- BIOS POST (Basic I/O System – Power On Self Test)
- MBR (Master Boot Record) – 512 byte
- GRUB2 – loads the selected kernel into memory and turns control of the computer over to the kernel
- kernel
- systemd – responsible for bringing the Linux host up to a state in which productive work can be done
- runlevel
And more on runlevels … I would seriously do more research on this topic but:
| Runlevel | Target Units | Description |
|---|---|---|
| 0 | runlevel0.target, poweroff.target | Shut down and power off the system. |
| 1 | runlevel1.target, rescue.target | Set up a rescue shell. |
| 2 | runlevel2.target, multi-user.target | Set up a non-graphical multi-user system. |
| 3 | runlevel3.target, multi-user.target | Set up a non-graphical multi-user system. |
| 4 | runlevel4.target, multi-user.target | Set up a non-graphical multi-user system. |
| 5 | runlevel5.target, graphical.target | Set up a graphical multi-user system. |
| 6 | runlevel6.target, reboot.target | Shut down and reboot the system. |
[text]
Traditional runlevel New target name Symbolically linked to…
Runlevel 0 | runlevel0.target -> poweroff.target
Runlevel 1 | runlevel1.target -> rescue.target
Runlevel 2 | runlevel2.target -> multi-user.target
Runlevel 3 | runlevel3.target -> multi-user.target
Runlevel 4 | runlevel4.target -> multi-user.target
Runlevel 5 | runlevel5.target -> graphical.target
Runlevel 6 | runlevel6.target -> reboot.target
[/text]
| SystemV Runlevel | systemd target | systemd target aliases | Description |
|---|---|---|---|
| halt.target | Halts the system without powering it down. | ||
| 0 | poweroff.target | runlevel0.target | Halts the system and turns the power off. |
| S | emergency.target | Single user mode. No services are running; filesystems are not mounted. This is the most basic level of operation with only an emergency shell running on the main console for the user to interact with the system. | |
| 1 | rescue.target | runlevel1.target | A base system including mounting the filesystems with only the most basic services running and a rescue shell on the main console. |
| 2 | runlevel2.target | Multiuser, without NFS but all other non-GUI services running. | |
| 3 | multi-user.target | runlevel3.target | All services running but command line interface (CLI) only. |
| 4 | runlevel4.target | Unused. | |
| 5 | graphical.target | runlevel5.target | multi-user with a GUI. |
| 6 | reboot.target | runlevel6.target | Reboot |
| default.target | This target is always aliased with a symbolic link to either multi-user.target or graphical.target. systemd always uses the default.target to start the system. The default.target should never be aliased to halt.target, poweroff.target, or reboot.target. |
Some quick commands worth having fresh:
## display the default target unit systemctl get-default ## list all currently loaded target units systemctl list-units --type target
Problem Diagnosis
Installing Configuring Maintaining Services
I think I need to restructure this section but for now …
There are many services that can do Layer 4 load balancing: Nginx/Nginx Plus, HAProxy, and the one we’ll look at today, IPVS.
Apache
MySQL
Nginx
SNMP
Network Tools
Iptables
IPVS
HAProxy
Build And Monitor Services On Production Servers
Print Friendly
Subversion
$Id: code-stuff.txt 4075 2019-04-02 13:06:52Z hoopchuk $