将 Cisco 877 配置为全桥模式
访问设备
当使用新版本 ssh 连接到此设备时,您可能需要使用此命令
ssh -o HostKeyAlgorithms=ssh-rsa,ssh-dss -o KexAlgorithms=diffie-hellman-group1-sha1 \ -o Ciphers=aes128-cbc,3des-cbc -o MACs=hmac-md5,hmac-sha1 admin@192.168.0.1
因为新版本的 OpenSSH 和 Cisco 的旧 sshd 存在 bug,链接在此here and here。
启用 SSH
如果您没有 SSH 访问您的调制解调器,您可能需要启用它。 > 代表常规“用户”模式,而终端上的 # 代表“特权”模式。 可以将其视为 “su”。
router>enable Password: router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. router(config)#ip domain-name <YOUR DOMAIN>
确保您指定需要 2048 位,否则路由器将回退到 ssh 1,并且不允许您使用 ssh 2。
router(config)#crypto key generate rsa The name for the keys will be: router.<YOUR DOMAIN> Choose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes. How many bits in the modulus [512]: 2048 % Generating 2048 bit RSA keys, keys will be non-exportable... router(config)#ip sh version 2
上传配置文件到路由器
有多种方法可以做到这一点。 您可以使用 tftp (简单文件传输协议) 或 ssh。
从运行 sshd 的服务器
如果您有一个运行 sshd 的服务器,您可以将配置文件从该服务器复制到您的 running-config。
copy running-config scp://user:password@ip/filename
在调制解调器上启用 scp 服务器
router(config)#ip scp server enable router(config)#aaa new-model router(config)#aaa authentication login default local router(config)#aaa authorization exec default local none router(config)#username USER privilege 15 password <USER PASSWORD CLEARTEXT> router(config)#ip scp server enable
然后,您可以从您的 Linux 工作站上传配置文件。
startup-config 是调制解调器在启动时从 nvram 加载的配置。
scp admin@192.168.0.1:nvram:startup-config .
running-config 是调制解调器使用的、在内存中的配置。
scp admin@192.168.0.1:system:running-config .
通过串口使用 minicom
如果您完全被锁定在您的 Cisco 路由器之外,您可能需要使用串口线。
为此,您可以使用 minicom,以下是您连接到调制解调器所需的设置
pu port /dev/ttyUSB0 pu baudrate 9600 pu bits 8 pu parity N pu stopbits 1
注意,您需要将串口线更改为您计算机上的串口线。 我使用了一个 USB 转串口转换器,因为我没有串口。
将配置文件保存到系统
如果您对 running-config 进行了小的编辑,请确保将其复制到 startup-config,否则如果您断开调制解调器的电源或重新启动它,更改将会丢失。
copy running-config startup-config
Cisco 877 ADSL 调制解调器桥接模式
! version 12.4 no service pad service timestamps debug datetime msec service timestamps log datetime msec service password-encryption ! hostname <HOSTNAME> ! boot-start-marker boot-end-marker ! logging message-counter syslog logging buffered 4096 informational enable secret 5 <SECRET> ! aaa new-model ! ! aaa authentication login default local aaa authentication login local_auth local aaa authorization exec default local none ! ! aaa session-id common ! ! dot11 syslog ip source-route no ip routing ! ! ! ! no ip cef ip domain name <DOMAIN NAME> no ipv6 cef ! multilink bundle-name authenticated ! ! ! username admin privilege 15 secret 5 <SECRET> username USER privilege 15 password 7 <SECRET> ! ! ! archive log config hidekeys ! ! ip ssh version 2 ip scp server enable ! bridge irb ! ! interface ATM0 no ip address no ip route-cache no atm ilmi-keepalive pvc 8/35 encapsulation aal5snap ! bridge-group 1 ! interface FastEthernet0 ! interface FastEthernet1 ! interface FastEthernet2 ! interface FastEthernet3 ! interface Dot11Radio0 no ip address no ip route-cache shutdown speed basic-1.0 basic-2.0 basic-5.5 6.0 9.0 basic-11.0 12.0 18.0 24.0 36.0 48.0 54.0 station-role root ! interface Vlan1 no ip address no ip route-cache bridge-group 1 ! interface BVI1 ip address 192.168.0.1 255.255.255.252 no ip route-cache ! ip default-gateway 192.168.0.2 ip default-network 192.168.0.0 ip forward-protocol nd no ip http server no ip http secure-server ! ! ! ip access-list standard SSH_ACCESS !This is a list of the addresses you want to allow permit <IP> permit <IP> ! ! ! ! ! ! control-plane ! bridge 1 protocol ieee bridge 1 route ip banner login Authorized access only! Disconnect IMMEDIATELY if you are not an authorized user! ! line con 0 no modem enable line aux 0 line vty 0 4 access-class SSH_ACCESS in authorization exec local_author login authentication login_local transport input ssh ! scheduler max-task-time 5000 end
除了更改显而易见的内容,例如主机名、域名和允许的 IP 地址外,您还需要验证 ATM0 设置是否与您的 ISP 的配置匹配。 具体来说:“pvc 8/35” 和 “encapsulation aal5snap” 对我来说有效,但可能对您无效。 您还需要生成密码并替换所有 <SECRET> 的实例。
生成密码
Secret 5 密码
您可以使用此 OpenSSL 命令为 “secret 5” 密码生成哈希值
openssl passwd -salt `openssl rand -base64 3` -1 "<YOUR PASSWORD>"
将输出放在 <SECRET> 中
Secret 7 密码
要加密 secret 7 密码,您可以使用这个 perl 脚本,感谢 m00nie。
#!/usr/bin/perl # Cisco (type 7) password tool from www.m00nie.com :D # Will either decrypt a _TYPE 7_ password from a cisco device # or will encrypt a string so that it can be used in a cisco # device. # # I made this code to learn more Perl and just out of interest # about the type 7 "encryption". The decryption code is already # and from a mailing list. The original header from that is below. # # Credits for original code and description hobbit@avian.org, # SPHiXe, .mudge et al. and for John Bashinski <jbash@CISCO.COM> # for Cisco IOS password encryption facts. # # Use for any malice or illegal purposes strictly prohibited! # @xlat = ( 0x64, 0x73, 0x66, 0x64, 0x3b, 0x6b, 0x66, 0x6f, 0x41, 0x2c, 0x2e, 0x69, 0x79, 0x65, 0x77, 0x72, 0x6b, 0x6c, 0x64, 0x4a, 0x4b, 0x44, 0x48, 0x53 , 0x55, 0x42 ); $loop = 0; while ($loop == 0) { print "\n\n***************************************************************\n"; print "* Cisco (type 7) password tool from www.m00nie.com :D *\n"; print "* Use for any malice or illegal purposes strictly prohibited! *\n"; print "***************************************************************\n\n"; print "1. Decrypt a password\n"; print "2. Encrypt plain text\n"; print "3. Quit\n\n"; print "Pick either 1, 2 or 3: "; chomp ($choice = <STDIN>); if ( $choice == 1 ) { decrypt() } elsif ( $choice == 2) { encrypt() } elsif ($choice == 3) { exit } else { print "$choice is not a valid option\n"; } } sub decrypt { print "Enter the encrypted password: "; chomp ($epass = <STDIN>); if (!(length($epass) & 1)) { $ep = $epass; $dpass = ""; ($s, $e) = ($ep =~ /^(..)(.+)/); for ($i = 0; $i < length($e); $i+=2){ $dpass .= sprintf "%c",hex(substr($e,$i,2))^$xlat[$s++]; } } print "\nEncrypted pass was: $epass\n"; print "Decrypted pass is: $dpass\n"; } sub encrypt { print "Enter the string to encrypt:\n"; chomp ($ptext = <STDIN>); $pt = $ptext; $etext = ""; $n = 2; $etext .= sprintf("%.2o", $n); for ($k = 0; $k < length($pt); $k+=1){ $tmp = ord(substr($pt,$k,1))^$xlat[$n++]; $etext .= sprintf("%.2X", $tmp); } print "\nPlain string was: $ptext\n"; print "Encrypted string is: $etext\n"; } # eof