[No audio]
Hello everyone.
Since we are on a network configuration part
of the Linux, we'll talk about NIC bonding.
What exactly the NIC bonding is?
Just to let you know, NIC bonding is
one of the very important and critical aspect
in Linux number configuration and this type of
questions are asked oftentimes in an interview.
So let's see a NIC. A NIC stands for Network
Interface Card that is attached to your computer.
So if you look at your laptop or behind your PC,
you will see a little port in there and that port
is your NIC. With NIC, which is Network Interface Card
bonding is also known as network bonding.
It can be defined as the aggregation or combination
of multiple NIC into a single bond interface.
Its main purpose is to
provide high availability and redundancy.
So let's look at our picture.
We have this four NIC cards on our computer.
So what we do in NIC bonding is we take two
ports, we combine them together and the reason we combine them
because what if one port dies, we still have another port.
So this is for the redundancy.
So another way to make two ports redundant or to
have them high availability is you combine them together.
If a port is one gig and the other
port is one gig, you combine them together to
aggregate them and get the throughput of two gigs.
This is achieved for high
availability and link aggregation.
So NIC bonding procedure is that you type
modprobe bonding, which is to get the
configuration of your driver, info bonding
to get the information of your bonding.
Then you create a file called ifcfg-bond0.
You edit the first ethernet1, you edit the second
ethernet, and you combine them and point to bond0.
If you have nic1 file, you create another
nic2 file for the second NIC, and then
you create a third file called bond0.
You point your nic1 and
nic2 files toward bond0.
And then what do you do at the end?
You restart the network of your computer.
So the command is systemctl restart network.
So without further ado, I will log into my system and
I'll tell you exactly how NIC bonding can be done.
And before we start this VirtualBox,
I want you to take a snapshot.
The reason I'm taking a snapshot is so we could
work back to its state, which is where it is
right now after we do all the configuration.
So right here you see Snapshots.
Click on Snapshot and right here it says Take.
Click on the Take, leave the snapshot number
1 as a name default and click OK,
now it has taken the snapshot.
Now I want you to click on Setting.
[No audio]
Go to Network, click on Network Adapter to check.
Enable Network Adapter, and select Bridged Adapter.
Now we will have two NICs on a computer
which is one here Adapter 1 and Adapter 2.
If you want more adapters,
we could go to Adapter 3 and 4, and
check on Enable Network Adapter, but we will work
only Adapter 1 and Adapter 2 at this time.
And I want you to click OK. So once the
setting is done, go ahead and click on Start.
[No audio]
Go ahead and login as yourself.
[No audio]
Okay, when you have the Desktop, right click
on your Desktop, and open up your terminal.
[No audio]
I would like to make the
console, the terminal a little bigger.
Okay, go ahead and type ifconfig,
and do more on the output.
And here you will see now
we have two network interfaces.
One is enp0s3, and the second one is enp0s8.
enp0s8 is the one that we just added to our Oracle VirtualBox.
Now what we want to do is we want to
combine these two, 3 and 8 together and make a
bond out of these two interfaces.
[No audio]
Become root first, let's clear the screen.
Now I will open up a document that I have
that has all the commands and configuration in my document.
This document is also added as part of your handouts.
So before you do this exercise, I want you
to also open up this document from your handouts.
Have it side by side while
you do the configuration of bonding.
So I have already opened this document.
[No audio]
Okay, so now it says just follow the directions.
It says, Add a new NIC if it does not exist.
Install bonding driver = modprobe bonding.
You need to install this if
you don't have bonding enabled.
But let's say if you do have it or not, so do
modinfo bonding, and I want you to do more on it.
And once you do more, and if you
get the output and description says Ethernet Channel Bonding Driver, v3.7.1,
that means you already have the driver installed,
which is the modprobe in Linux,
so you don't have to worry about installing it.
So you can move on to the next step.
Okay, the next step is to create a
new file called ifcfg-bond0 right here.
And I have to create this file
in this directory, in this path.
So if I copy and paste it's not going to work.
So I have to type it.
So I go back into our machine
and I'll do vi /etc/sysconfig/network
-scripts/ifcfg-bond0.
[No audio]
Now you are in vi mode.
Hit i to insert, and I want you
to start typing exactly what's written in there.
Please make sure don't make a mistake.
[No audio]
TYPE is Bond.
Name of this bond is bond0.
[No audio]
BONDING_MASTER, meaning who's the master of this bonding?
It's a self,
so yes. So BOOTPROTO,
[No audio]
so when you type none or static, it means the same thing.
So type none. ONBOOT yes.
[Author typing]
IPADDRESS
[Author typing]
I'm sorry, there's a little mistake.
It should be just IPADDR.
The IP that I have picked is 192.168.1.80
because I have already typed this IP before and I
know this IP does not exist, nobody has taken it.
But if you wanted to confirm if this IP is not taken,
you could just go into, you could open up another terminal and
do ping 192.168.1.80, and you will
see you are not getting a response back on that IP.
So it means it's not taken.
So I'll use IP.
I'm assigning the static IP.
NETMASK 255.255.255.0. GATEWAY,
Gateway is the IP address of your modem.
And then BONDING_OPTS equal mode = 5.
I'm picking mode five.
And what exactly mode five is or miimon is?
This is speed and the state.
I have also included that in my
document exactly what these options mean.
And I want you to review them and
you will know exactly what it means.
So now you could just save and exit the file.
[No audio]
Okay. Once you have that, it says bonding
options detail can be found here.
You see right here, it has all the options we picked.
If you remember, we picked option
five, which is transmit load balancing.
You could read about it.
And thenmiimon, which is a monitoring link,
monitoring frequency in milliseconds we picked 100.
Okay, so next step is it says, Edit
the first NIC file, which is enp0s3.
So I am in root directory.
I'll go into /etc/sysconfig.
Just drag this a little more so
you could see it a little better.
sysconfig cd network-script.
And in this directory I already have
a file called ifcfg-enp0s3. Do vi,
and now I have here I said delete the entire content.
So how do you delete it? In the vi
you do dd, dd, dd, dd.
Keep doing dd until you go to the bottom.
You are at the bottom and it says, No lines in buffer.
That's good. Now hit Enter.
Sorry, hit insert.
You probably have to hit insert a
couple of times to get it.
So now keep typing what exactly it's in there?
So TYPE = Ethernet, BOOTPROBE = none,
DEVICE
[No audio]
enp0s3.
[No audio]
ONBOOT = yes, you want to have that boot. HWADDR,
this is a new one.
Now this is the Mac address of your enp0s3.
So what is my hardware Mac address?
You have to open up another terminal in the back, drag
it, and then just type ifconfig, and do more.
And you will see enp0s3 has a Mac address of this.
[No audio]
So what I will do is, I'll drag this a little bit on
top, I'll bring the other window in the back.
And now I could type the address 08:00:27:c3:0e:28.
Verify it, 27:c3:0e:28. Yes
And then hit enter. MASTER,
it's asking you who's your master?
The master is bond0, which is the other
file that we created before that, hit Enter, SLAVE.
Are you a SLAVE?
Meaning this interface, is it a slave?
We'll say yes.
Check again. BOOTPROTO, we missed one.
Oh, no, we did not. It's there.
TYPE, BOOTPROTO, DEVICE, ONBOOT, HWADDR which is
the Mac address, MASTER bond0, and SLAVE.
Now save and exit.
Okay, now follow the directions.
Okay, now it says create the second
NIC file for emp0s8.
I could create a second one, or I could just copy
this, enp0s3 and change the name and Mac address
so it would be easier, I could
just copy enp0s3, and I name it icfcg-enp0s3, and take out,
replace 3 with 8.
Now it's copied.
Now vi ifcfg-enp0s8,
now it's 0s8,
you have to change this 3rd line which says DEVICE,
0s3 with 8,
yes, yes.
And now the Mac address would be different.
Go back to your other command that is open,
drag it up and you will see here, the
Mac address for enp0s8 is this one.
So once you have it highlighted, drag
it down so you could see it.
And now change it.
It is changed after the three optics.
So 0d:17:9b.
Okay, bond0, master is the bond0. Slave,
yes, I am a slave for bond0.
Then write quit, and save the file.
The file is saved.
Now I want to restart the service systemctl, restart the network
service, network restart,
hit enter, by running
ifconfig do the more on it. And you'll see
now the IP that I have
assigned says right here 192.168.1.80.
It's master and the other ports, sorry,
other NICs enp0s3 and s8,
you see here, right here, it
says these are SLAVE and SLAVE.
So IP assigned is given 192.168.1.80.
I'm going to take this IP, plug it into my
PuTTY session and see if I could connect to it.
192.168.1.80. Hit enter.
Yes, I could connect.
This is just the SSH key warning sign.
You could just accept it to save it
and log in and yes, there you go.
So now you know that your interface is
combined together and pointing it to bond0.
Any other instructions that we have, you could go down.
You can also see here, it's telling me
that I could verify the setting by doing
cat /proc/net/bonding/bond0.
When I do that, let me make this bigger,
and now you'll see here when I did the cat
you see it says Currently Active Slave is this one.
It is load balancing. Slave Interface is
this, and second Slave Interface is this.
Now, once it is done, I want you
to revert back to your original VM.
So just close it, power it off.
Close and says power off the machine.
You power it off.
Now go to your Oracle virtual machine right here.
And first once wait for it to power off,
then go to Settings and then come to Network,
go to network Adapter 2.
Unchecked the one we checked before. Click
OK, now it should not have the second adapter.
But I want you to click now to
the Snapshot 1, and click on Restore.
Now this is going to restore to the
original state where we had it before.
Here it will create another snapshot of your
current state which I don't want you to
do, so uncheck this box and click Restore.
Now it is restored to exactly same way
where it was before we started this lesson.
All right guys, I hope you enjoyed
it and please try right on.
This is one of the topic that's very important.
You will be working on a physical machines most of
the time when you have to do network bonding.
[No audio]