Hello. My name is Corey Thompson. And in these lessons, you will learn how to set up local, remote and dynamic port forwarding. We will also learn how to use proxy chains application in combination with our dynamic port forwarding. In this lesson, I will show you how to set up local port forwarding. Let's talk about the concept of local port forwarding and see how it can be applied in a real world scenario. Local port forwarding is a powerful technique that allows us to access services running on remote servers through our local machine. By redirecting network traffic from a local port to a remote port, we can securely interact with remote applications as if they were running locally. For this demonstration, let's assume you are a developer working remotely and you need to access a database server running on a remote machine, which in this case will be our ubuntu3 machine. However, the database server is only accessible within the company's private network, so we will have to use a remote server in order to access the database server. To do this, we need to utilize the local port 40. To begin, establish a secure connection to the remote server machine that will be in the middle using secure Shell SSH. This provides encryption and secure communication channels to set up our local port forwarding. Let's go over to our terminal on our ubuntu1 machine. I'm going to type out a simple syntax for the local port forwarding. let's take a look at this syntax. SSH -L stands for setting up a local port forwarding. The first portion is the local port. This is the port on your local machine to forward the traffic. Remember, it's attached to the machine you are currently on. So in our case, it will be the ubuntu1 machine. The next portion is the database server. This is the IP address of the device hosting the database we want to access, which again in our case will be the ubuntu3 machine. The port for the database port is the port for the database server and the services is hosting on. For this demonstration, it's been configured to serve port 9000 with a sample database text file. The next portion is a username. This is a username to access the remote server which has access to the database server. So think of it as a man in the middle box. You're connecting to the jump box that is then able to connect to the database server. The last part, the remote server is the IP address of that jump box that we are going to connect to. Now let me go ahead to run command and we'll talk about this. Now, let's take a look at this SSH Command. Again, the -L means that we're going to set up a local port forward, followed by the local port We want to listen to this. This is any number you can choose, but it must not be in use. We're going to make it simple, and use port 1234. The next portion is the database server that we ultimately want to connect to. The IP address shown there will get us there and the port following 9000 is where it's set up to provide a sample database text file. The user2 is the user credentials for the jump box or the ubuntu2 machine, in this case. That will has access to the database server. The next portion is the checkboxes IP address. The last part is the port in which the jump box is listening on. It's not listening on the default TCP port of 22. So we need to specify the alternate port. Now let's go ahead and press enter and let's provide user2's credentials. As you can see, we are on the user2 ubuntu2 machine. Now in another terminal, let's do some testing to verify that everything worked. We're on our ubuntu2 machine, so we need to verify that the network connection for our local port of 1234 was set up properly. So in a new terminal we can type SS command to look at the network connections. And as you can see in the first line, our local machine is listening on port 1234. So that means our SSH local port forwarding command worked. Now that we know our local machine is listening, will pull back the database file that our servers hosting, which remember is coming from the ubuntu3 machine, not the jump box. To do this we will use the wget command. Wget is a command line utility that's used for retrieving files from the internet or other sources. The name wget stands for webget, indicating its primary purpose of downloading files from web servers and other remote locations that's accessible through various protocols. We're going to use the -r with our wget to represent recursive and to grab everything inside of the directory that the database server is hosting. So our command looks like wget -r. Now we're going to specify the location which is going to be our local host. And now the port that we set up, the local port forward, which was 1234. So press enter we can see that it pulled back some files. We have the index HTML file, we have a file name database. When the command is successful, it will be saved into a directory named after our connection, which was the local host 1234. If we lost our current directory, we can see that it created that local host directory. So let's move into there. And if we lost out the contents, we can see we had the database in index file. We take a look at the database file. We can see that this represents a database content that's coming from the ubuntu3 or /the database server. To start the local port forwarding, you can simply close out the terminals. This will close the SSH session and terminate the port forwarding. That concludes our practical demonstration of local port forwarding. Remember to keep the SSH session open as long as you need the port forwarding to be active. Stay tuned for the next lesson where I will show you how to set up remote port forwarding. Thanks for watching.