The defines the named view. TYPE is either included or excluded. MASK is a list of hex octets, separated by '.' or ':'. The MASK defaults to "ff" if not specified. The reason for the mask is, that it allows you to control access to one row in a table, in a relatively simple way. As an example, as an ISP you might consider giving each customer access to his or her own interface:
view cust1 included interfaces.ifTable.ifEntry.ifIndex.1 ff.a0 view cust2 included interfaces.ifTable.ifEntry.ifIndex.2 ff.a0
(interfaces.ifTable.ifEntry.ifIndex.1 == .1.3.6.1.2.1.2.2.1.1.1, ff.a0 == 11111111.10100000. which nicely covers up and including the row index, but lets the user vary the field of the row)
文档中指出:
mask 是使用 . 或者 : 分隔的十六进制数
在未指定的情况下,mask 的默认值是 ff
mask 的主要作用是使你能够限制用户只允许访问 OID
表中的某一行数据
针对以上的帮助文档,下图能够更加形象化的理解 mask 的作用:
mask 中的每一 bit 都指示 OID 树对应的层级的访问权限,1
表示可访问,0表示不可访问。在上面的例子中,view cust1 允许用户访问
ifTable中第一行的所有列内容, 也就是 ifTable 表中第一行实例内容。
MacBook-Pro:gitblog carya$ snmpwalk -v 2c -c public localhost .1.3.6.1.2.1.2.2.1.1 IF-MIB::ifIndex.1 = INTEGER: 1 MacBook-Pro:gitblog carya$ snmpget -v 2c -c public localhost .1.3.6.1.2.1.2.2.1.1.1 IF-MIB::ifIndex.1 = INTEGER: 1 MacBook-Pro:gitblog carya$ snmpget -v 2c -c public localhost .1.3.6.1.2.1.2.2.1.1.2 IF-MIB::ifIndex.2 = No Such Object available on this agent at this OID