Παρασκευή 8 Νοεμβρίου 2013

Streaming your Dlink ip camera to XBMC

Create an empty .strm file, open with a text editor and put the stream link inside the file:

http://user:pass@xxx.xxx.xxx.xxx/MJPEG.CGI?.mjpg


Put your file into one of your source video folders.
You may then add it to favorites in order to have quick access to your camera stream
This was tested on a Dlink DSC-932L ip camera

Παρασκευή 11 Οκτωβρίου 2013

Setting up your openwrt adsl router for Forthnet IPv6 (Dual Stack) - Static Pilot

I am using a Ubiquiti AirRouter flashed with OpenWrt as a PPPoE client and my old linksys ADSL modem/router is configured in bridged mode and only handles the ADSL connection. 

This setup applies to openwrt Attitude Adjustment 12.09 and it is updated on Nov 2014

You have to install the follwing packages:
dhcp6-client
radvd
opkg update
opkg install radvd dhcp6-client

If you are using the Luci web i/f,  you should enable "Enable IPv6 negotiation on the PPP link" on the WAN advanced settings. It is more efficient though to do the changes via cli:

config interface 'wan'
        option _orig_ifname 'eth1'
        option _orig_bridge 'false'
        option ifname 'eth1'
        option proto 'pppoe'
        option password 'somepasshere'
        option username 'username.ath.forthnet.gr@stv6forthnet.gr'
        option ipv6 '1'
        option keepalive '5 5'
Then, edit /etc/config/dhcp6c :
config interface
 option interface 'lan'
 option AdvSendAdvert 1
 option AdvManagedFlag 0
 option AdvOtherConfigFlag 0
 option AdvLinkMTU       1492
 list client  ''
 option ignore  0

config 'dhcp6c' 'basic'
 option 'enabled' '1'    # 1 = enabled; 0 = disabled
 option 'interface' 'wan'   # This is the interface the DHCPv6 client will run on
 option 'dns' 'dnsmasq'    # Which DNS server you run (only dnsmasq currently supported)
 option 'debug' '1'    # 1 = enable debugging; 0 = disable debugging
 
 # Send options (1 = send; 0 = do not send)
 option 'pd' '1'     # Prefix Delegation
 option 'na' '1'     # Non-Temporary Address
 option 'rapid_commit' '1'   # Rapid Commit
 
 # Request options (1 = request; 0 = do not request)
 option 'domain_name_servers' '1'
 option 'domain_name' '0'
 option 'ntp_servers' '0'
 option 'sip_server_address' '0'
 option 'sip_server_domain_name' '0'
 option 'nis_server_address' '0'
 option 'nis_domain_name' '0'
 option 'nisp_server_address' '0'
 option 'nisp_domain_name' '0'
 option 'bcmcs_server_address' '0'
 option 'bcmcs_server_domain_name' '0'
 
 # Override the used DUID, by default it is derived from the interface MAC
 # The given value must be uppercase and globally unique!
 #option 'duid' '00:03:00:06:D8:5D:4C:A5:03:F2'

 # Script to run when a reply is received
 option 'script' '/usr/bin/dhcp6c-state'

# Define one or more interfaces on which prefixes should be assigned
config 'interface' 'loopback'
 option 'enabled' '1'    # 1 = enabled; 0 = disabled
 option 'sla_id' '0'    # Site level aggregator identifier specified in decimal (subnet)
 option 'sla_len' '4'    # Site level aggregator length (64 - size of prefix being delegated)
       # e.g. /60 from ISP -> 64 - 60 = 4

config 'interface' 'lan'
 option 'enabled' '1'
 option 'sla_id' '1'
 option 'sla_len' '8'
And my /etc/config/radvd

config prefix
 option interface 'lan'
 # If not specified, a non-link-local prefix of the interface is used
 list prefix  ''
 option AdvOnLink 1
 option AdvAutonomous 1
 option AdvRouterAddr 0
 option ignore  0

config route
 option interface 'lan'
 list prefix  ''
 option ignore  0

config rdnss
 option interface 'lan'
 # If not specified, the link-local address of the interface is used
 list addr  ''
 option ignore  0

config dnssl
 option interface 'lan'
 list suffix  ''
 option ignore  1

After you have applied the configuration, restart your network:
 /etc/init.d/network restart



Τετάρτη 7 Αυγούστου 2013

Configuring an openvpn bridge on CentOS

First, edit /etc/sysconfig/network-scripts/ifcfg-eth0
Remove, or comment the interfaces ip configuration and add it to the bridge:
DEVICE=eth0
#BOOTPROTO=static
HWADDR=70:72:BC:A3:21:51
ONBOOT=yes
#IPADDR=192.168.1.192
#NETMASK=255.255.255.0
#NETWORK=192.168.1.0
BRIDGE=br0
Edit /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
BOOTPROTO=static
ONBOOT=yes
TYPE=Bridge
IPADDR=192.168.1.192
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
#The follwing is of course optional
IPV6INIT=yes

restart network and check that the i/f is ok:
ifconfig br0


You have to create 2 custom scripts in order to add the tap interface in the bridge everytime your openvpn server is started and add the 2 follwing lines on your openvpn config:
up "/etc/openvpn/bridge-start.sh"
down-pre "/etc/openvpn/bridge-stop.sh"


bridge-start.sh
#!/bin/sh
/usr/sbin/brctl addif br0 $1
/sbin/ifconfig $1 up


bridge-stop.sh
/sbin/ifconfig $1 down
/usr/sbin/brctl delif br0 $


After your openvpn server is started, you may check that the interface is addes to the bridge:
brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.7072bca32151       no              tap0
                                                                       eth0


Πέμπτη 4 Ιουλίου 2013

Simple commands to convert MAC addresses to Cisco format and vice versa

The common mac addres format is colon separated:
01:23:45:67:89:ab

Cisco format is dot separeted in three groups:
0123.4567.89ab

To convert from one format to another create the following scripts:

mactocisco
echo $1 | sed 's!\:!!g;s!\(....\)!\1.!g;s!.$!!' | tr "[:upper:]" "[:lower:]"

ciscotomac 
echo $1 | sed 's!\.!!g;s!\(..\)!\1:!g;s!:$!!'

example:

mymac:~ user$ ./ciscotomac 0123.4567.89ab

01:23:45:67:89:ab