Skip to content
/ cgnet Public

A go package to connect to various Cisco devices

License

Notifications You must be signed in to change notification settings

Letsu/cgnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference Go Report Card License

CG - NET

CG-Net is a simple netmiko like package for go to manage cisco devices.

Currently, It's possible to connect to devices using telnet and ssh.

Tested on various cisco catalyst switches, ASRs and ISRs. Other devices should also be possible (:

Installation

go get github.com/Letsu/cgnet

Example

Get Version and configure a loopback interface

package main

import (
	"fmt"
	"github.com/Letsu/cgnet"
)

func main() {
	d := cgnet.Device{
		Ip:       "10.10.10.10",
		Username: "cisco",
		Password: "cisco",
		Enable:   "cisco",
		ConnType: cgnet.SSH,
	}

	err := d.Open()
	defer d.Close()
	if err != nil {
		panic(err)
	}

	ver, err := d.Exec("sh version")
	if err != nil {
		panic(err)
	}
	fmt.Println(ver)

	cmds := []string{"interface loopback10", "ip address 10.10.10.11 255.255.255.255", "no shut"}
	err = d.Configure(cmds)
	if err != nil {
		panic(err)
	}
}

About

A go package to connect to various Cisco devices

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages