Archiwum kategorii: OpenWrt

OpwnWRT, ssh i logowanie bez kluczy

Mam dwa routery z zainstalowanym openwrt. Chciałem móc wykonywać jedno polecenie wydane z jednego routa na drugim bez podawania hasła.

1. Na źródłowym serwerze stworzyłem klucze i następnie przekonwertowałem aby dropbear mógł go używać:

ssh-keygen -t rsa
dropbearconvert openssh dropbear id_rsa /etc/dropbear/server1_identity

2. Na serwerze docelowym klucz publiczny dodaje do pliku authorized_keys:

root@Gargoyle:/etc/dropbear# ls -l /etc/dropbear/authorized_keys
-rw-------    1 root     root           394 Mar 27 20:30 /etc/dropbear/authorized_keys

I teraz mogę się logować bez podawania hasła!

root@router:~/.ssh# ssh -i /etc/private_rsa_key root@192.168.200.30


BusyBox v1.19.4 (2014-01-22 14:20:14 CET) built-in shell (ash)
Enter 'help' for a list of built-in commands.


             _____                             _
            |  __ \                           | |
            | |  \/ __ _ _ __ __ _  ___  _   _| | ___
            | | __ / _` | '__/ _` |/ _ \| | | | |/ _ \
            | |_\ \ (_| | | | (_| | (_) | |_| | |  __/
             \____/\__,_|_|  \__, |\___/ \__, |_|\___|
                              __/ |       __/ |
                             |___/       |___/

OpenWRT i php date problem

Jeżeli masz problem jak poniżej:

Warning: strftime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /www1/php_xml/lib/Smarty-3.1.14/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 183

Fatal error: strftime(): Timezone database is corrupt - this should *never* happen! in /www1/php_xml/lib/Smarty-3.1.14/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 183

To rozwiązanie jest proste, należy doinstalować pakiety z lokalizacją daty:

#opkg install zoneinfo-core zoneinfo-europe

Dnsmasq: uzupełnienie odpowiedzi DNS przez wpisy z /etc/hosts

Dnsmasq można użyć w mniejszym urządzeniu dostępowym takim jak router. Czasem przychodzi potrzeba ustawienia lokalnych domen, które będą widoczne tylko z sieci wewnętrznej. Wpisy można umieścić w /etc/hosts:

root@lokaj:/etc/config$ grep "192.168.14.1" /etc/hosts
192.168.14.1    lokaj
192.168.14.1    owncloud.g2.unix4you.net
192.168.14.1    owncloud.g2.lab2.unix4you.net

Następnie w konfiguracji dnsmasq umieszczamy informację o tych domenach:

root@lokaj:/etc/config$ grep "'local'" dhcp
        option 'local' '/lan/lab2.unix4you.net/g2.unix4you.net/'

Restartujemy usługę:

root@lokaj:/etc/config$ /etc/init.d/dnsmasq restart

I sprawdzamy czy można pingować adres:

root@lokaj:/etc/config$ ping owncloud.g2.lab2.unix4you.net -c 3
PING owncloud.g2.lab2.unix4you.net (192.168.14.1): 56 data bytes
64 bytes from 192.168.14.1: seq=0 ttl=64 time=0.447 ms
64 bytes from 192.168.14.1: seq=1 ttl=64 time=0.308 ms
64 bytes from 192.168.14.1: seq=2 ttl=64 time=0.287 ms

--- owncloud.g2.lab2.unix4you.net ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.287/0.347/0.447 ms

OpenWRT: wyłączenie obsługi DNS przez dnsmasq

Niekiedy zachodzi potrzeba, aby usługa DNS była obsługiwana nie przez dnsmasq ale przez normalny serwer DNS (jak Bind). Wykonujemy to przez ustawienie zmiennej port na 0 w pliku /etc/config/dhcp.conf w sekcji „dnsmasq”.

Przed rekonfiguracją:

root@lokaj:/etc/config$ netstat -nlpt | grep -i 53
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      2959/dnsmasq
netstat: /proc/net/tcp6: No such file or directory

Rekonfiguracja:

root@lokaj:/etc/config$ head -n 3 dhcp

config 'dnsmasq'
        option 'port' '0'

root@lokaj:/etc/config$ /etc/init.d/dnsmasq restart

Po rekonfiguracji:

root@lokaj:/etc/config$ netstat -nlpt | grep -i 53
netstat: /proc/net/tcp6: No such file or directory

Jak sprawdzić wersję OpenWrt?

W przypadku standartowego Linuksa moglibyśmy użyć polecenia lsb_release. Jednak w przypadku OpenWrt, gdzie liczy się każdy MB, tego zrobić nie możemy. Musimy więc sprawdzać czy istnieją pliki charakterystyczne dla OpenWrt i jakie informacje one zawierają:

root@lokaj:/etc$ cat openwrt_version
r33081
root@lokaj:/etc$ cat openwrt_release
DISTRIB_ID="OpenWrt"
DISTRIB_RELEASE="10.03.x Snapshot"
DISTRIB_REVISION="r33081"
DISTRIB_CODENAME="backfire"
DISTRIB_TARGET="ar71xx"
DISTRIB_DESCRIPTION="OpenWrt Backfire r33081"

OpenWrt: 3ginfo

Instalacja

root@Gargoyle:/$ opkg install 3ginfo
Installing 3ginfo (1-52) to root...
Downloading http://ecco.selfip.net/backfire/ar71xx/packages/3ginfo_1-52_all.ipk.
Installing uhttpd (28) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/uhttpd_28_ar71xx.ipk.
Configuring uhttpd.
Configuring 3ginfo.

Pierwsze uruchomenie – test z konsoli

root@Gargoyle:/$ 3ginfo
Status: Rozlaczony
Czas polaczenia: -
Przeslano danych: - / -
Operator: Orange
Tryb pracy: EDGE
Sila sygnalu: 48%
Urzadzenie: huawei E173
MCC MNC: 260 03
LAC: 1644 (5700)
LCID: - (-)
RNC: - (-)
CID: 1467 (5223)
CSQ: 15
RSSI: -83 dBm

Strona WWW

Domyślnie, usługa po włączeniu będzie działała na porcie 81.

Więcej informacji

Więcej: http://eko.one.pl/?p=openwrt-3ginfo