1. Cisco sandbox
sandbox 提供给我们一个免费的开发平台,可以基于该平台做很多和思科网络设备、软件有关的代码开发、脚本测试、自动化配置等工作:
- 学习研究网络知识,提升自己
- 学习研究思科设备、软件提供的 API 接口
- 全天候支持
- 提供虚拟机、模拟器、以及真实网络设备等选择
- 最重要的是,以上全免费
首次进入 sandbox,链接为:https://devnetsandbox.cisco.com/RM/Topology,登录即可使用,支持很多种登录方式:
2. Sandbox 提供 2 种模式的 lab
截止至 2018 年底,sandbox 提供了约 68 个 labs,按运行申请模式不同分为:
- Regular 58 个,需要预留单独使用,个性化配置
- Always_On 10 个,共享模式,一直在线提供访问,不允许修改配置
2.1. Always_On 特点
该类 lab 比较简单,为了解 cisco sandbox 提供一种快捷的实现方式:
- 不需要申请和预留,随时可以使用
- 无需初始化配置
- 共享访问
- API 支持
如果需要个性化的设置和复杂的网络拓扑结构,则需要申请使用 regular sandbox。
2.2. 可编程的 NX-OS lab
NX-OS Programmability是其中一个 Always on sandbox,该 lab 提供 nexus 3k/9K 的各种不同的设备访问方式,实现:
- 测试设备的可重复利用的、可编程的脚本自动化工具
- 测试 NXAPI 接口,包括 CLI、REST
- 测试 netconf
- YANG model
- restconf(草稿标准)
我们可以通过首页找到该 LAB,详细的信息请访问网页。
2.2.1. 简单的访问方法
由于是共享 lab,访问方式比较简单和固定:
- Nexus 9000v Host : sbx-nxos-mgmt.cisco.com
- SSH Port: 8181
- NETCONF Port: 10000
- NXAPI Ports: 80 (http) & 443 (HTTPS)
- RESTCONF Port : 443 (HTTPS)
- Credentials(demo 账户):
- Username: admin
- Password: Admin_1234!
如果需要尝试一下通过 nxapi 访问设备,可以在浏览器中输入地址:http://sbx-nxos-mgmt.cisco.com ,使用上述“demo 账户”的用户名和密码登录,即可以显示 Nexus 9K sandbox。
如图显示命令"show interface brief"的输出:
我们也可以使用 ssh 登录设备
ssh admin@sbx-nxos-mgmt.cisco.com -p 8181
检查刚刚通过 nxapi 访问设备的细节:
2018 December 30 09:57:55.897 ngx_http_auth_pam_authenticate:381 pid:31473 PAM: client ip len:12
2018 December 30 09:57:55.897 ngx_http_auth_pam_authenticate:389 pid:31473 PAM: remote ip:10.79.98.239
2018 December 30 09:57:55.919 ngx_http_auth_pam_authenticate:414 pid:31473 PAM: Successfully authenticated user '
admin', remote ip:10.79.98.239
2018 December 30 09:57:55.919 ngx_http_cookie_set:651 pid:31473 creating cookie cleanup_cnt:0
2018 December 30 09:57:55.919 ngx_http_ins_api_post_body_handler:550 pid:12186 Input Message [
{
"jsonrpc": "2.0",
"method": "cli",
"params": {
"cmd": "show interface brief",
"version": 1
},
"id": 1
}
]
2018 December 30 09:57:55.919 is_nxapi_jsonrpc_request:298 pid:12186 Found jsonrpc request
2018 December 30 09:57:55.919 nxapi_jsonrpc_input_handler:101 pid:12186 Parsing json rpc request
2018 December 30 09:57:55.919 nxapi_jsonrpc_parse_request:901 pid:12186 JSONRPC Batch request found, starting par
se.
2018 December 30 09:57:55.919 _parse_in_req_msg_jsonrpc_store_nxversion:75 pid:12186 Input request version: 0
2018 December 30 09:57:55.919 _parse_in_req_msg_jsonrpc_username:668 pid:12186 cookie had user ''
2018 December 30 09:57:55.920 _parse_in_req_msg_jsonrpc_username:682 pid:12186 auth header had user 'admin'
2018 December 30 09:57:55.920 nxapi_jsonrpc_input_handler:109 pid:12186 Running jsonrpc commands
2018 December 30 09:57:55.920 nxapi_jsonrpc_run_cmds:453 pid:12186 JSON-RPC method '0'
2018 December 30 09:57:55.920 pterm_idle_vsh_sweep:677 pid:12186 pterm_idle_vsh_sweep
2018 December 30 09:57:55.920 pterm_get_vsh:720 pid:12186 vsh found: child_pid = 12260, fprd = 0x817cfc0, fpwr =
0x817d120, fd = 18, user = admin, vdc id = 1
2018 December 30 09:57:55.920 pterm_write_to_vsh:447 pid:12186 In vsh [18] Writing cmd "configure terminal"
2018 December 30 09:57:55.922 pterm_write_to_vsh:532 pid:12186 Cmd 'configure terminal' returned with '0'
2018 December 30 09:57:55.922 pterm_write_to_vsh:637 pid:12186 Done processing vsh output (ret=0)
2018 December 30 09:57:55.922 pterm_write_to_vsh:447 pid:12186 In vsh [18] Writing cmd "show interface brief | xm
l "
2018 December 30 09:57:56.230 pterm_write_to_vsh:532 pid:12186 Cmd 'show interface brief | xml ' returned with '0
'
2018 December 30 09:57:56.230 pterm_write_to_vsh:637 pid:12186 Done processing vsh output (ret=0)
2018 December 30 09:57:56.230 _jsonrpc_store_vsh_cmd:129 pid:12186 output size 47188
2018 December 30 09:57:56.238 _jsonrpc_store_result_xml:61 pid:12186 Sanitizing output from vsh
2018 December 30 09:57:56.241 _jsonrpc_store_result_xml:82 pid:12186 valid xml, build json for:show interface bri
ef
2018 December 30 09:57:56.244 pterm_write_to_vsh:447 pid:12186 In vsh [18] Writing cmd "end"
2018 December 30 09:57:56.246 pterm_write_to_vsh:532 pid:12186 Cmd 'end' returned with '0'
2018 December 30 09:57:56.246 pterm_write_to_vsh:637 pid:12186 Done processing vsh output (ret=0)
2018 December 30 09:57:56.246 nxapi_jsonrpc_input_handler:113 pid:12186 Formatting jsonrpc output
2018 December 30 09:57:56.246 nxapi_jsonrpc_input_handler:117 pid:12186 gather jsonrpc response
2018 December 30 09:57:56.248 nxapi_jsonrpc_input_handler:123 pid:12186 jsonrpc output ret:0
2018 December 30 09:57:56.248 ngx_http_ins_api_post_body_handler:575 pid:12186 Done processing request
2018 December 30 09:57:56.248 ngx_http_ins_api_post_body_handler:608 pid:12186 sent header
2018 December 30 09:57:56.248 ngx_http_ins_api_post_body_handler:650 pid:12186 Allocate response buffer:32667
2018 December 30 09:57:56.248 ngx_http_ins_api_post_body_handler:680 pid:12186 Sending response len: 32667
2018 December 30 09:57:56.248 ngx_http_ins_api_post_body_handler:681 pid:12186 Sending response now {
"jsonrpc": "2.0",
"result": {
"body": {
"TABLE_interface": {
"ROW_interface": [{
"interface": "mgmt0",
"state": "up",
"ip_addr": "10.10.20.95",
"speed": "1000",
"mtu": 1500
}, {
"i
sbx-n9kv-ao#
-END
原文出处:https://www.cnblogs.com/netdev/p/10217271.html
来源:oschina
链接:https://my.oschina.net/u/4365632/blog/3271702