Configuring a Private/Public Network and Forwarding Ports in Vagrant
2 hours 51 minutes
Hello. My name is Jasmine Jackson in our courses intro to Vagrant and in this lesson, we will learn about networking in vagrant Less Begin
The learning objectives for this video are we will learn how to create networks, a vagrant using the following
port forwarding public networks and private networks.
So before we start with port fording, we need to learn the history of port 40.
According to tech OPD, a poor fording is a networking technique which transmits all incoming communications or traffic of a specific port to a port on an internal network. So you may be thinking, OK, jasmine, that sounds great. It's a lot of words.
Can you break you down? I can.
So Port fording is where you can specify traffic
going from one port to another
example. So let's say I have a virtual machine and I want all of my traffic on Port 80 to be rerouted or re transmitted to port
2222 on my host machine. That is an example of Port 40 so a common feature of poor fording is connecting the Internet to an eternal land
port. Fording is used for segregating network traffic and optimizing networks speed and other names for port fording our port mapping tunnelling or punched through.
So how does Port Ford
Port fording Excuse me? Work and vagrant.
So port forwarding
allows sharing from the vagrant machine using a specific port to our host machine using another port. So going back to our example
on my vagrant machine, I can have poured 80
Go to poor to 2 to 4 on my host machine That is an example of port 40
to enable your newly created network using port fording we use the command vagrant Reload
So a caveat were using port fording Most providers by default have the four report bound to all interfaces. So what that means is that any device on that network will have access to your forward ports.
I will show you in the demo for port fording how we can
be more restrictive
with this caveat. But be mindful of this caveat when you're using port 40
so by default the protocol used is TCP
control protocol. But you can change the protocol to UDP or Universal Data Grand Protocol.
So TCP and UDP are outside of this course that's outside the scope of this course,
and for that you would need to take an intro to networking course to figure out what those two
protocols are. I can't say that for TCP. You can think of it as a telephone where the sender and receiver has a dedicated line, and the reason you would need a dedicated line is because the information that's transported back and forth
means to go in a specific sequence.
When you're on the phone and the conversation is out of sequence, it was sound like garbage or gibberish You won't be able to understand.
You can think of UDP as text messaging, so we're text messages. There's no guarantee that the messages will come in order. There's no guarantee you don't have a dedicated line with text messaging. Text messages can come.
An order of text messages could come out of order. If the service is down,
then the text messages won't go through. So there's no
confirmation of delivery with UDP.
But again, TCP and UDP are outside of this scores. But I just wanted to give you a small, very small primer on TCP and UDP, but if you want to learn more, you have to take a networking course.
Public networks in Vagrant.
So this is where it gets tricky. So according to Hash Corp and remember from Lecture one, the history of Vagrant Hash Corp is the company that does full time development with vagrant.
The definition of a public network is that
it's less private than a private network. So you might be thinking, Okay, well, that's obvious.
And you may be thinking, Well, why is it defined this way? And it's defined this way because different providers have different definitions for what a public network is. So again, according to hash court private Excuse me, a public network
is the network that's less private than a private network,
and it's not unlike, well,
okay, that's intuitively that makes sense.
the best way to configure a public network is to use D HCP dynamic host configuration protocol. And again, this is just like what TCP A UDP would d HCP if you want to know the inner workings again. This is
networking cores. You need to take a networking course, but to just give you a small primer de HCP. How it works is when you start your machine, the machine will automatically assign I p address to your machine. So this is done dynamically.
Hence dynamic and deviates
So when you start
the machine, the machine will give you an I p address. And when you shut down that machine and you restart the machine that you would get a new i p address. So it's dynamic
and a way to figure out how to find your I P address is using the vagrant Ssh. So creating a secure show
into your vagrant machine and then entering the command i f config in Lennox or I p config and windows
also no. With public networks, you can configure your i p using aesthetic I meaning that the I p would not change.
Be careful, because if your I p changes suddenly the your public network would not be accessible.
Next we have private networks.
So again, just like with public networks were private networks. You could use d HCP dynamic host configuration protocol where, uh, I P address is dynamically assigned and again you will use the same steps as with the public
network. Once you have your I p,
then you will create a secure shell using the vagrant ssh Command and then using the I f config command if its limits or I peek i p config command. Scuse me if his windows
to figure out your i p address Now again, with private networks, you can assign a static I fi.
What? Whether you use d HCP or you use a static I p. You need to make sure your I p is not publicly route herbal.
If it is rideable, then anyone can access this network and it will not be private.
Also for static are peas for both public and private.
You can use I p Internet Protocol version for or Internet protocol version six and again, just like with TCP UDP d h c p I P I P version for an i p version six.
Again, If you want to learn the nuts and bolts, you will need to take networking quarters.
But to give you a quick primer.
The Internet currently is using I P version for
for I P addresses, but we're moving toe I p version six because we're running out of I P addresses in the version for
standard. So we need to move to version six to give us mawr I p addresses Quick quiz.
What are the different ways you could configure a network? A publicly be privately see using port fording d all of the above.
I would give you a couple of seconds and I will come back with my answer. Let's start now. And the answer is that the, uh
d all of the above
we can configure a network using public networks, private networks or with Port 40.
So it's summary. In this video we discuss port 40
public networks and private networks.
Now we have an end of lecture quiz
What are the different ways you could configure a public network A. D a C P B static eyepiece, sea shell scripts or D A. M B.
I will give you a couple of seconds and I will come back with my answer. Let's start now.
And the answer is that, uh,
d a m b
remember, we can use d HCP dynamic host configuration protocol where r. I P s are dynamically assigned when we start our machine, or we can use static I P's where r I P is fixed and it will not change a caveat of that is
make sure that the I P doesn't change, because if it does, then your network would not be accessible. Sea Shell scripts don't relate to networking. It actually relates to our next lecture on provisioning. So that's out
and the answer is D A and B.
So I hope that you have learned a lot in this lecture with port forging public private Networks
and our next three videos. I will show you DIMOs on the topics we discussed port fording public networks and private networks. And then our next lecture, I give you a quick introduction with this question. We will talk about provisioning
how it relates to vagrant, how we can create in line scripts, which are basically scripts that print to the consul and external scripts, where we can install software and with provisioning. It's
automated and repeatable, which means we can create the script once and executed as many times as we want, which is powerful, and you will see that in the demos for that lecture. So, as I said, I hope you learned a lot
in this lecture, and I can't wait to see you in the demos for
Port fording public networks, it private networks in in our next lecture that talks about provisioning in vagrant
Thank you. Have a good day. Bye.