By Mouhamadou Diaw
In a previous blog , I was talking about virtual machines on ODA servers. Sometimes it comes that we want to add another network interface for other purpose.
In this blog I am describing the main tasks to add a second network interface card on KVM virtual machine. Let’s describe the context
I have an ODA X8-2M with appliance 19.12. This ODA contains virtual machines for the applications. The virtual machine only has one NIC used for the public connexion. The idea is to add a second network interface that will be used for the backups
-The oda server : oda-dev-01
-The virtual machine : vmserver_appli
We show the actual network configuration for the virtual machine vmserver-appli. Only eth0 is present in the VM.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@vmserver-appli ~]# ip a1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:e9:26:18 brd ff:ff:ff:ff:ff:ff inet 10.18.35.139/24 brd 10.18.35.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet6 fe80::f7a:d225:d568:5afa/64 scope link noprefixroute valid_lft forever preferred_lft forever[root@vmserver-appli ~]# |
As we can see below the eth0 is actually using the vNetwork pubnet of the physical ODA server. The pubnet is configured with the btbond1.
|
1
2
3
4
5
6
7
|
[root@oda-dev-01 ~]# odacli list-vnetworksName Type Interface Bridge Uniform Created Updated-------------------- --------------- --------------- -------------------- -------- ----------------------- -----------------------pubnet Bridged btbond1 pubnet NO 2021-09-27 10:55:41 2021-09-27 10:55:41 CEST CEST[root@oda-dev-01 ~]# |
In the ODA there is a second configured bonding with btbond2.
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@oda-dev-01 network-scripts]# cat ifcfg-btbond2# This file is automatically created by the ODA software.DEVICE=btbond2ONBOOT=yesBOOTPROTO=noneUSERCTL=noTYPE=BONDIPV6INIT=noNM_CONTROLLED=noPEERDNS=noBONDING_OPTS="mode=active-backup miimon=100 primary=p7p3"[root@oda-dev-01 network-scripts]# |
As we can see btbond2 is not used yet compared to btbond1 used for the pubnet vNetwork
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@oda-dev-01 network-scripts]# cat ifcfg-btbond1# This file is automatically created by the ODA software.DEVICE=btbond1ONBOOT=yesUSERCTL=noTYPE=BONDIPV6INIT=noNM_CONTROLLED=noPEERDNS=noBONDING_OPTS="mode=active-backup miimon=100 primary=p7p1"BRIDGE=pubnet[root@oda-dev-01 network-scripts]# |
So the idea is to create backupnet vNetwork based on btbond2. Later the backupnet vNetwork will be attached to the virtual machine.The command odacli create-vnetwork is used to create backupnet
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@oda-dev-01 network-scripts]# odacli create-vnetwork --name backupnet --bridge backupnet --type bridged --interface btbond2 --ip 10.18.45.55 --gateway 10.18.45.1 --netmask 255.255.255.128Job details---------------------------------------------------------------- ID: f3490869-1d38-4562-928f-644e971b24cd Description: vNetwork backupnet creation Status: Created Created: January 20, 2022 10:39:12 AM CET Message:Task Name Start Time End Time Status---------------------------------------- ----------------------------------- ----------------------------------- ----------[root@oda-dev-01 network-scripts]# |
We verify that the job is ok
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@oda-dev-01 network-scripts]# odacli describe-job -i f3490869-1d38-4562-928f-644e971b24cdJob details---------------------------------------------------------------- ID: f3490869-1d38-4562-928f-644e971b24cd Description: vNetwork backupnet creation Status: Success Created: January 20, 2022 10:39:12 AM CET Message:Task Name Start Time End Time Status---------------------------------------- ----------------------------------- ----------------------------------- ----------Validate Virtual Network doesn't exist January 20, 2022 10:39:12 AM CET January 20, 2022 10:39:12 AM CET SuccessValidate interface to use exists January 20, 2022 10:39:12 AM CET January 20, 2022 10:39:12 AM CET SuccessValidate interfaces to create not exist January 20, 2022 10:39:12 AM CET January 20, 2022 10:39:12 AM CET SuccessValidate interface is not default January 20, 2022 10:39:12 AM CET January 20, 2022 10:39:12 AM CET SuccessCreate bridge from interface January 20, 2022 10:39:12 AM CET January 20, 2022 10:39:18 AM CET SuccessCreate metadata January 20, 2022 10:39:18 AM CET January 20, 2022 10:39:18 AM CET SuccessPersist metadata January 20, 2022 10:39:18 AM CET January 20, 2022 10:39:18 AM CET Success[root@oda-dev-01 network-scripts]# |
And we can then list the vNetworks in the ODA
|
1
2
3
4
5
6
7
8
|
[root@oda-dev-01 network-scripts]# odacli list-vnetworksName Type Interface Bridge Uniform Created Updated-------------------- --------------- --------------- -------------------- -------- ----------------------- -----------------------pubnet Bridged btbond1 pubnet NO 2021-09-27 10:55:41 2021-09-27 10:55:41 CEST CESTbackupnet Bridged btbond2 backupnet NO 2022-01-20 10:39:18 CET 2022-01-20 10:39:18 CET[root@oda-dev-01 network-scripts]# |
Let’s describe the VM that I want to add a second network interface. We can see that only one vNetwork (pubnet) is attached to the VM.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
[root@oda-dev-01 network-scripts]# odacli describe-vm -n vmserver-appliVM details-------------------------------------------------------------------------------- ID: 14f10064-a048-419d-a850-18b1d9b2b69e Name: vmserver-appli Created: 2021-10-21 14:51:50 CEST Updated: 2021-10-21 14:51:50 CEST VM Storage: storevms Description: Web site standby VM image path: /u05/app/sharedrepo/storevms/.ACFS/snaps/vm_vmserver-appli/vmserver-appli VM size: 20.00 GB Source: V1009690-01.iso OS Type: NONE OS Variant: NONE Graphics settings: vnc,listen=127.0.0.1 Display Port: 127.0.0.1:1 Status-------------------------- Current node: oda-dev-01 Current state: ONLINE Target state: ONLINE Parameters-------------------------- Preferred node: NONE Boot option: NONE Auto start: YES Fail over: NO NUMA enabled: NO Config Live ------------------------- ------------------------- Memory: 4.00 GB 4.00 GB Max Memory: 8.00 GB 8.00 GB vCPU count: 3 3 Max vCPU count: 6 6 CPU Pool: cpuvms cpuvms Effective CPU set: 1-9,17-25,33-41,49-57 1-9,17-25,33-41,49-57 vCPUs: 0:1-9,17-25,33-41,49-57 0:1-9,17-25,33-41,49-57 1:1-9,17-25,33-41,49-57 1:1-9,17-25,33-41,49-57 2:1-9,17-25,33-41,49-57 2:1-9,17-25,33-41,49-57 vDisks: vdisk2webs21:vdc vdisk2webs21:vdc vdisk1webs21:vdb vdisk1webs21:vdb vNetworks: pubnet:52:54:00:e9:26:18 pubnet:52:54:00:e9:26:18[root@oda-dev-01 network-scripts]# |
Again on the virtual machine only one NIC eth0 is configured
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@vmserver-appli ~]# ip a1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:e9:26:18 brd ff:ff:ff:ff:ff:ff inet 10.18.35.139/24 brd 10.18.35.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet6 fe80::f7a:d225:d568:5afa/64 scope link noprefixroute valid_lft forever preferred_lft forever[root@vmserver-appli ~]# |
To add a second network interface, let’s attach the backupnet vNetwork to the VM . Just note the use both –live and –config
–live: The change is applied to the running VM instance, but does not persist after the VM stops.
–config: The change persists in the configuration of VM instance and takes effect on subsequent reboots.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@oda-dev-01 network-scripts]# odacli modify-vm -n vmserver-appli -avn backupnet --live --configJob details---------------------------------------------------------------- ID: 8da2a4cc-528c-47d9-bcb0-4481010c73f3 Description: VM vmserver-appli modification Status: Created Created: January 20, 2022 10:48:25 AM CET Message:Task Name Start Time End Time Status---------------------------------------- ----------------------------------- ----------------------------------- ----------[root@oda-dev-01 network-scripts]# |
Let’s verify that the job returns SUCCESS
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@oda-dev-01 network-scripts]# odacli describe-job -i 8da2a4cc-528c-47d9-bcb0-4481010c73f3Job details---------------------------------------------------------------- ID: 8da2a4cc-528c-47d9-bcb0-4481010c73f3 Description: VM vmserver-appli modification Status: Success Created: January 20, 2022 10:48:25 AM CET Message:Task Name Start Time End Time Status---------------------------------------- ----------------------------------- ----------------------------------- ----------Validate VM exists January 20, 2022 10:48:25 AM CET January 20, 2022 10:48:25 AM CET SuccessValidate network attachment pre-reqs January 20, 2022 10:48:25 AM CET January 20, 2022 10:48:25 AM CET SuccessAttach vNetworks January 20, 2022 10:48:25 AM CET January 20, 2022 10:48:25 AM CET SuccessSave configuration in ACFS January 20, 2022 10:48:25 AM CET January 20, 2022 10:48:25 AM CET SuccessSave live VM configuration in ACFS January 20, 2022 10:48:25 AM CET January 20, 2022 10:48:26 AM CET SuccessModify VM metadata January 20, 2022 10:48:26 AM CET January 20, 2022 10:48:26 AM CET SuccessPersist metadata January 20, 2022 10:48:26 AM CET January 20, 2022 10:48:26 AM CET Success[root@oda-dev-01 network-scripts]# |
Describing again the VM, we can see that the backupnet vNetwork is now attached and persistent
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
[root@oda-dev-01 network-scripts]# odacli describe-vm -n vmserver-appliVM details-------------------------------------------------------------------------------- ID: 14f10064-a048-419d-a850-18b1d9b2b69e Name: vmserver-appli Created: 2021-10-21 14:51:50 CEST Updated: 2022-01-20 10:48:26 CET VM Storage: storevms Description: Web site standby VM image path: /u05/app/sharedrepo/storevms/.ACFS/snaps/vm_vmserver-appli/vmserver-appli VM size: 20.00 GB Source: V1009690-01.iso OS Type: NONE OS Variant: NONE Graphics settings: vnc,listen=127.0.0.1 Display Port: 127.0.0.1:1 Status-------------------------- Current node: oda-dev-01 Current state: ONLINE Target state: ONLINE Parameters-------------------------- Preferred node: NONE Boot option: NONE Auto start: YES Fail over: NO NUMA enabled: NO Config Live ------------------------- ------------------------- Memory: 4.00 GB 4.00 GB Max Memory: 8.00 GB 8.00 GB vCPU count: 3 3 Max vCPU count: 6 6 CPU Pool: cpuvms cpuvms Effective CPU set: 1-9,17-25,33-41,49-57 1-9,17-25,33-41,49-57 vCPUs: 0:1-9,17-25,33-41,49-57 0:1-9,17-25,33-41,49-57 1:1-9,17-25,33-41,49-57 1:1-9,17-25,33-41,49-57 2:1-9,17-25,33-41,49-57 2:1-9,17-25,33-41,49-57 vDisks: vdisk2webs21:vdc vdisk2webs21:vdc vdisk1webs21:vdb vdisk1webs21:vdb vNetworks: backupnet:52:54:00:b2:ae:94 backupnet:52:54:00:b2:ae:94 pubnet:52:54:00:e9:26:18 pubnet:52:54:00:e9:26:18[root@oda-dev-01 network-scripts]# |
Connecting on the VM, we can see that there is a second network interface card eth1.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@vmserver-appli ~]# ip a1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:e9:26:18 brd ff:ff:ff:ff:ff:ff inet 10.18.35.139/24 brd 10.18.35.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet6 fe80::f7a:d225:d568:5afa/64 scope link noprefixroute valid_lft forever preferred_lft forever3: eth1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:b2:ae:94 brd ff:ff:ff:ff:ff:ff[root@vmserver-appli ~]# |
Now you can configure this second network card according to your needs
Conclusion
Hope this blog will help. Just a recommendation is to always restart VMs with odacli stop-vm after modifications, this will validate that your changes are persistent or not