2016-09-22 12:43:57 +00:00
|
|
|
---
|
|
|
|
title: About the interface Resource
|
|
|
|
---
|
|
|
|
|
|
|
|
# interface
|
|
|
|
|
2017-05-18 19:25:16 +00:00
|
|
|
Use the `interface` InSpec audit resource to test basic network adapter properties, such as name, status, and link speed (in MB/sec).
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
* On Linux platforms, `/sys/class/net/#{iface}` is used as source
|
|
|
|
* On the Windows platform, the `Get-NetAdapter` cmdlet is used as source
|
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
|
|
|
|
2016-09-27 19:03:23 +00:00
|
|
|
## Syntax
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
An `interface` resource block declares network interface properties to be tested:
|
|
|
|
|
2017-05-18 19:28:19 +00:00
|
|
|
describe interface('eth0') do
|
2016-09-22 12:43:57 +00:00
|
|
|
it { should be_up }
|
|
|
|
its('speed') { should eq 1000 }
|
|
|
|
its('name') { should eq eth0 }
|
|
|
|
end
|
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
2018-02-15 14:33:22 +00:00
|
|
|
## Properties
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2018-02-08 21:43:50 +00:00
|
|
|
`name`, `speed`
|
|
|
|
<br>
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2018-02-08 21:43:50 +00:00
|
|
|
## Resource Property Examples
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2016-09-27 19:03:23 +00:00
|
|
|
### name
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
The `name` matcher tests if the named network interface exists:
|
|
|
|
|
|
|
|
its('name') { should eq eth0 }
|
|
|
|
|
2016-09-27 19:03:23 +00:00
|
|
|
### speed
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
The `speed` matcher tests the speed of the network interface, in MB/sec:
|
|
|
|
|
|
|
|
its('speed') { should eq 1000 }
|
2018-02-08 21:43:50 +00:00
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
## Matchers
|
|
|
|
|
|
|
|
For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
|
|
|
|
|
|
|
### be_up
|
|
|
|
|
|
|
|
The `be_up` matcher tests if the network interface is available:
|
|
|
|
|
|
|
|
it { should be_up }
|
|
|
|
|