get DNS Suffix

This commit is contained in:
ricardopolo 2019-11-01 10:33:33 -05:00
parent bc335781fe
commit 03eae68972

View File

@ -325,7 +325,7 @@ function getInterfaceConnectionName(interfaceName) {
} }
} }
function getDHCPstatus(connectionName) { function getInterfaceDHCPstatus(connectionName) {
if(connectionName) { if(connectionName) {
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`; const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`;
try { try {
@ -351,7 +351,21 @@ function getDHCPstatus(connectionName) {
} }
} }
function getInterfaceDNSsuffix(connectionName) {
if(connectionName) {
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.dns-search;`;
try {
const result = execSync(cmd).toString();
const resultFormat = result.replace(/\s+/g,' ').trim();
const dnsSuffix = resultFormat.split(" ").slice(1).toString();
return dnsSuffix;
} catch (e) {
return 'Unknow';
}
} else {
return 'Unknow';
}
}
function testVirtualNic(iface, ifaceName, mac) { function testVirtualNic(iface, ifaceName, mac) {
const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97']; const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97'];
@ -421,6 +435,7 @@ function networkInterfaces(callback) {
let carrierChanges = 0; let carrierChanges = 0;
let operstate = 'down'; let operstate = 'down';
let dhcp = false; let dhcp = false;
let dnsSuffix = '';
let type = ''; let type = '';
if (ifaces.hasOwnProperty(dev)) { if (ifaces.hasOwnProperty(dev)) {
@ -475,7 +490,8 @@ function networkInterfaces(callback) {
try { try {
const connectionName = getInterfaceConnectionName(iface); const connectionName = getInterfaceConnectionName(iface);
dhcp = getDHCPstatus(connectionName); dhcp = getInterfaceDHCPstatus(connectionName);
dnsSuffix = getInterfaceDNSsuffix(connectionName);
lines = execSync(cmd).toString().split('\n'); lines = execSync(cmd).toString().split('\n');
@ -527,6 +543,7 @@ function networkInterfaces(callback) {
mtu, mtu,
speed, speed,
dhcp, dhcp,
dnsSuffix,
carrierChanges, carrierChanges,
}); });
} }