Finding TUN device name

Type:

grep -i ,ifname= scriptname

e.g.:

grep -i ,ifname= ${VMDirBas}/execbin/${VMGenNam}/${VMLILNAM}/sysstart/exc_${VMLILNAM}

e.g. output:

export CLIOPTVMNICONE=" -net tap${VMNICONEALTVLAN},ifname=${VMNICONETUNDEV}\

In this case, the tun interface (which is the part after the ,ifname= contains a variable name. So let's figure out the values of any variable.

grep -i VMNICONETUNDEV ${VMDirBas}/execbin/${VMGenNam}/${VMLILNAM}/sysstart/exc_${VMLILNAM}

There may be multiple lines of output. The one of interest is the one that starts with export and contains the variable name being searched for.

export VMNICONETUNDEV=tun${VMNICONEVLANNUM}

So, in this example, the desired tunnel interface name starts with the phrase “tun” and contains a variable. Figure out the value of that variable.

grep -i VMNICONEVLANNUM ${VMDirBas}/execbin/${VMGenNam}/${VMLILNAM}/sysstart/exc_${VMLILNAM}

There may be multiple lines of output. The one of interest is the one that starts with export and contains the variable name being searched for.

export VMNICONEVLANNUM="1${VMNUM}"

The quotation marks will get eaten up by the shell, so they aren't actually part of the variable's value. So the tunnel interface number starts with 1, and then contains the virtual machine number.

grep -i VMNUM ${VMDirBas}/execbin/${VMGenNam}/${VMLILNAM}/sysstart/exc_${VMLILNAM}

There may be multiple lines of output. The one of interest is the one that starts with export and contains the variable name being searched for.

export VMNUM=22

Based on this example, it seems the command will run “ifname=tun122”. So, the name of the tunnel interface is the part after the equal sign. This sample of 122 is based on NIC 1 of the machine with 22. Other virtual machines would have other numbers, so customize this number as needed.