WEBVTT

00:00.810 --> 00:06.780
In this series of lectures, we get our networking basics right.

00:06.800 --> 00:15.200
We look at basic networking concepts like Switching, Routing, Gateways etc.  We then understand DNS,  and

00:15.200 --> 00:18.290
then we get a basic introduction to core DNS.

00:18.680 --> 00:28.930
We look at how to configure DNS settings on a Linux system within understand basics of network namespace

00:28.930 --> 00:31.060
in Linux.

00:31.160 --> 00:36.060
I am not going to bore you with theories on OSI models or network layers

00:36.260 --> 00:42.890
We're just brushing up enough networking to understand the rest of the section in this course.

00:42.960 --> 00:48.470
Now we don't just go through the concepts we see how these are configured on our systems specifically

00:48.770 --> 00:51.020
from a Linux perspective.

00:51.020 --> 00:53.670
So there are going to be lots of commands.

00:53.870 --> 01:00.680
We look at this from a system admins and the application developers perspective and not necessarily

01:00.680 --> 01:07.390
from a network engineers that way later on when we discuss these in the context of our course.

01:07.580 --> 01:13.460
You know what we were talking about where to look for information where things are configured how to

01:13.460 --> 01:22.480
troubleshoot etc. And of course as always if these seem to be too basic for you if you or if you're

01:22.500 --> 01:29.370
already good with networking in Linux feel free to skip these lectures and go straight to the ones on

01:29.370 --> 01:30.530
Kubernetes.

01:30.660 --> 01:31.760
So let's get started.

01:33.370 --> 01:34.250
So what is a

01:34.320 --> 01:35.160
Network.

01:35.320 --> 01:41.650
We have two computers A & B – laptops, desktops, VMs on the cloud, wherever.

01:41.650 --> 01:43.870
How does system A reach B?

01:43.880 --> 01:51.070
We connect them to a switch, and the switch creates a network containing the two systems. To connect

01:51.070 --> 01:52.420
them to a switch

01:52.420 --> 02:00.100
we need an interface on each host. Physical or virtual depending on the host to see the interfaces for

02:00.100 --> 02:00.970
the host.

02:01.000 --> 02:03.730
We use the IP link command.

02:04.060 --> 02:11.270
In this case, we look at the interface named eth0 that we will be using to connect to the switch.

02:11.320 --> 02:13.960
Let's assume it's a network with the address.

02:13.960 --> 02:16.900
192.168.1.0.

02:17.020 --> 02:21.270
We then assign the systems with IP addresses on the same network.

02:21.310 --> 02:29.400
For this, we use the command ip addr. Once the links are up, and the IP addresses are assigned,

02:29.410 --> 02:37.150
The computers can now communicate with each other through the switch the switch can only enable communication

02:37.300 --> 02:44.470
within and network which means it can receive packets from a host on the network and deliver it to other

02:44.470 --> 02:47.190
systems within the same network.

02:48.740 --> 02:56.450
Say we have another network containing systems C & D at address 192.168.2.0.

02:56.450 --> 03:02.570
The Systems have IP address 192.168.2.10 and 2.11 respectively.

03:02.600 --> 03:07.430
How does a system in one network reach a system in the other.

03:07.430 --> 03:16.040
How does System B with the IP 192.168.1.11 reach system C with the IP 2.10 on the

03:16.130 --> 03:17.690
other network.

03:17.990 --> 03:27.320
That’s where a Router comes in. A Router helps connect two networks together. It is an intelligent device,

03:27.320 --> 03:34.850
so think of it as another server with many network ports. Since it connects to the two separate networks,

03:34.850 --> 03:41.000
it gets two IPs assigned. One on each network. In the first network

03:41.000 --> 03:49.400
we assign it an IP address 192.168.1.1  and in the second we assign it an IP 192.168.2.1.

03:49.400 --> 03:55.260
Now we have a router connected to the two networks that can enable communication between them.

03:55.580 --> 04:02.720
Now, when system B tries to send a packet to system C, how does it know where the router is on the network

04:02.960 --> 04:08.930
to send the packet through the router is just another device on the network.

04:08.930 --> 04:18.150
there could be many other such devices. That’s where we configure the systems with a gateway or a route.

04:18.960 --> 04:25.800
If the network was a room, the gateway is a door to the outside world  to other networks or to the

04:25.800 --> 04:27.040
Internet.

04:27.120 --> 04:35.040
The systems need to know where that door is to go through that to see the existing routing configuration

04:35.100 --> 04:42.540
on a system run the route command. It displays the kernels routing table and within that, as you can

04:42.540 --> 04:45.290
see there are no routing configurations

04:45.300 --> 04:46.450
as of now.

04:46.450 --> 04:53.640
So in this condition your system B will not be able to reach system C it can only reach other systems

04:53.970 --> 05:03.110
within the same network in the range 192.168.1.0. To configure a gateway on system B to reach the

05:03.110 --> 05:10.750
systems on network 192.168.2.0, run the ip route add command, and specify that you can reach the

05:10.760 --> 05:19.340
192.168.2.0 network through the door or gateway at 192.168.1.11. Running the route

05:19.550 --> 05:26.690
command again shows that we have a route added to reach the 192.168.2.0 series network through the

05:26.690 --> 05:28.700
router.

05:28.710 --> 05:32.430
Now remember this has to be configured on all the systems.

05:32.440 --> 05:39.730
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

05:39.730 --> 05:46.340
routing table to access network 192.168.1.0 through the router configured with the IP address

05:46.350 --> 05:56.420
192.168.2.1.  Now suppose these systems need access to the Internet. Say they need access to Google at

05:56.430 --> 06:02.330
172.217.194.0 network on the internet. So you connect the router to the internet.

06:02.720 --> 06:10.290
and then add a new road in your routing table to road all traffic to the network 172.217.194

06:10.610 --> 06:17.420
through your router there are so many different sites on different networks on the Internet instead

06:17.420 --> 06:23.870
of adding a routing table entry for these same routers IP address for each of those networks you can

06:23.870 --> 06:31.740
simply say for any network that you don't know a route to use this router as the default gateway.

06:32.090 --> 06:38.510
This way any request to any network outside of your existing network goes to this particular router.

06:39.470 --> 06:46.970
So in a simple setup like this, all you need is a single routing table entry with a default gateway set

06:46.970 --> 06:49.700
to the routers IP address.

06:49.700 --> 06:54.630
Remember instead of the word default you could also say 0.0.0.0.0.

06:54.830 --> 06:57.450
It means any IP destination.

06:57.680 --> 07:02.640
Both of these lines mean the same thing. A 0.0.0.0

07:02.660 --> 07:08.890
Entry in the Gateway field indicates that you don't need a gateway for example in this case for system

07:08.900 --> 07:14.370
C to access any devices in the 192.168.2.0 network.

07:14.480 --> 07:20.930
It doesn't need a gateway because it is in its own network. But say you have multiple routers in your

07:20.930 --> 07:29.750
network one for the Internet another for the internal private network then you will need to have two

07:29.750 --> 07:32.510
separate entries for each network.

07:32.510 --> 07:39.320
One entry for the internal private network and another entry with the default gateway for all other

07:39.320 --> 07:42.240
networks including public networks.

07:42.260 --> 07:45.750
So if you are having issues  reaching internet from your systems,

07:46.010 --> 07:53.520
This routing table and the default gateway configuration is a good place to start let us know look at

07:53.700 --> 07:57.190
how we can set up a linux host as a rotor.

07:57.210 --> 07:58.590
Let's start with a simple setup.

07:59.650 --> 08:06.530
I have 3 hosts A, B and C.  A & B are connected to a network 192.168.1 and B

08:06.530 --> 08:14.360
& C to another on 192.168.2. So host B is connected to both the networks using two interfaces eth0

08:14.420 --> 08:24.550
A has IP 192.168.1.5, C has 192.168.2.5 and B has an IP on both the networks.

08:24.550 --> 08:28.280
192.168.1.6 and 192.168.2.6.

08:28.340 --> 08:31.800
How do we get A to talk to C? Basically,

08:31.850 --> 08:39.160
if I try to ping 192.168.2.5 from A, it would say Network is Unreachable.  And by now we know why that is.

08:39.290 --> 08:45.840
Host A has no idea how to reach a network at 192.168.2.

08:45.920 --> 08:54.260
We need to tell host A that the door or gateway to network 2 is through host B.  And we do that by adding

08:54.440 --> 09:03.350
adding a routing table entry. We add a route to access network 192.168.2 via the gateway

09:03.350 --> 09:12.130
192.168.1.6. If the packets where to get through to Host C, Host C will have to send back responses

09:12.130 --> 09:21.910
to Host A. When Host C tries to reach Host A at 192.168.1 network, it would face the same issue. So

09:21.910 --> 09:29.650
we need to let know Host C know that it can reach Host A through Host B which is acting as a router.  So we

09:29.650 --> 09:36.520
add a similar entry into Host C’s routing table. This time we say to reach network 192.168.1.0,

09:36.910 --> 09:46.460
talk to Host B at 192.168.2.6. When we try to ping now, we no longer get the Network Unreachable

09:46.490 --> 09:54.890
error message that means our routing entries are right but we still don't get any response back. By default

09:55.220 --> 10:02.420
in Linux, packets are not forwarded from one interface to the next for example packets received on eth0

10:02.430 --> 10:11.470
on host, B are not forwarded to elsewhere through eth 1 this is this way for security reasons.

10:11.480 --> 10:17.720
For example, if you had eth0 connected to your private network and eth1 to a public network, we

10:17.720 --> 10:23.450
don't want anyone from the public network to easily send messages to the private network unless you

10:23.540 --> 10:25.410
explicitly allow that.

10:25.700 --> 10:30.170
But in this case since we know that both are private networks and it is safe to enable communication

10:30.200 --> 10:37.810
between them we can allow host B to forward packets from one network to the other whether a host can

10:37.810 --> 10:47.190
forward packets between interfaces is governed by a setting in this system at file /proc/sys/net/ipv4/ip

10:47.190 --> 10:56.250
forward by default, the value in this file is set to 0 meaning no forward set

10:56.280 --> 10:59.830
this to 1 and you should see the pings go through.

10:59.840 --> 11:06.150
Now remember simply setting this value does not persist the changes across reboots for that you must

11:06.150 --> 11:12.020
modify the same value in the /etc/sysctl.conf file.

11:12.630 --> 11:16.080
So let's take away some key commands from this lecture.

11:16.080 --> 11:23.650
These will be handy in the upcoming lectures IP link is to list and modify interfaces on the host

11:23.670 --> 11:31.920
ip addr command is to see the ip addresses assigned to those interfaces  ip addr add command is used to set

11:32.190 --> 11:34.860
IP addresses on the interfaces.

11:34.860 --> 11:40.740
Now remember changed made using these commands are only valid till a restart. If you want to persist these

11:40.740 --> 11:49.110
changes you must set them in the /etc/network/interfaces file. ip route or simply the route command

11:49.110 --> 11:56.500
is used to view the routing table. And ip route add command is used to add entries into the routing table.

11:56.550 --> 12:02.290
And finally remember the command to check if IP forwarding is enabled on a host.

12:02.310 --> 12:08.480
If you're working with a house configured as a router Well that's it for this lecture in the next lecture.

12:08.500 --> 12:11.100
We'll discuss about DNS configurations.

