DevOps Prerequisites Course - Getting started with DevOps

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to the DevOps prerequisite course the one course that you must go through before starting your DevOps or cloud journey my name is Muhammad Muhammad and I will be your instructor for this course students who are absolute beginners and are totally new to IT or the cloud and DevOps world requires some additional help in starting their journey for example they often run into issues with setting up a basic lab environment using VirtualBox or issues with configuring the right kind of networking in VirtualBox or trouble with working with the Linux CLI or text editors like VI editor and sometimes it's trouble with getting a web server to communicate with a database server or at other times it's working with data formats like JSON or e mo so we have identified a gap and we believe that this is because they are missing some of the basic prerequisites as a DevOps or cloud engineer it is important to have these basics cleared and that's why we built this course to bridge that gap this course helps you get your basics right so the rest of the journey is smooth now you might be wondering whether you have the background or the experience to get started and I want to assure you that this course is really for anyone who wants to start their DevOps or cloud journey even if you're from a non IT background or you don't have a computer science degree or if you are a college student who has no work experience and wants to start your DevOps or cloud journey this course is also for those who happen to have some experience such as developers who wants to learn a little bit about operations in order to move to a DevOps role so no coding or programming knowledge required so how does it work with visual learning we simplify complex concepts using illustrations and animations and we have demos where we show you how to put these into practice we have hands-on labs that open up right in your browser where we have pre-configured environments for you to practice with our labs are fun and interactive and hassle-free you don't need to do anything to get them to work they just work right in your browser you'll learn by exploring real environments and solving puzzles and you'll troubleshoot and fix broken environments and we will always verify your work and we'll give you feedback on what went wrong at any time you feel stuck we have a community where you can get help so let's get started and I will see you in the next video so let's take a closer look at the objectives of this course remember that this is a DevOps and cloud prerequisites course so this is the course that comes before you start an actual DevOps course and since we cover a lot of concepts we will cover just enough of each topic so you have a fair idea about that topic as well as get some cancel and experience in the first section we start with the basics of Linux where you go through and understand basic commands in the Linux CLI you'll learn how to work with the VI editor as it's important to be comfortable with at least one text editor in Linux you'll use this when you work with files in Linux such as configuration files we then look at how to install software and dependencies in Linux and then we will see what our services and how to configure them at times you may want to set up your own personal lab environment an environment where your changes are saved and an environment where you can develop your own custom solutions and this section will help you create your own lab as well as troubleshoot and maintain it which is something that most students struggle with especially the networking part in worship box and we have some neat lectures and demos that explain those another area that students usually struggle is with networking in Linux how our interfaces and IP address is configured why can't I get a VM to reach the internet or multiple VMs to ping each other how do I configure routing what is DNS and how do I configure the right DNS settings and how do I troubleshoot DNS related issues and we covered these along with labs in this section we also look at some of the commonly used data structure languages like JSON and mo automation tools like ansible use llamo to develop playbooks and docker and kubernetes use it for building definition files so we have a lot of fun challenges that will help you practice this well let's get started when you're ready in this section we'll go through some of the basics of linux command line if you're already as linux maestro then feel free to skip this section or simply go through the labs and try to complete the challenges and make sure you're comfortable with all of them while designing this course we used stack overflows in sites along with the data from service we conducted from our student base and which you might have seen in our other courses to identify the most commonly used and most demanding technologies that we will cover in this course that way we can make this course relevant to most of you so you'll see me referring to these often and I hope learning the most loved and wandered technologies will motivate you as per stack overflows insights the most common and the most loved platform used for development work happens to be Linux if you are from a Windows background I'd highly recommend learning some Linux basics as most DevOps tools have a requirement for Linux as part of this course we cover basics of Linux OS such as how to work with the command line interface how to work with text editors like VI editor we discuss package management and services etc there are different flavors of Linux such as Ubuntu Red Hat Enterprise Linux CentOS etc we conducted a survey of our students and a good percentage of them requested their preferred OS to be CentOS followed by Ubuntu and Red Hat Enterprise Linux CentOS is a free community edition of Red Hat Enterprise Linux so learning Central's also helps you cover the basics of RHEL Learning Centres will also help you prepare for Linux certifications like Linux essentials or Linux foundations certified systems administrator certification now since you also cover a basics of Red Hat Enterprise Linux it also helps you prepare for any Red Hat exams and that's why we decided that CentOS is going to be the OS of our choice for this course so let us begin our Linux crash course in this section you're going to work with Linux systems in our lab this is so you get very familiar with the Linux CLI and some basic commands before you actually deploy a Linux system by yourself the next section is about deploying a Linux system on your Linux laptop using tools like VirtualBox when you do that the CLI and commands you learn in this section will be handy so I recommend not deploying your own Linux system for now instead just rely on our labs and get some good hands-on practice and then in the next section deploy your own VMs so we will start assuming a Linux system has already been provisioned let's start with Shell Linux systems have both CLI and GUI interfaces when you work with Linux especially in IT you work with the CLI and you must get really comfortable with it because most servers that you work with in your work environment won't really have a graphical user interface so we will just focus on the command line the text-based command line interface that helps you run commands to interact with the operating system is called the Linux shell if you have ever worked on a Linux system before you might have noticed that sometimes the CLI interface behaves differently as in sometimes you press the backspace button to delete a command and it doesn't work or when you press the tab button to autocomplete it doesn't autocomplete and that's because there are different kinds of shells such as the bourne shell the c shell c shell bourne-again shell which is known as bash and each of these shells behave differently the older shell which is the bourne shell or simply known as shell had limitations in the way we interact with it the newer bash shell supports many advanced features such as arithmetic operations conditionals arrays etc you can see which shell you are on by printing the environment variable name shell using the echo dollar shell command the echo command helps you print on the screen and the dollar symbol helps you specify an environment variable let's now get introduced to some basic Linux commands we will first look at the commands and you will then work on labs where you will use these commands echo as we just discussed is the command used to print a line of text the word you enter after the echo command will be printed on your screen as simple as that the echo command is usually used when you want to print out an environment variable as we just saw we will discuss about environment variables later the echo command is also used in scripts where you want to print out information onto screen the LS command is used to list all the contents of a directory here we see that we have two files file dot txt and file to conf and a directory named my underscore dir one the CD command stands for change directory and it is used to navigate to new directories in the system for example to get into the my underscore dir one directory run the command CD followed by the directory name the PWD command or the present working directory command is used to print the directory you are currently in the mkdir or the make directory command is used to create a new directory in this example we've created a new directory called new underscore directory to run multiple commands one after the other separate them by a semicolon in this case it first changes into the new directory then makes a directory by the name www and then prints the current working directory now even though it's a single execution remember there are three separate commands and executed one after the other at times you might want to create a directory tree for example we want to create a directory slash TMP slash Asia slash India slash Bangalore one way to do that is to run the make directory command three times specifying one directory each time for example first we create the first directory and then we create the India directory in inside Asia and then we create the Bangalore directory inside India a better way to do that would be to run a single command using the - P option like this this way it creates the entire directory tree in one shot and does not complain if a particular directory is not available to remove a directory and all of its contents run the RM - or command and specify the directory name to copy one directory to another location use the CP command but with the - R option this copies the directory and all of its contents from one location to another let's see some commands to work with files to create a new file run the touch command and provide the file name this creates a new file but with no contents to add some contents to the file use the cat command and the redirection symbol which looks like a forward arrow followed by the file name once this command is issued the prompt will wait for your user input you would be able to add lines of text hit the return key to typing into a new line of text and press the ctrl D combination to exit out of this prompt and save the data to the file to view the contents of a file run the cat command followed by the file name this time without the redirection symbol these are some basic commands to work with files in the CLI for editing contents of a file you may need a text editor like VI or vim we also take a look at the basics of VI editor later in this course now while working with DevOps tools you often come across situations where you will have to modify configuration files on Linux and these editors will come handy then but to get through this lecture and the following labs you don't really need a text editor so let's continue to copy a file use the CP command and specify the source file path and name and the target path and name to move a file which is similar to cutting and pasting a file to a different location use the MV command specify the old name and the new path and the file name if the file is moved to the same path but with a different name then is essentially like renaming the file and that is how you rename a file in Linux there's no separate command for that run the RM command to remove or delete a file so that's about it for this section head over to the labs and practice working with these basic Linux commands let me quickly introduce you to the hands-on labs in this course the lab interface is divided into two sections here you have a terminal which is a live terminal to a Linux host and here you have a quiz portal it takes a few minutes for the labs to load so just give it some time if you need more space for your lab click on this button here to hide the curriculum window that way you can get a more space for your lab so we'll just wait for it to load okay so the lab is loaded and I'm on the Linux terminal here and this is my quiz portal in the quiz portal I have various tasks that I am expected to complete the tasks are of two kinds first we have exploratory questions which are these where we ask you to explore the environment and and select the right answers from these options let me walk you through a few of these questions in this case this is a multiple-choice question so here you have a question and here you have some options who you're supposed to select the right option in case you are not sure how to find the answer to that question we have some hints so clicking on this will tell you exactly what you need to do it will give you the command that you need to run or hint to find the right solution we also have a timer so these labs are available for an hour each time so you can access these labs as many times as you want but each time there's a time limit like sits in an hour and this lab session also has a number of questions and you can see the question numbers here currently we are on the first question and this lab has a total of 10 questions you can also skip through questions in case you go through five questions and then for some reason you had to stop or for some reason the lab terminates in that case you can restart the lab and then you can skip through the questions so let's start with let me show you a few examples in this case we have the question is how many directories and files are present in the home Thor test directory so we go to that particular directory here okay and then we list the contents and we see that there are three directories and then three files okay so the correct answer is three directories and three files and that's correct next the question is which text file is not present under the Home Tour directory so we know that there is files one two and four so three is not is the correct answer but let's say you pick the wrong answer and then it's going to tell you that it's wrong so you must select the correct answer and the next question is to create its now this is a task so this is the second type of question which is not a multiple choice question so here you have to perform the tasks that you're asked to do and if you don't do it and it's going to check your work and it's going to tell you that the task is not completed so in this case we have to create a file under the Home Tour directory so we use the touch command and we create the file you can always refer to the the course material the PDF to get the correct answer or you can refer to the hint so here I create an empty file using the touch command when I check it's successful okay so these are very basic labs and as and when you go through the course the difficulty will increase and you'll have more and more complex tasks and challenges to complete now for some reason if you would like to open a new terminal here there are some options so if you click on the plus button and click on open your terminal then you can get a new terminal window so here I have the old terminal and here I have the new one and if you are at some point in time we will be hosting web servers and if you would like to access the URL of the server then you have to click these links and that way it'll open up a new browser and it will forward your request to the host what you're accessing is at Terminal two every mode server I hope you enjoy your learning let us now look at some more Linux commands that will help you get through this course we will start with user accounts to know which user you are run the Who am I I command in this case it says you are user Matthew the ID command gives you more information about the user such as the users ID which happens to be one zero zero one and the group ID and the groups that the user is part of to switch from one user to another you may use the SU command su stands for switch user to switch to user say a Poorna run the SU command followed by the user's name you will then be prompted for the user's password if you're accessing one system from another system using se SSH and you want to log in to the other system using a different user than your current user specify the user name before the host name followed by an @ symbol when it comes to performing tasks not all users can do all tasks in Linux Mathieu is a regular user and so his access on the system is restricted every Linux system has a super user known as the root user the root user has no restrictions on the system and can perform any task which is why in most production environments or enterprise environments access to the root user is restricted and you will almost never login to the systems as a root user now as a normal user what if you wish to perform actions that can only be performed by a root user such as installing and configuring software and services on the system or viewing certain paths such as the root directory a root user can make that possible for a regular user by granting them sudo privileges by making an entry into the Etsy sudoers file so the user is still a regular user but with root privileges when a regular user is granted sudo privilege they can now elevate their permission level and perform tasks that they otherwise couldn't by simply prefixing a command with the keyword pseudo they'll be asked for their password and on entering the password the command is executed when you look through the labs in the rest of this course you'll work in an environment where you will not have root access instead you will be a regular user with sudo privileges so while making changes to the system you must remember to use the sudo prefix if not you will get permission denied errors so whenever you hit permission denied errors remember that it could be because you haven't used these pseudo prefix we will be discussing about a lot of commands through the rest of this course and for the sake of brevity we won't be specifying the sudo prefix each time on all our slides so it is assumed that you will use this prefix while working in the labs let us now look at some commands that will help us download files from the internet at times you will have to download files from the internet such as RPM packages or binary files or images and you can use use the Col command and provide the URL of the file to download the file add the dash capital o option to save the result to a file otherwise it'll just print the file on screen another tool that can be used to download files is the W get command again specify the full URL and with the dash capital o options specify the name of the file that you want it to store locally as at times you may be on a Linux system and may not know what operating system you are on to know the current OS inspect the release files under the Etsy directory the release files may be named differently based on the operating system so use a wild-card like this to see more details about the OS view these files by running the cat command and you can see that in this case it's CentOS version 7 let's not talk about package managers in Linux package managers help you install various software on the Linux system and when you go through DevOps and cloud courses you will install various software such as web servers database servers and DevOps tools or dependent software's and most of these are installed using package managers CentOS uses an RPM based package manager just like Red Hat and press Linux or Fedora rpm stands for red hat package manager a software is packaged into a bundle with the extension Tod RPM to install the package use the RPM command and the - i option for install and specify the package name - uninstall a package use the - e option and to query the database and get details about an installed package use the - cue option so rpm requires you to point it to the exact location where the RPM package is available you then install that package on the system it does not care about any dependencies that this package may have for example say you were installing another software like ansible and it requires python and other other dependent software so simply installing ansible with the RPM command would not take care of installing python and other dependent libraries if they are all not already installed and that's why you need a solution that can make these easy for you a single command that can query the package find its location and install all dependencies as well as the package itself that's where package managers like yum come into play yum is a high level package manager that uses RPM underneath running a simple yum install ansible command installs ansible and all of its dependent packages yum searches software repositories that act as warehouses containing hundreds and thousands of RPM package files these repositories can be local that is installed on your laptop for example or on a remote location either a secure server in your enterprise or available publicly in the Internet under the hoods yum still makes use of the RPM package manager so when you try to install a package using yum yum searches these repositories finds the required packages and dependencies and installs all of them in the right order so what is this remote repository and how our packages stored there like how does yum find where a particular package is located the information about the repository in a configuration file at path slash Etsy / yum repose dot d directory every operating system comes bundled with its own set of repositories from which you can install a lot of commonly used software and tools so you might not need to edit the list of repositories but at times the default set of repositories may not have the software you need or may not have the latest version of software that you need to install so in that case you will need to configure additional repositories so that yum can find those packages instructions to configure additional repositories are usually made available along with the software itself and we'll see an example of that so to see the list of repositories available on a system run the young rapid list command and here we see that there are a set of CentOS repositories such as the base and extra repository as well as MongoDB and MySQL ones so listing the files under the Etsy MDOT riposte directory shows the files where these repositories are configured and if you look inside one of these files you will see the URL of the location where all packages are stored now if you visit this URL you can see the RPM files that yum will eventually download and install on your local system with the RPM utility so that's kind of how young finds a package in this case since we are relying on an existing yum repo on CentOS it takes us to an older version of ansible which happens to be version 2.4 although the latest version as of this recording is 2.9 so as I just mentioned the instructions to configure the repo to install the latest version of ansible is available in the ansible documentation page itself so you can configure a new report using the yum install command itself and running this command adds a new repository to your system which points to the latest version of ansible to see a list of installed or available packages run the yum list command and followed by the package name if you want to search for its particular package it provides the package name and version and if it's an installed package or just an available package to remove an installed package run the yum remove command followed by the package name and to list all available versions of a package run the young list command but this time with the show duplicates option so here we see two versions of packages for ansible and we can see that each of these are from two separate repositories one is from the extras repository and the other is from the EPL repository to install a specific version of a package run the yum install command with the package name followed by a hyphen and the version of the package let's now talk about services in Linux once you install a software on servers especially those that run in the background such as web servers or database servers you would need to make sure that those servers or services are running and that they stay running even after the servers are rebooted so services in Linux help you configure software to run in the background and make sure that they run all the time automatically when servers are rebooted as well as they follow the right order of startup when any software that runs as a service in the background is installed such as a web server or database server or devops tools like docker they're automatically configured as a service on the system to start that service you run the service start command and providing the service name which happens to be in this case httpd the newer method to start a service is to use the system cuddle command and run the system cuddle start command and provide the service name so in this case system cuddle or systemctl start httpd system cuddle is the command used to manage services on a system the managed server both the commands at the service command and the system cuddle command serve the same purpose the service command uses the system cuddle utility underneath so we will just focus on using the system cuddle command for the remainder of this lecture to stop a running service run the system cuddle stop command followed by the service name to check the status of a service run the system cuddle status command to configure a service to start automatically when the system boots up run the system cuddle enable command and to disable the service at boot up run the system cuddle disabled command once services are configured it is so convenient for administrators to start job or enable these services you don't have to go looking for the executables to start these services so how do you configure a program or software as a service say for example you have a simple Python program it could be a simple web server that's developed in Python and the code is available at opt code my ab dot py you can run this server with the Python interpreter once it's running if you call the local host for port 5000 you see it return hello world which happens to be the response of the web server now I want to configure this as a service now so you want your program to run as a service so that when you run the system kuddle start command it starts and when you run the system cuddles stop command it stops and similarly you want to configure your application to automatically start when the system boots up and you know even automatically restart in case the application crashes how do you do that as we just saw the system cuddle command-line utility is used to manage the system these services so we must configure our program as a system de service so how do we do that a system DS service is configured using a system D unit file these files may be located at Etsy system D slash system path so let's create a unit file at Etsy system D system path the file must be named with the name that you eventually want the service to be known as in this case we'll name it my app and with an extension dot service define a section called service using the square brackets and inside the file and provide a directive named exact start under it this is where you specify the command that you will be using to run your application so the same command that we run here we're going to put it over here and that's it that's enough to configure your application as a service run the system cuddle daemon reload command to let system D know that there is a new service configured and then run the system cuddle start command and provide the name of the service in this case my underscore app let's check the status of the new service using the system cuddle status command it lists that the service is in an active and running state you can now test by performing a coal operation on port 5000 of localhost to stop the application run the system cuddle stop command okay so we have configured our application to run as a service and we are now able to start and stop it as required so how do we configure it to automatically run when the system boots up we configure that in the unit file and the unit configuration file has many other options and the service section is only one of the many sections another section is the install section so in this section we basically need to configure this service to run after a particular service that runs at boot up so one way to specify that is using the wanted by directive we can configure this service to run after the multi-user target run level is started once this is done you can configure the service to start during boot up using the system cuddle enable command you can also provide additional metadata information about the service such as description that would allow others to understand what this service is about now for that add a new section in the file called unit and use the description directive if your application has other dependencies such as commands or scripts that are to be run before starting the application or after starting the application then add the exact start pre and exact start post directives and specify the scripts or commands to be run if you'd like the application to automatically restart in case it crashes specify the restart directive and set its value to always so let's take an example of a real software say docker right well we're not going to talk about docker itself we have you know multiple courses on docker where we talk a lot about docker in this context docker is just an example of a software so and it's the same with any software so you don't really need to know anything about docker to understand this lecture so once Curry's installed docker daemon runs as a background process that listens for docker commands when docker is installed an executable named docker D is made available on the system at path slash users slash bin slash docker D this is configured as a service using the system unit file at path Lib a system the system docker dot service now this file has three sections the unit service and install section as we just learned and you can see the description as well as some of the other details such as link to documentation etc and the service section has the command that is run to start the docker daemon which is specified under the exec start section in this section we will learn more about control based text editors in Linux earlier in this course we saw the usage of the cat command to write and redirect data into a file while this works well and has its uses it is a very basic form and offers no additional features and is not feasible when dealing with adding or manipulating a large amount of texts or for writing code in the DevOps and cloud world you'll be working with a number of Linux servers and most of the time you'll be accessing them remotely using terminal tools and you'll be modifying content in a number of files configuration files mostly so getting the basics of VI editor comes in really handy in such cases there are a number of text editors available in Linux and such as VI vim Nano etc and in this course we will look at VI editor which happens to be the most popular one VI editor comes installed by default with most operating systems run the VI command and specify the filename to open it the terminal opens the file and you are now inside the VI editor VI editor has two modes of operation the command mode and the insert mode when you open file in VI editor you are by default in the command mode in this mode you can issue commands to the editor such as to copy and paste lines or delete a line or a word or to navigate between lines etc but you cannot write contents to the file to write contents to the file you must switch to the insert mode to switch to the insert mode type lower case I once you are in insert mode you may modify the file contents as you would normally to switch back from insert mode to the command mode press the Escape key let's see what operations are available in the command mode you may move around through the editor using the arrow keys or the keys kjh l on your keyboard k to go up edge to left j to down and l to the right to delete a character press X typing DD deletes the entire line to copy a line type YY and to paste it type in p2 scroll the page up or down press the ctrl + U or D buttons typing in colon takes you to the prompt where you can type in commands to save the changes made to the file and write the file to disk use the colon W command you can optionally specify a file name as well to discard any unsaved changes made to the file and quit wim type in : q command to save changes and quit type in : WQ command so how do you find stuff for example I want to find the word off in this file for this type in the command slash off when you do that all occurrences of the word off is highlighted and the cursor is positioned at that location to move your cursor to the rest of the occurrences press the N key and you can continue to press the N key to move the cursor to all future occurrences well that's it for the basics of VI editor for now in this section we will talk about setting up a lab for beginning your studies on DevOps and cloud technologies at code cloud we have embedded labs for our courses and we provide you a readily available environment to work on but at times you may want to set up your own personal learning environment an environment where your changes are persistent and an environment where you can develop your own custom solutions and this section will help you create your own lab as well as troubleshoot and maintain it which is something that most students struggle with we will discuss the different options available to set up a lab environment such as laptops or cloud we will discuss using VirtualBox as a solution to set up labs on your laptop we will discuss how to deploy multiple VMs in a VirtualBox environment we will discuss networking in VirtualBox which is one of the topics that a lot of our students have trouble with such as getting the VMS to talk to each other accessing the internet from the from the VMS SSH into to the VMS etc we will also discuss how to take snapshots to save the state of VMs and restore those snapshots we will then discuss how to automate the deployment of VMs using vagrant a vagrant is a really neat tool that can help you set up a local lab environment very easily and it is I highly recommend you to learn that and finally we will also look at some options available on the cloud to set up your own lab environment you have two options one is your laptop either office or home the second is on the cloud a private cloud within your organization or a public cloud provider like Google AWS or a sure there are many cloud providers that offer free tier where you can create VMs and use them for free we will talk about some of those later for now let's start with a lab setup on a home laptop or desktop environment this could also be an office laptop I personally prefer a home laptop as I can do anything with it as I want I don't need to take approvals or raise requests to firewalls or get permission to install software on it I want to be independent and do whatever I want to do so you need such an environment to play around with and to break and and then fix it back together and basically do anything that you want to do with it so what is a home lab environment and what are the kind of things that you will be needing it for while going through DevOps cloud or IT automation courses you will often come across a set of tools that you will need to work with tools such as kit for source code management build tools like Jenkins for running bills programming language frameworks like Java Python or nodejs they're dependent libraries and packages web servers like Apache web server nginx Tomcat servers or databases like MySQL MongoDB etc or containerization tools like docker or kubernetes and automation tools like ansible chef or puppet as well as cloud management tools like you know cloud SDKs or cloud command-line tools and even different operating systems even such as Ubuntu cent OS fedora etc now you can install all of these directly on your laptop and play around with them but at some point it's going to start impacting the performance of your laptop and you might run into compatibility related issues different applications may have a requirement for different versions of these software's and then you'll try to uninstall and reinstall them and soon you'll see yourself in an installation and cleanup loop and trying to get it all working and soon you'll end up reimagining your laptop and losing all your configurations and all of the personalization that you did to your laptop so one way to combat that is to do everything that you need to do within a virtual machine on your laptop so this way if things go south you can simply delete your virtual machine and provision anyone or take a backup of your virtual machine and restore state from backup we will discuss how do that later in this section this also allows you to try different things in different virtual machines and have different operating systems on different virtual machines irrespective of what OS you are on say you are on a Mac or Windows you can have one VM with one - and little bit sent OS you can run Windows or Linux on Mac or a Windows server on Linux or a Linux on Windows or Mac etc and you can have as many systems as you want as long as you have sufficient hardware resources now of course all of all of these tools that are listed here some of them definitely need to be on your laptop such as git or you know the a few other popular tools that you would use on a day-to-day basis for development purposes but what I'm referring to here are more of the tools like programming language frameworks or build tools or web servers or databases etc so what is a software that can help you create these virtual machines these virtual machines into which you can you know that does which we can play around with or install applications on it's called as a virtualization software or hypervisors now you might have heard about VMware ESX servers or Windows hyper-v servers that can create virtual machines these are known as type 1 hypervisor they're installed directly on bare metal such as a laptop or server and then the VMS are created on that now these are used in enterprises and production environments where you need to create and manage large number of virtual machines and as such these hypervisors have high resource requirements they also need to be installed and configured directly on the laptop and they are expensive as well a lot of people do use this for home labs especially if they have systems with high resources but that's not what we want here for our purpose there are other solutions available that better suit our needs and are easy to manage and those are type 2 hypervisors there hypervisors that runs on an existing operating system examples are oracle virtualbox and VMware Workstation these allow you to easily get started with virtual machines on your laptops without having to install any other operating system or reimage your laptop so going forward when we say a host operating system we are referring to the main OS on our laptop and when we talk about guest operating systems we are referring to the VMS that are created on the hypervisors which are on the operating system and so these are our topic of interest Oracle VirtualBox and William ware workstation both of these are very easy to get started with just download and install and off you go but which one among the two Oracle VirtualBox is a free and open source tool it can be installed and used to create virtual machines on Windows Linux or Mac exactly the same way it supports backup and recovery with snapshots and clone features it lets you run multiple VMs together and also helps you create separate networks within your laptop for different groups of VMS we am or workstation is on the other hand is not a free software it can only be installed on Windows or Linux and not Mac and it supports advanced features like snapshots and clones there is a free version of VMware Workstation known as VMware Player that's available for Windows and Linux and VMware fusion which is available for Mac however these do not have many features that vmware workstation or VirtualBox supports such as running multiple VMs at the same time or taking snapshots or performing you know advanced networking configurations so if you ask me considering the cost benefits and the features Oracle VirtualBox is my choice for a home lab environment so Oracle VirtualBox is supported on Windows Linux Mac or Solaris platforms visit this link to go to the downloads page and download the package for your operating system and this link gives you the list of supported operating system versions with respect to resource requirements oracle virtualbox can be installed on a system with an x86 hardware with memory as small as 512 mb and only consumes around 30 MB of disk space for itself however since virtual machines require resources it's a good idea to have additional resources on your host system a lot more actually so a dual-core or quad-core processor and a memory of at least 4gb and disk space of at least 100 GB or more will help you set up one or two small VMs and you can be really smart in managing resources by allocating VMs with only sufficient resources that that it requires and using lightweight OS images instead of the full-blown OS images so once it's installed open up the VirtualBox tool by starting the executable it should be available in your application section or in your program section on Windows to create a new virtual machine hit the new button at the top then give your VM a name and specify the location where you want the files of the VM to be created the VM itself and the discs of the VM are stored as a file on the host operating system set the type of the OS to Linux and since the VM that I intend to create is st. OS machine I choose Red Hat 64-bit as my OS version because cent OS is a community fork of Red Hat Enterprise Linux so they're kind of the same except that Red Hat Enterprise Linux has a lot more advanced packages and and built-in features but at the core they are the same so from the list of options available now you have Linux and debian fedora you don't see cent OS but instead of that you can just select Red Hat and then you have others like open so say 1 2 etc the next step is assigning memory resources this may differ between different OSS if your OS is lightweight you may assign a smaller amount of memory 1gb is usually good and next we select the hard-disk okay here's where you can create and attach a new disk to the VM now a new disk means it's blank and does not have anything on it it doesn't even have an operating system on it now creating a new VM is like buying a new PC or a laptop without an operating system you decide what CPU memory and disk configurations are needed and then you buy the laptop and get the disks attach the disk to the machine and then the disk is a blank disk and there's no operating system on it so you need to install an operating system using an OS CD so just like how you would install an OS on a laptop you would need to install an OS on a virtual machine created like this now that's one approach but there's a better way and what if the disk you attached already has an OS on it a pre-configured pre-built OS that way when the VM is created we attach the disk which has the OS on it and then when it boots it's ready to go you don't have to manually install the OS so how do we create those disks and where do we get such disks from well it so happens that a large collection of such pre-configured disks or images as it is called are available on the Internet and one such website is OS boxes org they have a list of images for all kinds of operating systems like ubuntu debian cent OS fedora etc once an image is downloaded use that as an existing virtual hard disk file while creating the VM and that's it and the VM is now created now all you need to do is start the VM by right-clicking and selecting the normal start option from the menu in the next lecture we will see the different ways of connecting to the VM and working with it and that's one area a lot of people have problems with like how do you SSH into the VM how do I access a service hosted on um etc and that's what we will cover in the next lecture in this demo we're going to see how to set up a lab environment okay so in my case I have a Windows system so I will be setting up a lab environment on my Windows system it doesn't really matter what operating system you're on you could follow the same instructions to set up a lab environment on Linux or your Mac operating systems so in our case we're going to install VirtualBox so go to virtualbox.org g and in the website you will have find a link to download the VirtualBox software in the download page you will find is links to download VirtualBox for specific operating systems in my case i'm in mine is windows i'm going to click on windows and i'm going to download the software once downloaded run the executable and follow the instructions in the installation wizard to complete installation in my case I've already installed it so I'm just going to cancel that after you install open up the Oracle VM VirtualBox interface and it will look something like this now the next step is to deploy virtual machines in order to do that you can either create a machine attach a CD drive of an operating system and follow the instructions to install the operating system as we are familiar with however there's also an another easy way there are pre-installed pre-configured operating system images available on the Internet we could use those to easily deploy as many virtual machines as we need for this if you go to the website OS box's org you will find a lot of pre-installed pre-configured images of various operating systems go to the site and select the VM images VirtualBox images link at the top then you will be will find a list of various different operating systems from this we will select st. OS and then it will take us to the Centaurs page here you can see information on downloading the Centaurs image in our case we're downloading the VirtualBox image for st. OS 7 and we're downloading the 64-bit portion so remember to download that particular version we will then it is downloaded as a dot 7z file which is a compressed file so you need a software to uncompress it like a tar or winzip my case I'm using the 7-zip software to extract the contents of the file into a folder wait for it to finish the extraction process once finished if you go into the folder you will see that there is a folder called 64-bit and inside that folder you'll find a file with the extension dot VDI the stands for virtual disk and that is what we will use to create a virtual machine we're now ready to create a new virtual machine so we go back into the Oracle VM VirtualBox interface click on new and we fill in the name and operating system now I will name the virtual machine that I'm creating as CentOS - template because as we discussed we our goal is to create a template and then use that template to create as many virtual machines as I need so I'm going to name it as centaurs - template I will now select the type as Linux and the version since it does not have sent OS listed I could simply select other now as you can see another versions there are 32-bit as well as 64-bit options in our case we downloaded the center with 64-bit version so we must select a 64-bit option now in case you do not see the 64-bit options in this list and that is most probably because you do not have the virtualization technology enabled on your laptop to enable virtualization technology on your laptop it is usually under the BIOS settings so if you simply Google enable virtualization in BIOS followed by your laptop model you will see a set of results it's usually it usually looks something like this under the BIOS under the advanced BIOS features you'll have something called as virtualization and you must ensure that it is set to enable state so once you do that restart your laptop and you will find the 64-bit option and click Next in the next here we select a memory size by default it's set to 512 MB and let's change that to around 2 GB so we'll set it to 2 2 gigs in the next step we select the hard disk that we downloaded so in this case the default selection is create a virtual hard disk now but that's not what we want we already have a prebuilt image of a hard disk downloaded so we're going to specify that select the use an existing virtual hard disk file option and click on browse and browse to the file that we downloaded and extracted which is the centralized 7 file with the VDI extension click on ok and that creates the file now before powering on the template we will go into settings and make a few more changes good system and will increase the CPU to around 2 and we go to network section and we will set the adapter 1 to bridge network this way my virtual machine gets an IP address as well as it can connect to the internet to download and install packages as required I will now go ahead and power on the system you okay I'm now at the login prompt select the default user which is the Oh which is OS boxes now the password to find out the password for any images downloaded from OS boxes org go to the info section and then you'll see that the user name is OS boxes and the password is always boxes dot o-r-g so I'm going to use that password OS boxes dot part G I will click on sign-in to log in to this entire system in this demo we are going to see how to set up a lab environment so in our case we're going to install VirtualBox so go to virtualbox.org G and in the web site you will have find a link to download the VirtualBox software in the download page you will find is links to download VirtualBox for specific operating systems I'm going to download the software once downloaded run the executable and follow the instructions in the installation wizard to complete installation after you install open up the Oracle VM VirtualBox interface and it will look something like this now the next step is to deploy virtual machines in order to do that you can either create a machine attach a CD drive of an operating system and follow the instructions to install the operating system as we are familiar with however there's also an another easy way there are pre-installed pre-configured operating system images available on the internet we could use those to easily deploy as many ocean machines as we need for this if you go to the website OS boxes org you will find a lot of pre-installed pre-configured images of various operating systems go to the site and select the VM images VirtualBox images link at the top then you will be will find a list of various different operating systems from this we will select st. OS and then it will take us to the Centaurs page here you can see information on downloading the Centaurs image in our case we're downloading the VirtualBox image for sent OS 7 we're downloading the 64-bit version so remember to download that particular version it is downloaded as a dot 7z file which is a compressed file so you need a software to uncompress it wait for it to finish the extraction process once finished if you go into the folder you will see that there is a folder called 64-bit and inside that folder you'll find a file with the extension VDI the stands for virtual disk and that is what we will use to create a virtual machine we're now ready to create a new virtual machine so we go back into the Oracle VM VirtualBox interface click on new and we fill in the name and operating system I will now select the type as Linux and click Next in the next here we select a memory size in the next step we select the hard disk that we downloaded so in this case the default selection is create a virtual hard disk now but that's not what we want we already have a pre-built image of a hard disk downloaded so we're going to specify that select the use an existing virtual hard disk file option and click on browse and browse to the file that we downloaded and extracted which is the Centaurs 7 file with the VDI extension click on OK and that creates the file now before powering on the template we will go into settings and make a few more changes good system and will increase the CPU to around 2 I will now go ahead and power on the system you in this lecture we will look at how to connect to the VM we created in the previous video now some of the most frequently asked questions about setting up a local lab environment revolves around connectivity how do we connect to the VM and how do we SSH into it why can't I access the you know something that's a hosted on the VM such as a web browser and we'll find answers for these in this video so on our laptop which we will call as the host system we have deployed Oracle VirtualBox and created a VM having s into s image which happens to be the same the guest system I'm using Mac but it works the same for Windows or Linux now when a VM is installed and ready you can start the VM either in a normal mode or a headless mode now a normal mode gives you a console to the VM you can see the UI of the VM as you would see a Linux laptop Buddha it's like looking at the monitor of a machine if the image we downloaded came with a Linux GUI as well then we can see the GUI on the screen and work with the VM like working with any other in a GUI the GUI is okay to explore and maybe you know play around with initially but when you get into real DevOps and cloud and automation tasks it would be better to have CLI access so I personally never use the GUI because it's in fact a bit painful to work with you know switching between your system and the VM UI and since it's a VM the GUI and console may be a bit slow you can't easily copy and paste stuff from your hosts to the guest or you know copy files back and forth you can but it's just not that easy now eventually you need a terminal to work with a Linux system and that is to run commands for you know installing packages working with services etc so instead of using the terminal inside the GUI it is a lot more convenient to use a terminal on your host laptop in the normal mode when the console is closed the VM must be shut down or suspended it pops up this message where it gives you these three options the first one says save the Machine state which is suspend and then sent or the other options are send a shutdown signal or power of the machine the other option shown here is the headless start so if that is selected the VM still starts but the console window won't be opened the William can only be accessed remotely using SSH or remote desktop tools for Windows the third option is where it can be started in a normal mode but closing the console won't require you to suspend or shut down the VM instead you have you now have a new option and that says continue to run in the background so that just selecting that option simply causes the console alone and it continues to keep the VM running in the background depending on what OS has been used on the guest system we have different ways of connecting to it for example say we had a Windows system to remotely connect to the Windows system without using the console you could use the some kind of remote desktop clients such as the one provided by Microsoft now if the guest has a Linux operating system as it is in case of sent OS we can connect to it remotely through SSH using SSH clients like the terminal app in in Linux or Mac and tools like putty in Windows although the VMS are within our laptop think of them as separate machines connected to the same network so whatever you need for one system to connect to another system you would need that here for this to work you must have these VMs configured with IP addresses and the relevant services must be configured and running on Windows you need the Remote Desktop service to be running and on Linux you need the SSH service to be running so make sure SSH server is installed and is in a running State if so you can SSH into the VM from the host system using the terminal on the host and the IP address of the remote VM but how do you configure SSH service and IP addresses on the VM if you can't connect to it on the first place for that you could use the console to perform initial configuration it's a common practice to use the console to perform initial configurations and then once SSH is enabled switch over to the terminal for all future interactions so if you run into issues connecting to a VM check to make sure that the VM has an IP address set and that you are using the right IP address and that SSH service on the remote VM is running so here's a quick example on how to check or set IP addresses in a centralized machine run the IP address show command and it lists all interfaces and IP addresses assigned to them the first interface is the loopback interface with the IP 127 dot 0 dot 0 dot one and the second interface is e 0 which is the interface used for connectivity and it has IP addresses are 192 dot 168 of 1.10 now if the IP address was not set you can set the IP using the IP address add command and specify the IP address followed by the subnet mask and the device you want to set the IP on which happens to be e 0 in this case now with different operating systems the device names as well as commands may differ so refer to the operating system documentation xand and find out the right relevant way to set IP address and here's a quick tip on checking the SSH service the SSH service comes by default with sent OS image to check if the daemon is running run the service hisses HD status command if it's not running run the service sshd start command to start it well that's it for now we will now head over to a demo and see this in action and in the upcoming lectures we will discuss more about networking in VirtualBox okay I'm now at the login prompt select the default user which is the Oh ages OS boxes now the password to find out the password for any images downloaded from OS boxes org go to the info section and then you'll see that the user name is OS boxes and the password is always boxes dot o-r-g so I'm going to use that password OS boxes stored part G I'll click on sign in to log in to this entire system I'll open up a terminal and type in ifconfig the ifconfig command tells me the IP address currently assigned to the virtual machine as you can see it is one ninety two dot one sixty eight dot one dot one one two now I will open up a SSS terminal to SSH into that virtual machine and in my case I'm using a terminal software called as mobile extra I like to use this this is a free software that is available you could use any SSH terminal software you could simply use putty as well so create a new SSH session and specify the IP address which is one ninety two dot one sixty eight dot one dot one one two and the username is OS boxes click on ok now we'll specify the password which is OS boxes dot o-r-g and M logged in so there are different ways to connect to a Linux VM on VirtualBox depending on how you set up your networking I used two different approaches while deploying the VMS in Windows and Mac so I kind of had two demos there Windows and Mac you don't have to go through them it's kind of the same demo the only difference between the two is that on one I set up a bridged networking and on the other I didn't okay so the one on the left as you see here is the setting on Mac and on the one on the right is the setting on windows on the windows deployment I added a bridge adapter and on the Mac OS I didn't I just configured the default NAT option for the networking adapter now if you had configured the bridge adapter as in Windows the VM becomes part of the external network and it gets an IP address assigned to it you can simply SSH to it as you would SSH to another system in your network in case of NAT as in the Mac setup it doesn't connect to the external network and so does not get an IP address on the external network that we can use to SSH to so we will use port forwarding as we discussed in the previous lecture I also want to point out that this doesn't have anything to do with Windows or Mac both these network configurations can be configured on either OS and it works the same I just chose two different options just to show you the difference between the two okay so let's proceed with the connectivity on Mac once the system is powered on if the console looks too small you can go to the View menu and scale visibility to 300% there is a welcome screen and wizard within the console so just go through that and close them from the applications menu select terminal will not check the IP address of the system so we type in IP address show command to see the IP addresses as you can see it gets an IP address of 10.0 2.15 now this is a private internal IP assigned by the NAT router for this VM so this IP is not reachable from anywhere else neither the host or nor any other VMs created on this network so don't try to you know ping this IP or SSH to this IP here from the host you do not be able to do that if you had multiple VMs you will see that all VMs configured with NAT are isolated and they all get the same IP address assigned and they cannot reach each other however with network address translation they can reach the external world so you should have internet connectivity if your host has internet connectivity you can verify that by trying to ping an external website like this ok so that looks good so how do you remotely connect to this system like if you want to SSH into this VM to perform you know to carry out operations to run commands how do you do that so first verify that the SSH service is running for this run the service SSH D status command we see the status is active now our goal is to SSH into this VM from a terminal on our host since it doesn't have an IP address that we can SSH to we will set up port forwarding go to the settings menu of this VM and under the network section select port forwarding add a new rule we will forward a port on our localhost to a port on the VM the SSH service listens on port 22 on the VM but we also have an SSH service on our host that uses port 22 so we cannot forward 22 on our host to the VM so we will configure another port say port 22 22 on the host to forward to port 22 on the VM so we add a rule for that and we name it SSH port now I could try to SSH to my local host IP or a loopback IP address which is 127 dot 0 dot 0 dot 1 and specify port 22 22 and if you'd like to log in as root user specify the user name before the IP address and enter the password OS box's dot org and you're in well we've now connected to our VM and we can now run any commands we'll inspect the release files under the Etsy directory using the cat command to verify the version of OS and as we can see that it's CentOS 7 so we've connected to the right system okay so that's it for this demo in this lecture we will look at the various networking options available within VirtualBox some of the common issues that our students face with respect to VirtualBox is around networking a lot of our students struggle with understanding the different kinds of networks such as NAT bridge and host only and what they mean and what type of network to be used when also how do multiple VMs connect with each other and how to troubleshoot issues where you can't reach the internet and that's what we will discuss in this video so before getting into networking in VirtualBox let us first revise some of the basic networking concepts now computer systems like our laptops or servers have different kinds of interfaces or adapters that are used for connectivity such as wired Ethernet interfaces to connect to a LAN network through a hub or a switch using a cable & wireless interfaces to connect to the network through Wi-Fi now irrespective of how they connect to a network once they do they get an IP address assigned either manually or dynamically if there is a DHCP server in the environment an IP address is assigned to an interface in this case we have a laptop that's connected using an Ethernet cable to a switch in our home once the connection is established our laptop gets an IP address when you run the IP address show command you see the interface en p0 s3 and it has the IP address 192 dot 168 or 1.5 now say you have another adapter a Wi-Fi adapter and you attach that to the same network but this time through Wi-Fi then that interface gets another IP address assigned to it and can be seen in the output of the same command the same laptop now has two separate IP addresses on the same network if any other host were to try to reach our laptop you know they may do so using any of these IP addresses so what I'm trying to say is every system every computer system has different interfaces and it can have multiple such interfaces and adapters to connect to different networks so it could be the same network which is which is as it is in this case but it could be to connect to different networks and some interfaces have internet connectivity depending on what network they're connected to and the others do not once a virtual machine is provisioned in VirtualBox if you go to the settings of that VM and in the network tab you will see different networking options to start with there are four adapters this means that you can configure your VM to have up to four network connections now how you configure those and what do you connect these adapters to is up to you by default only the first adapter is enabled and it is attached to NAT as you can see there are multiple options available here nat bridge adapter host-only adapter being some of them and we will see what these options our next so let's start with a simple example say we have a physical system like our laptop or a PC and it's connected to the network with the address 192 dot 168 of 1.0 so you set an IP for your PC to one ninety two dot one sixty eight dot one dot ten and we have VirtualBox on it say for example a on VirtualBox we have provisioned multiple virtual machines so there are four virtual machines provisioned now how do these VMs talk to each other how do they read systems outside of your PC now as of now these virtual machines are simply created they don't have any network or any IP address assigned to them so if you log into any of these VMs through their console and try to ping one another it would fail and it wouldn't be you wouldn't even know what the IP address is due to a pain in the first place so we create a private network within our PC it's called as a host only network and has an address 192 dot 168 of Phi dot 0 so we attached the virtual interfaces of the VMS to this network now I'll explain how we do that in a bit but let me first cover the concepts so once you attach the interfaces of the virtual interfaces of the VMS to this network they all get an IP address in the 192 dot 168 our Fido series in that range so one system gets 192 168 5.2 another one gets 503 504 and 505 our PC is a part of the network so a virtual interface is created on our PC and connected to the same network and it gets an IP one ninety two dot one sixty eight dot 5.1 so all the VMS and pc itself are now part of a virtual private host only network the reason it's called host only is because the connectivity is contained within this host all the william's can reach each other but they cannot reach the outside wall nor can anyone outside this host reach these virtual machines they're all on a private internal host only network so how do you create this host only network and how do you attach reams to this to create this host only network on VirtualBox on Mac go to file and then host network manager you'll have a similar option available for Windows and Linux as well so just find out where that is once you go into the host network manager inside the host network manager create a new network by clicking on the create button this creates an internal virtual network in our laptop and creates an interface by the name VBox net 0 and assigns our laptop the first IP address on this interface if you run the ifconfig command you see the two IP addresses assigned to my laptop the 102 168 1 dot 10 on the internal adapter and 192 168 5.1 on the VBox net 0 adapter so that's the network the first network created by VirtualBox and you can create multiple such hosts only networks within mercial box so now that we have created the network to attach a VM to this network go to the settings page of a VM and under network select the adapter and select attach to host-only adapter and select the new network that we created so do that on each VM and since this host only network also has DHCP and enabled the Williams I'll get an IP assigned automatically ok so that was one scenario let's look at another option so say we have another physical machine in the network so just building off of that previous example where we have on one side we have our host on network and the and the VMS inside it but we also have another host that's attached to this particular network and it has an IP 192 168 1 dot 11 the PC has some kind of service running on it such as let's say a database instance for example and our VMs on the first PC would like to access this particular database now in the current setup with the host only network the VMS are not going to be able to do that is because they are on a host only network and they cannot really reach outside of that host so for this we introduce a nat network so instead of creating a host only network we create a NAT Network the Nats network is similar to the host only network where as in we create a private network within the physical system and we attach all the VMS to it and they all get an IP address but this time these VMs can access the outside world the VMS can now access the database using its IP address now for every packet that is sent from the VM to the database the NAT engine which sits on the on our host is going to replace the source IP with its own IP address so that when the database receives a request is going to think that it's all coming from the first PC it is unaware of the VMS that are present on the first pc so it processes the request and sends back the data to the first PC the NAT engine on receiving the response intercepts the packet and changes the address back to the original VMS IP and forwards it back to the vm so that's what's called address translation and that's why network address translation when a request is sent the network the from address is actually translated to the host address and then the request goes and then when the response is received the the to address is changed back to the original address of the VM that in fact send the request so with this setup the VMS within can access the outside world but remember the outside world is still unaware of the VMS that exists within the system so no systems from the outside world can access the VMS inside so how do you do that to create an ad network go to the VirtualBox preferences page and select Network and there you will find nat networks click the plus button and create a new NAT network once created to attach a VM to this NAT network go to the VM settings and under network attach the adapter to Matt's network now note that it is different from NAT so NAT and net network are different and then select the name of the net network and that's all so what is NAT and NAT network what is the difference between NAT and network and NAT NAT is the default setting of a VM on VirtualBox it works similar to NAT network as in the VMS can reach the external world and you know users net and network address translation so that when workers go out they go out with the address of the house and when responses are received the address is replaced by the virtual network within that VM however you don't have that internal network here so as such the beams are not able to reach each other so each VM is isolated they cannot talk to each other but they can talk to external systems through the host so each in this case each VM kind of gets its own NAT router whereas in the earlier case there was a net network and there was a single NAT router that there works for all VMs in this case there's more isolation between the VMS within the host so that was about NAT now let's look at another scenario where an external host requires access to the internal VMs so if you've been talking about internal VMS trying to access external services but now let's see what happens if we want external services or external VMS to access internal VMS services or services running on these internal VMS so say for example there's a web application running on one of these VMs and there are other systems that are on our network list such as you know lat and these laptops want to access the web server that's running inside one of these VMs so let's look at another kind of network known as a bridge network the bridge network acts as an extension of the LAN network so you don't really have to create a bridge Network like how we created the host only network or the net network before the bridge network is always there so you just have to connect to it so once the VMs connect to this network this time they get an IP address in the same IP range as that of the external LAN network so they're assigned IPs in the range 192 168 1 dot series and it is as though they are all part of the same external network any device on the network can see them as just another virtual machine on the network so even though they are within the the first host there in fact it is as if they are all part of the same network because the host also gets an IP address am in the range 192 168 1.10 and the VMS within the host also get an IP address in the same range 1 dot 1213 so it's as if they're all part of the same network but in fact these VMs are inside this host so since they are all part of the same network through the bridge network these laptops can access any services that are that are run on these VMs so that's about bridge network ok so we've talked about the three kinds of network host only and NAT and Britten let's now talk about Internet connectivity in each of these cases in case of a net setup whether it's a NAT network or just NAT we learned that internal VMs can reach external network through network address translation so VM is configured with a NAT interface can reach internet as long as the host VM has Internet connectivity you don't really need em to do anything else the bridged option as we know is a next of the external network so it makes the VM as another host on the network so just like all hosts on a network the VM should be able to reach the internet easily so there's nothing really required over there - however in case of a host only network the VMS are on an internal private network all william's attached to that internal network can see each other but they can't connect to any systems outside of the host machine the host machine is connected to two networks the internal host only network where the we'ums are there and the external network that has internet connectivity and that has connectivity the rest of the network so now we can enable the host machine to forward traffic from the internal network to the external Network now for this you must enable IP forwarding on the host VM so this is by default disabled on our laptops most laptops have that that functionality so enabling the IP forwarding feature essentially makes our laptop a router so a router that can route traffic one from one network to another now if you think about it you don't really have to do that and if all you need is to establish internet connectivity for the VMS there are other ways to do that such as by adding an additional adapter to these VMs just as we learned earlier that there are each of these has four adapters so you can configure a second adapter and attach it to net and that way through those adapters those VMs will have internet connectivity so that's just another additional option yeah so this here's what I was talking about so Holly we said that there of each VM can have four adapter so you can configure the second adapter to be attached to net so now when you run into connectivity issues you know where to look at and you know that you should be looking at the number of interfaces that are configured on the VM look at what type of network they are attached to check if those interfaces have IP addresses assigned and you should be able to get a fair idea you aren't able to reach the internet now before I let you go one more thing that's worth mentioning is about port forwarding so a lecture about worship box networking is incomplete without discussing about port forwarding so let's look at what that is let's look at a simple scenario where we have a single VM configured with NAT the the default option port forwarding allows us to map a port on the host to a port on the guest for example 480 on the host could be mapped to port 80 on the guest so that any traffic that comes in on port 80 on the host is forwarded to port 80 on the guest now maybe the guest is running a web server and it's since it's an ad set up as we discussed before external hosts can't reach the VM so configuring a port forward can help the web server receive requests from external hosts even though it's in the net set up because the port forwarding forwards traffic from the port on the host to the port on the guest now it need not be the same port either you can map port 8080 to port 5000 on the VM earlier we discussed that to SSH into the VM we assign an IP address and then use that IP address to SSH from the host to the guest another way to do that is if you don't know the IP address of the VM and you can map port 22 of the guest which is the port used to establish SSH connection to another port say 2 - 2 - on the host then you can simply SSH to the loopback IP address of the host and port 22 22 and that will in fact forward those requests to port 22 on the VM and you should be able to SSH into that so this way you can have multiple VMs and multiple different services running on them and you can map those services to ports on the host now this is done under the VM network settings and by going into the portal forwarding options here you can see the different rules to map host port to guest port as well as specify the protocols that are used let us now look at deploying multiple VMs on VirtualBox and configuring networking between them we will also look at some cloning and snapshot functionalities one way to create multiple VMs is to simply clone an existing VM so if you plan to create multiple VMs then it's good to plan ahead so that you could first create a template VM and then just create multiple clones from it to create a clone for an existing VM right-click the VM and select the clone option note that for this option to appear the VM must be powered off then give the new VM a name I'll limit VM to and then select the type of clone so there are two types of clones a full clone and a linked clone a full clone creates a full copy of the disk used by the existing VM consuming equal amount of new space a linked clone uses the disk of the existing VM and only consumes space for the changes made in the new VM the only concern is when you plan to move a VM from one system to another in case of the linked clone you'll have to copy the disk of the original VM as well or in case you decide to delete the original VM you will run into issues as the linked clone has a dependency on it so if you don't plan to copy your VMs then link clone is a good option as it consumes less space on your on your laptop okay so I'll just select linked clone and continue with it and create the VM so we now have two VMs before turning and them on let us make some changes so we want the two VMs to be able to reach each other so they both must be part of the same network as per the current setting they are configured with that and so they are isolated from each other we also want the VMS to be able to reach the Internet as we plan to install software on them so we will leave adapter one with NAT and that's for the internet and we will configure a second adapter to connect to a host network for that we must first create the host network so go to file and select host network manager our windows systems should also have this option once it's open create a new network I already have a network in this case and I'll add a new network it's named V box net one and as you can see it has an IP address range one ninety two dot one sixty eight dot 57 dot one if you'd like the VMS to get an IP address assigned to them automatically then check this box and then click close then go to the VMS network settings and set the second adapter to connect to host only network and choose the newly created network do that for both VMS also note that if your system is low on resources feel free to reduce the CPU and memory on these VMs as necessary then power on the VMS and wait for them to boot up once they are up login using the OS boxes dot org user account I had created a user account named Matthew on one system that's why you see that there you can also see that on the other system and that's because when we cloned it all the settings get cloned as well now once logged in open up the terminal and inspect the IP addresses here you see the new interface that was created to connect to the new host only network it's named en p0 s8 the IP address that got assigned automatically is one ninety two dot one sixty eight dot 57 dot three let us now check on the second system the second system gets IP one ninety two dot one sixty eight dot 57.4 and remember we said that our host is also a part of the network so our host also gets an IP address of 192 dot 168 or 57 dot one on the network now they all can reach each other through these IP addresses we can now SSH to these VMS using these IP addresses we don't really need that port forwarding rule we configured in the previous demo anymore so SSH and use the root password and I will use another terminal to SSH to the other VM we will also test Internet connectivity since we have the first adapter configured for NAT we have Internet connectivity through that and we see that successful now just to test and show you the difference will change the first adapter to use the other host network we had instead of the NAT configuration now when we check the IP address we see that it now has another IP on the first interface which earlier was configured with NAT and if we try to reach internet now it is not possible so remember that depending on your requirements you must set up your networking configurations if you simply want the VM to have internet connectivity then set it to NAT each VM is isolated if you'd like multiple VMs to talk to each other and have internet connectivity choose Nats Network if you want multiple VMs to reach each other but no internet connectivity choose host network in this case your host will also be part of the same network and can reach the VMS without any port forwarding if you'd like the benefits of multiple networking options then you can have both of these on a single VM as we did in this demo so have one adapter configured to host Network and the other adapter with NAT now none of these options really make your VMs visible to the external network so your VMs are essentially hidden if you'd like all of these and also have your VMs visible on the external Network then choose the bridged option let us now look at the snapshot feature with the snapshot feature you can create a snapshot or backup of your VMs state at a particular point in time and then restored to that backup at a later point in time let's just pick the first VM for this demo say we have an application or a file created in a directory for example we create a directory slash opt slash app and under that we create a file named example dot TX with the contents an example file so that's the current good state let us now take a snapshot so click on this option on the VM and under that select snapshots there should be a similar option for that on other platforms as well you know in Windows and Linux so try to find that out here you can see the current state click on the take button to create a snapshot we will name it the good state and provide a description you can now see a good state and snapshot created here now we're going to simulate a failure we will echo some junk data to the file to simulate some kind of a corruption ok now that we have messed up our system and lost the original contents of the file how do we restore it go to the snapshots window and right-click the snapshot named good state and select the restore option now the restore option is grayed out because the VM is still up so let's first shut it down now the restored option is available click on it to restore stapes the snapshot once restored start the VM we again connect to it and if you go to the opt app path you see the example dot txt file and if you look into its contents you see that it has a write contents great so this functionality is especially useful when you are testing different software and functionalities on VMs for example before making a major change to your vm such as upgrading the version of software or packages you could take a snapshot of the working state to get back to in the future you can also clone a new vm from the snapshot say you made a lot of changes and something went wrong and you're not sure what that is and if you'd like to create a new vm from the previous snapshot that's possible too so right click the code snapshot and choose clone and then follow the same process we followed earlier to create a new vm from that clone let us now get introduced to the basics of vagrant in the previous videos and demos we looked at how to deploy a VM on VirtualBox we followed this process of first downloading the image from the OS boxes dot org website and then we created a new VM we then configured networking such as you know creating post networks and then we went into the settings of each VM and configure the interfaces to use those correct networking settings and then we also configured port forwarding and finally you know booted up the VM we then repeated these tasks for every VM that we wish to create vagrant helps us automate all of these tasks and do all of these with a single vagrant up command that way you don't have to go searching for images of operating systems or download them or create networks or configure port forwarding manually Begaren does all of that automatically so vagrant is especially useful when you have complex systems involving multiple VMs and if you plan to deploy and manage the entire setup together to get started visit vagrant comm and click on the download option and then download and install the appropriate version for your OS once installed run the vagrant in its command and specify the name of the Box you'd like to deploy I'd like to deploy a CentOS 7 box so what is a box a box is a vagrant term and refers to a packaged format of a vagrant environment it contains an OS image as well as scripts required to configure the environment you can find a list of all publicly available vagrant boxes at vagrant cloud by visiting app vagrant opcom slash boxes search and find the box of your choice running the vagrant init command initializes the vagrant box in the current directory and creates a vagrant file the vagrant file has instructions on customizing your box we will look at that in a bit to start the vagrant box run the vagrant up command and when this is done vagrant downloads the image required to create the VM it then creates the VM gives it a random name and configures any settings such as port forwarding or anything like that and waits for it to be ready running the vagrant command without any options lists all available commands you can see the vagrant box command used to manage installation and removal of boxes we just saw the init and up command that initializes a box and brings up the VM you may use the suspend command to suspend a VM the resume command to resume a VM and the halt command to stop the VM the destroy command to stop and the VM and the status command to get the status of a VM if the vagrant file is changed use the reload command to reload the VM you can also take and restore nap shots using the vagrant snapshot command you could SSH into the VM by simply running the vagrant SSH command vagrant will identify the port configured for port forwarding and use that to SSH vagrant also sets up SSH key based authentication so it uses that as well let's take a look at the background file a vagrant file starts with a configuration block within the vagrant configuration block the image used by the box is specified in this case it happens to be CentOS class 7 this is all there is configured in the default vagrant file if you'd like to customize this VM this is where you would do it and then you can share this file with others and the VM will boot up the same way in exactly the same way with the same configurations for everyone for example you could configure port forwarding here and say port 8080 on the host will be forwarded to port 80 on the guest or you could configure a directory to sync between the host and the VM that way you can easily move files from your host machine to the VM if you'd like to configure the CPU and memory settings on the VM then you could do that within the provider VirtualBox block like this you can also configure a simple shell script to run at boot up using the shell provision block like this so when you run the vagrant up command now background provisions a VM following the specifications given in this vagrant file and also runs the shell script given here you may also include multiple VMs in this this approach can help you automate the deployment of complex environments on your laptops such as small clusters of popular systems there are that have automated clusters and such as kubernetes clusters which has multiple VMs VirtualBox is just one provider among the many supported by vagrant you can also use vagrant in a VMware environment such as VMware Workstation or VMware fusion or in a Microsoft hyper-v environment as well so I'd highly recommend you to check out background a and get comfortable with it this will help you easily create and deploy virtual machine or local lab environments as well as save all the work that you did under your configurations in a vagrant file that way in the future you can just if you'd like to deploy the same kind of lab environment all you need to do is run a background up command and then you can share that wagger and file your custom file with others in the community and help others benefit from that as well let's take a quick demo of vagrant to download an install vagrant go to vagrant opcom then go to the downloads page and select the right version for your OS I'm on Mac so I'm going to select Mac OS and this works the same on all operating systems so you can follow the same instructions that I'm following in this demo once the executable is downloaded install it on your system once installed the command vagrant should be available on your system let us now open up a terminal and create a directory for vagrant where we will store all our vagrant configurations within CD into that directory and we are now ready to deploy a VM using vagrant remember you must have the virtual machine provider which in this case is VirtualBox already installed on the system so I already have that it could also be VMware Workstation or fusion as well so whatever it is that you plan to use remember it must exist on the system before you act try to bring up a VM using vagrant now if it's anything other than VirtualBox then when you run the vagrant up command you must also specify that provider using the provider option now we need to find vagrant boxes to deploy searching for vagrant boxes in google will land you on the vagrant cloud page and here you can search for various boxes for different operating systems and solutions I'll go with CentOS 7 select that in that CentOS 7 page we see a template for the vagrant file we could copy this and create a vagrant file by ourself manually or if we want vagrant to create that file for us I go to the new tab and copy the command the command is a vagrant in it and followed by the name CentOS 7 all this command does is create a vagrant file with the image set to CentOS 7 if you see the contents of the vagrant file we see that it is really just a template with all the options commented out any line that begins with a hash is commented out the only line set is the line with the box name running the vagrant up command now downloads the image and then creates a VirtualBox VM with it if you open what you can see the VM being created it takes a while for it to boot up so give it some time and once it's booted up we see the machine booted and the ready message okay now when you run this vagrant up command and if you were using an environment other than VirtualBox then this is where you must also specify the provider using the provider option we can now SSH into the VM using the vagrant SSH command so even if you are on a Windows environment you don't really need another SSH terminal tool or putty or anything this command just works it also takes care of authenticating you into the VM using SSH keys we are now in and we can test the version by viewing the Etsy release files I check the status of the VM using the vagrant status command we see it's in a running state to shutdown run the vagrant halt command we now see the status is powered off vagrant file and make some changes if you go all the way to the bottom we see the VMS resource settings like memory and configuration it's currently commented out if you look at these settings of the VM we see that it has 512 MB of RAM and 1 v CPU local resources can increase boot time for the VM so we'll increase the resources for the VM from the vagrant file so let's uncomment the memory specification as well as the starting and ending of that block now we will leave the memory to 1gb to provide CPU configuration use the V B dot CPUs property and we set it to 2 V CPUs we can also rename the VM here not sure if you notice but the VM has a random name assigned to it and all of these settings can be found in the vagrant documentation page we save that file and every time you modify the vagrant file for the changes to take effect you must run the vagrant reload command we wait for it to boot up and we can see that the vm name is already updated to the name we specified go into settings and we see the memory and CPU are set correctly as well at times when you boot up VMs using the vagrant up command you might see an error like this it's a timeout error what's happening here is that vagrant starts the VM and waits for it to boot up completely however the VM took more time to boot than vagrant expected this could be because the VM is configured with very few resources and it takes a long time for the VM to load the VM may end up booting properly eventually and then you should be able to access the VM as you would normally but in case you are not sure and you think it's stuck power of the VM using the vagrant halt command and then go to the file and you can increase the timeout by adding a property config dot VM dot boot timeout like this you reloading the vagrant file restarts the VM and the next time vagrant waits longer before throwing an error message well that's a quick introduction to vagrant and I hope it will help you set up labs quickly if you'd like to learn more about vagrant please let us know and we can probably create a separate course just for vagrant because there are so many things that you can do with vagrant in configure multiple VMs you can configure scripts as we saw in the lecture so it's a very neat tool to really set up a custom lab environment and then save that configuration so that you can share it with others in this video we get introduced to DNS in Linux for the absolute beginners we will discuss the basic concepts and view some commands that will help us explore DNS configuration on hosts specifically Linux host at the end of this section you will go through a practice test where you're given a set of challenges related to B and s and are asked to solve them on a live practical hands-on lab environment right in your browser we have two computers a and B both part of the same network and they've been assigned with IP addresses 192 168 1.10 and 1.11 you're able to ping one computer from the other using the other computer's IP address you know that system B has database services on them so instead of having to remember the IP address of the system B you decide to give it a name DB going forward you would like to ping system B using the name DB instead of its IP address if you try to ping DB now you would see that host a is unaware of a host named DB so how do you fix that basically you want to tell system a that system be a type e address 192 168 1 dot 11 has a name DB you want to tell system a that when I say DB I mean the IP 192 168 1 dot 11 you can do that by adding an entry into the SC host file on system a mention the IP address and the name you want your house to see system B as with all system a the IP at 192 168 1.11 is a host named DB pings to DB now gets sent to the correct IP nar successful now there is an important point to note here with old system a that the IP at 192 168 1.11 is a host named DB host a takes that for granted whatever we put in the HC host file is the source of truth for host a but that need not be the truth host a does not check to make sure if system B's actual name is DB for instance running a hostname command on system B reveals that it is named host to but host it doesn't care it goes by what's in the host file you can even full-system a to believing that system B is Google just add an entry into the host file with an IP mapping to www.google.com then ping Google and you will get a response from system B so we have two names pointing to the same system one s DB and another as Google and we can use either names to read system B we can have as many names as you want for as many servers as you want in the Etsy host file every time we reference another host by its name from host a through a ping command or SSH command or through any of the applications or tools within this system it looks into its Etsy host file to find out the IP address of that host translating host name to IP address this way is known as name resolution within a small network of few systems you can easily get away with the entries in the SC host file on each system I specify which are the other systems in the environment and that's how it was done in the past until the environment grew and these files got filled with too many entries and managing this became too hard if one of the server's IP changed you would need to modify the entries in all of these hosts and that's where we decided to move all these entries into a single server who will manage it centrally we call that our DNS server and then we point all hosts to look up that server if they need to resolve the host name to an IP address instead of its own Etsy host files so how do we do that how do we point our host to a DNS server our DNS server has the IP 192 once they see it 100 every host has a DNS resolution configuration file at Etsy resolve cons you add an entry into it specifying the address of the DNS server we say name server and point it to 192 dot 168 100 and that should be it once this is configured on all of your hosts every time a host comes up across a host name that it does not know about it looks it up from the DNS server if the IP of any of the hosts was to change simply update the DNS server and all hosts should resolve the new IP address going forward you no longer need any entries in the SC host file in any of the hosts but that does not mean you can't have entries in host file you still can for example say you were to provision a test server for your own needs you don't think others would need to resolve the server by its name so it need not be added to the DNS server in that case you can add an entry into your hosts at-sea host file to resolve this server you can now resolve the server however no other system will be able to do that so a system is able to use host name to IP mapping from the Etsy host file locally as well as from a remote DNS server what if you have an entry in both places one in your Etsy host file and another in DNS I have an entry in my local file set to 100 to 168 1.1 1 5 and someone added an entry for the same host to 192 168 1.11 6 on the dns server in that case the host first looks in the local Etsy host file and then looks at the name server so if it finds the entry in the local Etsy host file it uses that if not it looks for that host in the DNS server but that can be changed the order is defined by an entry in the file at C NS which calms the line with the hosts entry as you can see the order is first files and then followed by DNS files refers to Etsy host file and DNS refers to the DNS server so for every host name the hosts first looks into the Etsy host file and if it cannot find it there it then looks at the DNS server this order can be modified by editing this entry in the file as per this order our host would resolve the test server to 192 168 1.11 5 what if we try to ping a server that is not in either list for example I try and ping delete wwe.com I don't have facebook.com in my Etsy host file and and I don't have it in my DNS server either so in that case it will fail you can add another entry into your other resolve that confiar to point to a name server that knows Facebook for example 8.8.8.8 is a common well known public name server available on the Internet hosted by Google that knows about all the websites on the Internet you can have multiple name servers like this configured on your host but then you will have to configure that on all your host in their network you already have a name server within your network configured on all the hosts so in that case you can configure the DNS server itself to forward any unknown host names to the public name server on the Internet you should now be able to ping external sites such as Facebook calm until now we have been just trying to reach systems with their names like web DB NFS etc but we just try to ping Facebook at www.facebook.com/babelsub and calm at the end it's called a domain name and it is how IP is translated to names that we can remember on the public internet just like how we did for our hosts now the reason they are in this format separated by dots is to group like things together the last portion of the domain name the dot-com stats edu or etc are the top-level domains they represent the intent of the website comp for commercial or general dotnet for network dot edu for educational organizations and dot org for nonprofit organizations let's look at one in particular in Google's case the dot is the route that's where everything starts com is a top-level domain Google is the domain name assigned to Google and www is a subdomain the subdomains help in further grouping things together under Google for example Google's map service is available at maps.google.com so Maps is a subdomain Google's storage service is available at drive.google.com mobile apps are available at App Store google.com Google's email service are available at mail.google.com you can further divide each of these into as many subdomains based on your needs so you begin to see a tree structure forming when you try to reach any of these domain names say apps Google come from within your organization your request first hits your organization's internal DNS server it doesn't know who apps or Google is so it forwards your request to the internet on the internet the IP address of the server serving App Store Google com may be resolved with the help of multiple DNS servers a root DNS server looks at your request and points you to a DNS server serving comps a.com DNS server looks at your request and forwards you to Google and Google's tienen server provides you the IP of the server serving the apps applications in order to speed up all future results your organization's DNS server may choose to cache this IP for a period of time typically a few seconds up to few minutes that way it doesn't have to go through the whole process again each time so that was out in the public what about your organization your organization can have a similar structure to for example your organization could be called as my computer come and have multiple subdomains for each purpose the www for external facing website mailed out my company intercom for accessing your organization's mail drive for accessing storage paid or company intercom for accessing the payroll application HR for accessing HR application etc all of these are configured in your organization's internal DNS server the reason we discussed all of this is to understand another entry in the Etsy result of con file remember this is the file where we configure the DNS server to be used for our hosts with that we were able to resolve servers in your organization with just their names like web we have now introduced more standard domain names like web dot my company comm or D beat up my company.com etc now when you ping web you can no longer get a response of course this is because we are trying to ping web but there is no record for by the name web on my DNS server instead it is web dot my company comm so you have to use web dot my company dot-com now I can understand if someone outside our company wants to access our web server he would have to use web got my company dot-com but within our company your own company you want to simply address the web server by its first name web just like how he utters other members in your family simply by their first names which is not the case when someone outside your family addresses them using their full names so what do you do to configure web to resolve my web dot my company comm you want to say when I say web I mean web dot my company comm for that you make an entry into your hosts Etsy resolved or con file called search and specify the domain name you want to append next time you try to ping web you will see it actually tries web dot my company comm now your host is intelligent enough to exclude the search domain if you specified a domain in your query like this you may also provide additional search domains like this so it would mean when I say web I mean web dot my company comm or web dot prod dot my company com so your host will try searching all of these domain names when you look for a host name finally a word about a record types so how are the records stored in the DNS server we know that it stores IP - host names that's known as Ayer records storing ipv6 to hostnames is known as quad a records mapping one name to another name is called cname records for example you may have multiple aliases for the same application like a food delivery service may also be reached at eat or hungry that's where a cname record is used name to name mapping there are many more but that's what we're going to look at for now now ping may not always be the right tool to test DNS reservation there are a few other tools as well such as nslookup we can use nslookup to query a hostname from a DNS server but remember in this lookup does not consider the entries in the local Etsy host file so if you add an entry into the local Etsy host file for your web application and if you try to do an NS lookup for that web application it is not going to find it the entry for your web application has to be present in your DNS server nslookup only queries the DNS server the same goes with dig dig is another useful tool to test the NS name resolution it returns more details in a similar form as is stored on the server in the upcoming practice exercises section you will practice viewing configuring and troubleshooting DNS in a lab environment on actual systems through some fun and challenging exercises in this series of lectures we get our networking basics right we look at basic networking concepts like switching routing gateways etc we then understand DNS we look at how to configure DNS settings on a Linux system so let's get started so what is a network we have two computers a and B laptops desktops VMs on the cloud wherever how does system a reach B we connect them to a switch and the switch creates and network containing the two systems to connect them to a switch we need an interface on each host physic or virtual depending on the host to see the interfaces for the host we use the IP link command in this case we look at the interface named e0 that we will be using to connect to the switch let's assume it's a network with the address 192 dot 168 or 1.0 we then assign the systems with IP addresses on the same network for this we use the command IP addr once the links are up and the IP addresses are assigned the computers can now communicate with each other through the switch the switch can only enable communication within an Network which means it can receive packets from a host on the network and deliver it to other systems within the same network say we have another network containing systems C and D at address 192 dot 168 2.0 the systems have IP address 192 168 2 or 10 and 2 dot 11 respectively how does a system in one network reach a system in the other how does system be with the IP 192 168 1 dot 11 reads system C with the IP 2.10 on the other network that's where a router comes in a router helps connect to networks together it is an intelligent device so think of it as another server with many network ports since it connects to the two separate networks it gets to IPS assigned one on each network in the first network we assign it an IP address one of you wants to steal one dot one and in the second we assign it an IP 2.1 now we have a router connected to the two networks that can enable communication between them when system b tries to send a packet to system see how does it know where the router is on the network to send the packet through the router is just another device on the network there could be many other such devices that's where we configure the systems with a gateway or erupted if the network was a room the Gateway is a door to the outside world to the other networks or to the Internet the systems need to know where that door is to go through that to see the existing routing configuration on a system run the route command it displays the colonel's routing table and within that as you can see there are no routing configurations as of now so in this condition your system B will not be able to read system C it can only reach other systems within the same network in the range 192 dot 168 1.0 to configure a gateway on system B to reach the system's on network 2.0 run the IP route and command and specify that you can reach the 182 dot one sixty eight dot 2.0 network through the door or Gateway at one eighty two dot one sixty eight dot one dot one running the route command again shows that we have a wrote added to reach the 182 168 or 0 series network through the router now remember this has to be configured on all the systems for example if the system C is to send a packet to system B then you need to add a route on system C's routing table to access the network at 1.0 through the router configured with the IP address 2.1 now suppose these systems need access to the Internet say they need access to Google at 172 dot 217 to $104 0 network on the internet so you connect the router to the Internet and then add a new route in your routing table to route all traffic to the network 170 2.2 17.1 94 through your router there are so many different sites on different networks on the internet instead of adding a routing table entry for the same routers IP address for each of those networks you can simply say for any network that you don't know a route to use this router as the default gateway this way any request to any network outside of your existing network goes to this particular router so in a simple setup like this all you need is a single routing table entry with the default gateway set to the routers IP address remember instead of the word default you could also say 0.0 0.0 it means any IP destination both of these lines mean the same thing in 0.000 entry in the Gateway field indicates that you don't need a gateway for example in this case for system C to access any devices in the 192 168 2.0 Network it doesn't need a gateway because it is in its own network but say you have multiple routers in your network one for the internet another for the internal private network then you will need to have two separate entries for each network one entry for the internal private network and another entry with the default gateway for all other networks including public networks so if you're having issues raising internet from your systems this routing table and the default gateway configuration is a good place to start let us now look at how we can set up a linux host as a router let's start with a simple setup I have three hosts a B and C a and B are connected to a network 192 168 1 and B and C to another 1 192 168 dot 2 so host B is connected to both the networks using two interfaces it's 0 and it 1a has IP 182 168 1.5 C has 180 to 160 of 2.5 and B has an IP on both the networks 1.6 and 2.6 how do we get a to talk to C but basically if I try to ping 2.5 from a it would say to work is unreachable and by now we know why that is host a has no idea how to reach a network at 192 dot 168 got to we need to tell host a that the door or gateway to network to is through host B and we do that by adding a routing table entry we add a route to access network one ninety two dot one sixty eight dot two while the gateway 192 168 1.6 if the packets were to get through to host c host c will have to send back responses to host a when host c tries to reach host a at 192 168 1 network it would face the same issue so we need to let host c know that it can reach host a through host b which is acting as a router so we add a similar entry into host C's routing table this time we say to reach network 182 168 1.0 talk to host B at 192 168 2.6 when we try to ping now we no longer get the network unreachable error message that means our routing entries are right but we still don't get any response back by default in Linux packets are not forwarded from one interface to the next for example packets received on e 0 on host B are not forwarded to elsewhere through each one this is this way for security reasons for example if you had eats 0 connected to your private network and each one to a public network we don't want anyone from the public network to easily send messages to the private network unless you explicitly allow that but in this case since we know that both our private networks and it is safely enable communication between them we can allow host B to forward packets from one network to the other whether a host can forward packets between interfaces is governed by a setting in this system at file proc says net ipv4 IP underscore by default the value in this file is set to zero meaning no forward set this to one and you should see the pings go through now remember simply setting this value does not persist the changes across rebels for that you must modify the same value in the Etsy sis control.com file so let's take away some key commands from this lecture this will be handy in the upcoming lectures IP link is to list and modify interfaces on the host IP addr command is to see the IP addresses assigned to those interfaces IP addr add command is used to set IP addresses on the interfaces now remember changes made using these commands are only valid till a restart if you want to persist these changes you must set them in the SC network interfaces file IP route or simply the route command is used to view the routing table and IP route add command is used to add entries into the routing table and finally remember the command to check if IP forwarding is enabled on a host if you are working with a house configured as a router in this lecture we will talk about IP addresses and ports from a web applications perspective so one of the common issues that we've seen students especially beginners struggle with while working with web applications are related to connectivity so what IP addresses do we use and what are port numbers and what port numbers to use what is the difference between localhost 127 dot 0.01 and the IP addresses of the server or why does it matter and why can't I access the web server from another system if there is a web server and database server then why is one not able to reach the other so things like these are some of the common questions that we get all the time so and through this lecture I'd like to clarify all of these and going forward whenever you run into any similar issues you should be able to follow these steps and troubleshoot and fix issues easily so let's take a step back and understand a little bit about the basics of networks and IPS so computer systems like our laptops or servers have different kinds of interfaces or adapters for connectivity such as wired Ethernet interfaces to connect to a LAN network through a hub or a switch using a cable and the wireless interfaces to connect to the network through Wi-Fi so irrespective of how they connect to a network once they do they get an IP address assigned an IP address is assigned to an interface in this case we have a laptop that's connected using an Ethernet cable to a switch in our home once the connection is established our laptop gets an IP address assigned to it on the network when you run the IP address show command you see the interface enp 0 s3 has the IP address 10.0 2.15 now say you have another adapter a Wi-Fi adapter and you attach that to the same network but this time through a Wi-Fi then that interface gets another IP address assigned to it and can be seen in the output of the same command the same laptop now has two separate IP addresses on the same network so if any other host in the network were to try to reach our laptop they may do so using the any of these IP addresses each of these network interface cards are divided into multiple logical components known as ports now you can have up to 65535 ports on each IP address each port is a communication endpoint programs can listen on these ports for requests so when you run a web server it listens for requests on these interfaces on one of these ports for instance a Python flask web server listens on port 5,000 by default now you can change that by specifying the port number as a parameter inside the run call like this we have now configured the application to listen on port 8000 but on what IP address and we have two IP addresses configured on our host the port on which of these interfaces or IP addresses is the application going to listen on you can also specify the IP address on which the server should listen on using the host option like this the application now listens on IP 10.0 2.15 on port 8000 so anyone trying to access my application on this IP address and port will be able to view my server however they won't be able to access the server on the other interface on IP 10.0 2.16 so what if I want my application to be available through both these IPS then instead of specifying the IP address of a single interface you must specify 0.0.0.0 in that case the server will listen on all available interfaces we now have our application available on all interfaces and anyone can access it what if we are not ready yet to make it available to the external world for example we are only developing our application and don't want anyone else to access it except for maybe ourselves from within our laptop in that case remove the host specification in the application run call but when we do that it does not listen on any interface so then how do we test it by ourselves if it's not available on any interface what IP do we use in a browser to access our application when no option is specified the server listens on IP 127 dot 0 dot 0 dot 1 by default this is known as the loopback address apart from the two interfaces we talked about earlier every host has a built-in virtual interface known as the loopback address the information about this interface is also visible under the output of the IP address show command its name his hello and the IP assigned is 127 dot zero dot zero dot one every host has this loopback interface built into it and all of them have the same IP address set on it 127 dot zero zero one when you refer to the IP 127 dot 0 dot 0 dot one it is like referring to yourself it's like saying I me or myself anything you sent to IP 127 dot 0 dot 0 dot one is sent to the same host nothing sent to this address leaves the host system so from within your host if you wish to test your application you can simply open up a browser and type in 127 dot 0 dot 0 dot 1 followed by the port at which the server is listening to access the web server now instead of typing in the IP address you can also say local host because local host is the standard network name associated with the low back IP address and that also means that you cannot access this web server from any other host other than this host the 127 dot 0 dot 0 dot 1 IP address is an IP address used to refer to this host from only within this host every other host has their own internal loopback interface with the same IP address of 127 0.01 and if you try to access the web server using this loopback IP address from the second host you won't be able to connect to the first house it looked for a web server on its own host which does not exist so the request fails so remember that this particular IP address or the host name local host referred to the local host itself and it can only be reached from within that host well that's it for now head over to the labs and practice working awaits IP addresses and ports and I will see you in the next lab hello and welcome to this lecture in this lecture we take a look at what llamo files are if you are familiar with the ml already feel free to skip this section and head over to the next section if you have not worked with Gamal in the past I would highly recommend going through this because the rest of the course depends entirely on llamo if you have worked with other data structure formats like XML or JSON you should be able to easily pick it up don't worry if you haven't worked on any of these you should still be able to easily pick it up going through the coding exercises that accompany this course a yellow file is used to represent data in this case configuration data here is a quick comparison of a sample data in three different formats the one on the left is XML where we display a list of servers and their information the same data is represented in JSON format in the middle and finally in yellow format to the right take a minute to compare the three formats let's take a close look at llamo if you take the data in its simplest form such as key value pair this is how you would define it in llamo key and value separated by a colon the keys are fruit vegetable liquid and meat and the values are apple carrot water and chicken remember you must have a space followed by colon differentiating the key and the value let's take a look at how an array is represented we would like to list some fruits and vegetables we would say fruits followed by a colon on the next line enter each item with a dash in the front the dash indicates that it's an element of an array how about a dictionary a dictionary is a set of properties grouped together under an item here we try to represent nutrition information of two fruits the calories fat and carbs are different for each fruit notice the blank space before each item you must have equal number of blank spaces before the properties of a single item so they are all aligned together let's take a closer look at spaces in llamo here we have a dictionary representing the nutrition information of banana the total amount of calories fat and carbs are shown notice the number of spaces before each property that indicates these key value pairs fall within banana but what if we had extra spaces for fat and carbs then they will fall under calories and thus become properties of calories which doesn't make any sense this will result in a syntax error which will tell you that mapping values are not allowed here because calories already have a value set which is 105 you can either set a direct value or a hash map you cannot have both so the number of spaces before each property is key in yeah Mille you must ensure they're in the right form to represent your data correctly let's take it to another level you can have less containing dictionaries containing lists in this case I have a list of fruits and the elements of the list are banana and grape but each of these element are further dictionaries containing nutrition information a lot of students new to Yama have reached out to me asking when to use a dictionary or a list so let me explain this a little bit better first of all it is important to understand that all of what we discussed so far such as XML JSON or Yama are used to represent data it could be data about an organization and all of its employees and their personal details or it could be data about a school and all of its students and their grades or it could be data about an automobile manufacturing company and all of its cars and its details it could be anything let's take an example of a car a car is a single object and it has properties such as color model transition and price to store different information or properties of a single object we use a dictionary in this simple dictionary I have properties of the car defined in a key value format this need not be as simple as this for example in case we need to split the model further into model name and make ear you could then represent this as a dictionary within another dictionary in this case the single value of model is now replaced by a small dictionary with two properties name and ear so this is dictionary within another dictionary let's say we would like to store the name of six cars the names are formed by the color and the model of the car to store this we would use a list or an array as it is multiple items of the same type of object since we are only storing the names we have a simple list of strings what if we would like to store all information about each car everything that we listed before such as the color model transition and price we will then modify the array from a list of strings to a list of dictionaries so we expand each item in the array and replace the name with the dictionary we built earlier this way we are able to represent all information about multiple cars in a single yellow file using a list of dictionaries so that's the difference between dictionary list and list of dictionaries I hope you understood the difference between the three and when to use each of these before we head over to exercises let's take a look at some key notes dictionary is an unordered collection whereas lists are ordered collection so what does that mean the two dictionaries that you see here have the same properties for banana however you can see that the order of properties fat and carbs do not match in the first dictionary fat is defined before carbs and in the second dictionary carbs comes first followed by fat but that doesn't really matter the properties can be defined in any order but the two dictionaries will still be the same as long as the values of each property match this is not the same for lists or arrays arrays are ordered collection so the order of items matter the two lists shown are not the same because apple and banana are at different positions this is something to keep in mind while working with data structures also remember any line beginning with a hash is automatically ignored and considered as a comment we are now ready to head over to the coding exercises and have fun playing with mo files well you've reached the end of the dev ops prerequisites course congratulations you now have enough knowledge to get started with any of the DevOps and cloud courses out there you'll now be comfortable working with Linux systems basic applications basic networking yamo and other configuration files so what's the next step you have now completed the DevOps prerequisites course in the get your basics right section the other course available in this section is the Linux basics course Linux plays a key role in the DevOps and cloud world so it's always helpful to get real good hands-on experience working with Linux systems our Linux basics course is a good start and it's an engaging and fun course developed in a story format and with lots of hands-on labs as you did in this course to start your journey with containers and the cloud native world get started with the docker for the absolute beginners course it's a course that will help you get a good understanding of the importance of containers and the role of docker in the cloud native computing world this course will pave way to the kubernetes for beginners course knowledge about container native technology like docker is a prerequisite for learning kubernetes kubernetes is one of the most trending technology in IT industry as of today and it's a very in demand skill once you complete the beginners course you can target the kubernetes certifications like CK a and CK ad our courses have labs and multiple mock exams that will help you clear certification easily kubernetes is a prerequisite for red hat openshift after completing the CK ad course where you will learn how to configure and deploy applications on kubernetes you can then proceed to the red hat openshift course in the automation category start with the most popular automation tool ansible are ansible for the absolute beginners course is targeted for those who have zero experience in automation or scripting with this course you will be able to implement automation solutions without any experience in coding no coding or programming experience required in fact none of these courses require any kind of coding or programming experience whatever you have learned in this DevOps prerequisites course is sufficient to go through any of these courses you may choose to learn other systems like puppet and chef as well the ansible for the absolute beginners course will also help you prepare for the ansible certification exam and we plan to have a lot more courses added to this path in the future so check out this page whenever you get time we also have the code cloud engineer program that will help you get more hands-on experience this is a simulated job environment that you can enroll for free and start while getting tasks assigned to you for more details check out engineered code cloud comm well that's it for now thank you so much for joining me in this course and I hope to see you in our next courses
Info
Channel: freeCodeCamp.org
Views: 208,724
Rating: undefined out of 5
Keywords: devops, docker, yaml, vagrant, virtualbox, linux
Id: Wvf0mBNGjXY
Channel Id: undefined
Length: 166min 8sec (9968 seconds)
Published: Fri Jun 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.