Created
May 9, 2016 11:36
-
-
Save libcrack/7b75737647e3aacabfaf4e71116cadbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # [email protected] | |
| # dom abr 5 22:19:42 CEST 2015 | |
| # | |
| # dynamips arguments | |
| # | |
| # -H [<ip_address>:]<tcp_port> : Run in hypervisor mode | |
| # | |
| # -P <platform> : Platform to emulate (7200, 3600, 2691, 3725, 3745, 2600 or 1700) (default: 7200) | |
| # | |
| # -i <instance> : Set instance ID | |
| # -r <ram_size> : Set the virtual RAM size (default: 256 Mb) | |
| # -o <rom_size> : Set the virtual ROM size (default: 4 Mb) | |
| # -n <nvram_size> : Set the NVRAM size (default: 128 Kb) | |
| # -c <conf_reg> : Set the configuration register (default: 0x2102) | |
| # -m <mac_addr> : Set the MAC address of the chassis | |
| # -C, --startup-config <file> : Import IOS configuration file into NVRAM | |
| # --private-config <file> : Import IOS configuration file into NVRAM | |
| # -X : Do not use a file to simulate RAM (faster) | |
| # -T <port> : Console is on TCP <port> | |
| # -U <si_desc> : Console in on serial interface <si_desc> | |
| # (default is on the terminal) | |
| # --filepid filename : Store dynamips pid in a file | |
| # | |
| # -t <npe_type> : Select NPE type (default: "npe-400") | |
| # -M <midplane> : Select Midplane ("std" or "vxr") | |
| # -p <pa_desc> : Define a Port Adapter | |
| # -s <pa_nio> : Bind a Network IO interface to a Port Adapter | |
| # -I <serialno> : Set Processor Board Serial Number | |
| # -a <cfg_file> : Virtual ATM switch configuration file | |
| # -f <cfg_file> : Virtual Frame-Relay switch configuration file | |
| # -E <cfg_file> : Virtual Ethernet switch configuration file | |
| # -b <cfg_file> : Virtual bridge configuration file | |
| # -e : Show network device list of the host machine | |
| # | |
| # Available NETIO types: | |
| # * unix : UNIX local sockets | |
| # * vde : Virtual Distributed Ethernet / UML switch | |
| # * tap : Linux/FreeBSD TAP device | |
| # * udp : UDP sockets | |
| # * udp_auto : Auto UDP sockets | |
| # * tcp_cli : TCP client | |
| # * tcp_ser : TCP server | |
| # * mcast : Multicast bus | |
| # * linux_eth : Linux Ethernet device | |
| # * gen_eth : Generic Ethernet device (PCAP) | |
| # * fifo : FIFO (intra-hypervisor) | |
| # * null : Null device | |
| # | |
| # $ find . -iname "*.bin" | |
| # ./3600/c3620-j1s3-mz.123-19.bin | |
| # ./3700/3725/c3725-adventerprisek9_ivs-mz.124-15.T14.bin | |
| # ./3700/3745/c3745-a3jk9s-mz.123-4.T2.bin | |
| # ./3700/3745/c3745-a3js-mz.123-11.T10.bin | |
| # ./2600/c2600-j1s3-mz.123-26.bin | |
| # ./3900/c3900-universalk9-mz.SPA.151-4.M.bin | |
| ## PIRULA -P 3600 ./3900/c3900-universalk9-mz.SPA.151-4.M.image | |
| # -P 3600 ${imagerepo}/3600/c3620-j1s3-mz.123-19.bin | |
| # -P 3725 ${imagerepo}/3700/3725/c3725-adventerprisek9_ivs-mz.124-15.T14.bin | |
| # -P 3745 ${imagerepo}/3700/3745/c3745-a3jk9s-mz.123-4.T2.bin | |
| # -P 3745 ${imagerepo}/3700/3745/c3745-a3js-mz.123-11.T10.bin | |
| # -P 2600 ${imagerepo}/2600/c2600-j1s3-mz.123-26.bin | |
| platform="$1" | |
| name="${platform}_${RANDOM}" | |
| screen_title="cisco_${name}" | |
| pidfile="/run/$USER/dynamips_${name}.pid" | |
| imagerepo="/data/VirtualMachines/Cisco" | |
| image= | |
| case $1 in | |
| 2600) | |
| #image="${imagerepo}/2600/c2600-j1s3-mz.123-26.bin" ;; | |
| image="${imagerepo}/2960/c2960-lanbasek9-tar.122-53.SE2.tar" ;; | |
| 3600) | |
| image="${imagerepo}/3600/c3620-j1s3-mz.123-19.bin" ;; | |
| 3725) | |
| #image="${imagerepo}/3700/3725/c3725-adventerprisek9_ivs-mz.124-15.T14.bin" ;; | |
| image="${imagerepo}/3700/3725/c3725-adventerprisek9_ivs-mz.124-15.T14.image" ;; | |
| 3745) | |
| #image="${imagerepo}/3700/3745/c3745-a3jk9s-mz.123-4.T2.bin" ;; | |
| image="${imagerepo}/3700/3745/c3745-a3js-mz.123-11.T10.bin" ;; | |
| *) | |
| echo -e "\n\tUsage: $0 <2600|3600|3725|3745>\n" | |
| exit 1 | |
| ;; | |
| esac | |
| [[ -f "$image" ]] || { | |
| echo "ERROR: Cannot locate image for platform \"$platform\": \"$image\"" | |
| exit 1 | |
| } | |
| screen -S "$screen_title" \ | |
| dynamips \ | |
| --filepid "$pidfile" \ | |
| -P "$platform" "$image" | |
| [[ $? == 0 ]] && { | |
| echo ">> Screen created:" | |
| echo "$(screen -ls | grep "$screen_title")" | |
| exit 0 | |
| } || { | |
| echo ">> ERROR starting dynamips $platform $image" | |
| exit 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment