суббота, 17 марта 2012 г.

Самые базовые настройки Cisco CSS (11500).

В сети опубликовано достаточно много статей по настройке балансировщиков (контент свичей) Cisco серии 11500, однако практически все они относятся не к базовой настройке (менеждмент интерфейса). В принципе, ниже будет памятка для ленивых (типа меня), кто избегает RTFM'а.
Параметры доступа на консоль стандартные для Cisco - 9600N8N1 (Speed (baud) = 9600, Data bits = 8, Stop bits = 1, Parity = None, Flow control = None)
Заводские логин и пароль:
username admin
password system
для смены логина admin
conf t
username-offdm новый_логин password новый_пароль
для смены сетевых параметров менеджмент интерфейса:
conf t
boot
ip addr новый_адрес
subnet mask маска_сети
gateway address адрес_шлюза (ГРАБЛИ! как показала практика, эта настройка работает странно - просто не работает, лучше для доступа к менеджмент интерфейсу указывать статические маршруты для заранее известных подсетей)
ip management route подсеть /префикс шлюз (например, ip management route 172.27.59.0 /24 172.27.56.86)
Далее можно добавить параметры времени (отображаются в running-config):
- из раздела глобальной конфигурации настраивается временная зона clock timezone MSD hour 4 after-UTC (MSD – Moscow Daylight Timezone), что соответствует зоне UTC+4 часа,
- также отключается переход на летнее/зимнее время no clock summer-time
Сохранение настроек: wr mem
Просмотр настроек:
sh boot
sh clock
sh run (куда ж без него...).

четверг, 8 марта 2012 г.

Guru Plug Server Plus (GPS+) восстановление (unbrick) и заливка Debian'а

В процессе игр с сабжем были использованы материалы по ссылкам:

http://bzed.de/posts/2010/05/installing_debian_on_the_guruplug_server_plus/
http://www.cyrius.com/debian/kirkwood/sheevaplug/install.html
http://plugcomputer.org/plugforum/index.php?topic=1648
http://www.newit.co.uk/forum/index.php/topic,410.0.html

Для подключения к консоли использовался "родной" JTAG адаптер.
После подключения интерфейсов и включения GPS+ есть 3 секунды для остановки загрузки и попадания в uBoot. То есть перед включением сервака проверяем, на какой интерфейс сел адаптер:
dmesg | grep tty
в моем случае он приземлился на ttyUSB0
screen /dev/ttyUSB0 115200
(не забываем, что выйти из сессии можно по комбинации Ctrl+a нажать k, потом согласиться с выходом - y).
Запускаем screen и включаем сервак, жмем любой баттон для входа в загрузчик (для этого всего 3 секунды!).

При успехе, попадаем в строку приглашения: Marvell>>
сразу просматриваем переменные окружения и версию загрузчика:
>> version
U-Boot 2009.11-rc1-00602-g28a9c08-dirty (Feb 09 2010 - 18:15:21)

>> printenv
bootcmd=setenv ethact egiga0; ${x_bootcmd_ethernet}; setenv ethact egiga1; ${x_bootcmd_ethernet}; ${x_bootcmd_usb}; ${x_bootcmd_kernel}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x6400000;
bootdelay=3
baudrate=115200
x_bootcmd_ethernet=ping 192.168.2.1
x_bootcmd_usb=usb start
x_bootcmd_kernel=nand read.e 0x6400000 0x100000 0x400000
x_bootargs=console=ttyS0,115200
x_bootargs_root=ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs
ethact=egiga0
ethaddr=***
eth1addr=***
stdin=serial
stdout=serial
stderr=serial
Environment size: 549/131068 bytes

по команде help выводятся доступные команды. В "моей" версии загрузчика не было части нужных команд, например, работы с устройствами с файловыми системами ext2-3-4. Так что загрузчик нужно обновить. Сделать это можно несколькими способами, в частности, с USB носителя (в FAT) или по сети с TFTP сервера.

Бинарник загрузчика использованный мной:
http://people.debian.org/~tbm/u-boot/2011.12-2/guruplug/u-boot.kwb
Выбор пал на сетевую загрузку, для чего были добавлены настройки:
setenv bootdelay 10
setenv ipaddr 172.17.18.248
setenv serverip 172.17.18.247
saveenv
tftpboot 0x0800000 u-boot.kwb
nand erase 0x0 0x60000
nand write 0x0800000 0x0 0x60000
reset
В результате получен девайс в новой версией загрузчика:
U-Boot 2011.12 (Jan 08 2012 - 21:46:50)

Теперь необходимо загрузить uImage и uInitrd, чтобы позднее начать сетевую загрузку и установку самой ОС. Это также можно сделать по сети (через TFTP) или с носителя.
Для разнообразия попробовал разобраться с носителем: в GPS+ есть слот для карт microSD, вот такую карточку на 8Гб и использовал (на нее же позднее ставится ОС).
Карта отформатирована в ext4 (через GParted).

!Помнить! После создания раздела и форматирования владельцем карты становится root, так что для возможности записи данных на карту нужно сменить владельца:
sudo chown mik17 /media/guruplug/

Нужные файлы доступны по ссылкам:
ftp://ftp.debian.org/debian/dists/stable/main/installer-armel/current/images/kirkwood/netboot/marvell/sheevaplug/uImage
и
ftp://ftp.debian.org/debian/dists/stable/main/installer-armel/current/images/kirkwood/netboot/marvell/sheevaplug/uInitrd

Записываем их в корень карточки и саму карту вставляем в GPS+.

На всякий случай повторно включаем поддержку USB устройств (заодно будет выполнен и поиск носителей):
>> usb start
(Re)start USB...
USB: Register 10011 NbrPorts 1
USB EHCI 1.00
scanning bus for devices... 3 USB Device(s) found
scanning bus for storage devices... Device NOT ready
Request Sense returned 02 3A 00
2 Storage Device(s) found

определяем, какой девайс - наша карта:
>> usb storage
Device 0: Vendor: Generic Rev: 9909 Prod: STORAGE DEVICE
Type: Removable Hard Disk
Capacity: not available
Device 1: Vendor: Generic Rev: 9909 Prod: STORAGE DEVICE
Type: Removable Hard Disk
Capacity: 7384.0 MB = 7.2 GB (15122432 x 512)

нас интересует Device 1, точнее его первый раздел.

Загружаем файлы с карточки:
>> ext2load usb 1:1 0x00800000 /uImage
Loading file "/uImage" from usb device 1:1 (usbdb1)
1435184 bytes read
>> ext2load usb 1:1 0x01100000 /uInitrd
Loading file "/uInitrd" from usb device 1:1 (usbdb1)
3172565 bytes read

Теперь добавляем в переменные окружения загрузку с карты памяти:
setenv bootargs_console console=ttyS0,115200
setenv bootcmd_usb 'usb start; ext2load usb 1:1 0x00800000 /uImage; ext2load usb 1:1 0x01100000 /uInitrd'
setenv bootcmd 'setenv bootargs $(bootargs_console); run bootcmd_usb; bootm 0x00800000 0x01100000'
saveenv
setenv bootargs console=ttyS0,115200n8 base-installer/initramfs-tools/driver-policy=most

Начинаем процесс установки !Важно! необходимо точно убедиться, что с сетевыми настройками нет проблем, так как сабж тянет установочные файлы из Инета.
bootm 0x00800000 0x01100000
В процессе установки задаются стандартные вопросы.

После установки "внезапно" выяснится, что имеющийся беспроводной интерфейс не видится, а в логах примерно такие сообщения:
can't load helper firmware
failed to load helper firmware

Для решения этой проблемы нужно загрузить файлы sd8688.bin и sd8688_helper.bin в /lib/firmware
Взять эти файлы можно по ссылкам:
http://git.infradead.org/users/dwmw2/linux-firmware.git/blob/8ad78631586495ca5738c78884c14bfaf29f633e:/libertas/sd8688.bin
и
http://git.infradead.org/users/dwmw2/linux-firmware.git/blob/8ad78631586495ca5738c78884c14bfaf29f633e:/libertas/sd8688_helper.bin
После перезагрузки беспроводной интерфейс появится.

четверг, 1 марта 2012 г.

TFTP сервер для Ubuntu (который можно вкл/выкл)

Для скачивания конфигов или заливки прошивок на сетевые девайсы полезно всегда иметь на разъездном буке ряд сервисов, в частности, TFTP сервер, но такой, чтобы он не весел постоянно запущенным (как atftpd). Для Windows очень долгое время я пользовался 3com_TFTP-Syslog-FTP-server'ом (как видно из названия, там же еще и FTP и Syslog). Долго искал аналогичную примочку по Линуха.
Понравился такой сервачок: http://code.google.com/p/tftpgui/ от Гугла, основанный на Python'е.
После скачивания и распаковки, на рабочем столе по правой кнопке мыши делаем Create Launcher / Type="Application in Terminal" / Name="TFTP_Server" / Command="sudo /~/Progs/tftpgui/tftpgui.py"
Конечно же в поле команды нужно будет указать путь распакованному файлу tftpgui.py (без кавычек).

понедельник, 27 февраля 2012 г.

Включение последовательного интерфейса в дистрибутивах на базе Дебиан с init (не upstart!).

В меморизз.
Взято отсюда: http://www.debuntu.org/how-to-set-up-a-serial-console-on-debian
How-To set up a serial console on Debian

This tutorial will go over the steps to go through in order to set up a serial console on Debian Linux.

Debian uses sysvinit to handle the booting process, amongst the different task, and as such, there is a few differences between most of the tutorial that you might find on the internet regarding how to set up a serial console.

A Serial Console becomes handy when running a headless server (i.e no keyboard and screen) or if you cannot connect a a server because of a network issue.

In this tutorial, we will set up a serial console on the server, the machine we want an access to. Setting up a serial console client will be covered in another article.
1. Checking the serial devices

In order to find which devices are available on a box, you can run:

$ dmesg | grep tty
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:0a: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A

From this output, we can guess that there is 2 serial interface2 (/dev/ttyS0 and /dev/ttyS1). This tutorial considers that you are using device 1 (ttyS0), if you use the second device, you will need to change ttyS0 by ttyS1.
2. Setting up the serial console on the server

On the server, we are going to set up:

A serial console on ttyS0
Have kernel booting messages output to the serial console
Make Grub outputs to the serial console

2.1. The serial console

To set up a serial console, We need to edit the file called /etc/inittab in order to spawn a getty on the serial device. getty will take care of prompting the user for a username and password.

Go and edit /etc/inittab and add:

s0:2345:respawn:/sbin/getty -L 115200 ttyS0 vt102

just below:

1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

Now, run:

# init q

In order to have sysvinit re-read its configuration and spawn a getty on /dev/ttyS0 .

To authorize root to log in through the serial console, you need to edit /etc/securetty and make sure you have:

ttyS0

2.2. Having grub outputting to ttyS0

grub can be configured to output on the serial console.Edit grub and add:

serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console

In the section before the different kernels. This will take care of having grub being displayed one the serial console so you can actually modify grub through the serial console or boot using another kernel.

If using ttyS1, then change it to --unit=1

Also, in order to get the booting messages outputted to the serial console, you can append to your kernel line the following:

console=ttyS0,115200n8 console=tty0

So, finally, the kernel line will look like:

kernel /boot/vmlinuz-2.6.18-6-686 root=/dev/sda1 ro console=ttyS0,115200n8 console=tty0

That's it, upon next reboot, you will be able to connect directly to your box using a serial console!.

По факту для быстрого включения консоли можно выполнить (работает и в Ubuntu):
sudo getty -L 115200 ttyS0 vt102 &

пятница, 17 февраля 2012 г.

Cisco ISR архивирование конфига (версионность).

В мемориз!
Взято отсюда:
https://supportforums.cisco.com/videos/2715
#
mkdir CONFIG_ARCHIVE
conf t
archive
path flash:CONFIG_ARCHIVE/RUN_CONFIG
! Путь к каталогу, где будут архивные копии конфигов (к ним автоматом будут добавляться номера)
write-memory
! Добавление конфига в архив происходит при каждом сохранении конфига в старт (wr mem)
maximum 10
! Сохраняется количество версий - 14 - максимально
!Здесь же в настройках есть опции rollback
!rollback retry timeout ?
! <0-1000> Timeout value in seconds
#
dir flash:/CONFIG_ARCHIVE/
more flash:/CONFIG_ARCHIVE/RUN_CONFIG-1
! просмотр сохраненного конфига
archive config
! явное указание бэкапа конфига
show archive
config replace flash:/CONFIG_ARCHIVE/RUN_CONFIG-1
! Процедура rollback'а - отката на указанный вариант конфига

вторник, 14 февраля 2012 г.

Передача файлов через консоль (xmodem, ymodem).

Не помню, где взял..., но в меморизз:

Uploading files with xmodem

PuTTy on Windows does not support zmodem, xmodem, etc. so I often used HyperTerminal, but the GUI of Hyperterminal annoys me.

So instead of switching between PuTTy and HyperTerminal all the time, I tried to use a different terminal emulator ‘TeraTerm Pro’. This seems fine, but for some reason it dumps a few random characters on the serial line after the file is transferred, falsely answering the multiple choice menu to decide between runtime, diag, multiple image or loader.

I am now using GNU Screen with lrzsz. It was a little struggle to figure out the correct syntax for this, because Screen has a google-incompatible name. Hopefully I’ve sprinkled enough relevant terms in this post to help somebody else with this issue.

I start screen with ‘screen /dev/ttyUSB0 115200′. Then when I start the Xmodem download on the bootrom side I execute CTRL-A “:exec !! sx -kb firmware.bix” in screen.

This works mostly fine. It eats the multiple choice menu after the transfer, but you can press to view it again. And FYI, the bootrom support Xmodem-1K giving a nice transferboost over regular Xmodem.

---

i have write my doc from youre.

*********************
Attention a etre raccordé sur le bon switch en cas de stack
*********************

screen /dev/ttyUSB0

enable
conf t
line con 0
speed 115200

CTRL A + k

screen /dev/ttyUSB0 115200

exit
exit

copy ymodem: flash:filename.bin

CTRL A puis :exec sz -kb filename.bin

Маршруты в HP-UX

Взято отсюда: http://www.cyberciti.biz/tips/hp-ux-how-do-i-configure-routing-or-add-route.html
HP-UX: How Do I configure routing or add route?

by LinuxTitli on October 29, 2005

You can use route command to configure routing. Syntax is as follows:
route add net {network-address} netmask {subnet} {router-address}

Let us assume your router address is 192.168.1.254 and network ID is 192.168.1.0/24, then you can type route command as follows:
# route add net 192.168.1.0 netmask 255.255.255.0 192.168.1.254

OR

To add a default route:
# route add default 192.168.1.254

Verify that (display) routing table is updated (display routing table):
# netstat -nr

Test it i.e. try to ping or send nslookup request:
# ping mycorp.com

To flush all routing entries use command [quite handy to clean your gordian knot ;)] :
# route -f

However if I reboot HPUX box then above routing entries gets removed. To pick up your setting upon each reboot your need to configure Routes in HPUX networking configuration file - /etc/rc.config.d/netconf. To add default router/gateway 192.168.1.254:
# vi /etc/rc.config.d/netconf

Add or modify following entries

ROUTE_DESTINATION[0]="default"
ROUTE_MASK[0]=""
ROUTE_GATEWAY[0]="192.168.1.254"
ROUTE_COUNT[0]="1"
ROUTE_ARGS[0]=""

Reboot HP-UX system/server to take effect
# shutdown -ry 0