In this lesson, we'll learn how to configure network settings on
Ubuntu.
Let's start with the basic concepts. First
to be able to communicate across networks. A device needs an IP address
IP stands for internet protocol
and there are two kinds of IPs
IPv4
and IPv6.
The V here stands for version
and in version four of the internet protocol addresses look like this.
Basically four numbers that can take values from 0 to 255.
Why these specific values?
Because internally computers use eight bits for each number here and
eight bits can represent a number from 0 to 255.
For example,
000000000 is binary zero in decimal notation.
And you can see here 1234 and so on
all the way up to
all the way to solid ones, which is 255.
So an IP like 1921681101 and decimal
is actually this in binary.
And this binary representation is important for the next thing we'll discuss.
Sometimes we will see IP S displayed in this format.
We have the IP address with a slash 24. At the end,
this is called
Cidr notation or CI Dr which is an abbreviation for classless inter domain routing.
We can see an extra slash 24 at the end next to the IP address.
This tells us that the 1st 24 bits of this address are the prefix of this network.
If we take another look at the binary notation,
this will become easier to understand.
So 1921681101 in binary is this
and we can see that the 1st 24 bits align with
the first three numbers we have in this IP address,
which means that 1921681
is the network prefix.
Basically the address of the network itself.
And the last part
101
refers to a specific device on that network.
It's somewhat similar to phone numbers.
For example, if you call someone from Italy,
you need to use the plus 3 9 prefix
when you call plus 3 +9123456789.
The first part plus 3 9 is the country prefix
and a +123456789 is the personal number of the person you're calling.
So a network prefix is analogous to a country prefix in phone numbers.
So a network prefix is just like a country prefix and phone numbers.
If a device knows that the
Cidr notation of a network IP is
24.
Then it understands that 1921681 refers to the generic network prefix
and 101 to a specific host on this network.
This also means that any IP from 1921681.0
all the way to 1921681.2 55 is part of the same network,
but an IP like 1921682101 is part of a different network
because the prefix does not have the same initial three numbers.
Or if we think in binary, it does not have the same 1st 24 bits as the slash 24
Cidr notation indicates that it should have.
Now, if the
Cidr notation would be different,
for example, 1921681101 slash 16,
we get something along these lines.
The 1st 16 bits would be the network prefix
and the second would be the host.
So in this case,
just the 1st 16 bits of the network prefix which coincide with the first two numbers,
192168.
That means the last two numbers.
Now 1.101 refer to a host or device connected to this network.
In other words, for our current
Cidr notation,
any IP in this network must begin with a fixed 192168.
While the last two numbers can be anything from 0 to 255.
So we can have IP S from 1921680.0
all the way to 1921682 55.2 55.
Now let's look at IPv6.
Now these addresses have 100 and 28 bits instead of 32 bits like IPv4,
these addresses have 100 and 28 bits instead of 32 bits.
As this case for IPv4.
Here's an example of an IPv6 address.
Now we notice that this is a bit different in three ways.
For one, we have eight groups of numbers here instead of four like we had with IP V four
two, these numbers are not in decimal format
instead they're in hexadecimal format.
There are 16 hexadecimal digits
0123456789
and AB CD ef.
In this case,
the letter A is equivalent to the number 10
in our decimal format that we use every day.
B is 11 C is 12 all the way up to F which is 15.
So a number like FFFF is equivalent to 65535 and decimal notation
and all ones in binary.
And the third difference is that each number
here is separated by a semicolon character.
Since these IPv6 addresses are quite long, we'll often see them shortened.
So an IP like this
will usually be shortened to something like this.
And this is done by removing all of the leading zeros. First.
For example, we can see that zero db eight became db eight
and the consecutive group of zeros and
semicolons was abbreviated to two consecutive semicolon characters
IPv6 addresses also support the Cider notation.
So an address like this with the slash 64
signals that the 1st 64 bits represent the network prefix
and each group of two hexadecimal digits is eight bits.
So 64 bits would mean eight groups.
Now, in this case,
we've highlighted in purple, the network prefix of this IP for a slash 64
cidr notation.
And of course, if the IP is shortened,
you'll usually see it noted like this
as we can see for prefixes that are multiples of the number.
Eight things are straightforward enough.
Unfortunately, some
Cidr notations can be a bit harder to understand
if the prefix is 20 bits.
For example,
this doesn't coincide with the first three numbers of an IPv4 address anymore.
But there are online tools to help you decipher
or calculate the Cider notations you need to use,
just look up Cider calculator or Subnet
calculator on the internet.