Random notes & other stuff…

…about Linux, electronics, digital photography, whatever…
Icône RSS Icône Accueil
  • Cisco 1841 ADSL configuration for Free telecom

    Posté le 17th mai 2009 leucos Pas de commentaires

    (a french translation for this article is here)

    http://leucos.lstilde.org/wp/2009/05/cisco-1841-ads…r-free-telecom/

    People connected via Free, a french internet provider are usually happy customers… until they need to get support. Well, this is a problem with most of providers out there.

    When you subscribe to Free, they send you a Freebox : a combo containing a DSL modem, a router, an FXS to hook your telephone, and sometimes more if you’re lucky enough to have TV and other services.

    But when you don’t want to use this box, or when it’s dead, you can use alternate ways to get connected. The easiest one if to get a DSL modem (a speedtouch for instance), and use a PPPoE capable routeur (like a Linksys WRT54GL + tomato firmware).

    You can also do PPPoA if you have a router with an ATM interface. The configuration included below can be used on a Cisco 1841 routeur with ATM card to connect to Free. It probably can be adapted to other models  very easily by changing only interface names.

    You can debug what happens by issuing :

    debug ppp neg
    debug ppp auth

    Good luck.

    !
    version 12.4
    no service pad
    service timestamps debug datetime msec
    service timestamps log datetime msec
    service password-encryption
    !
    hostname c1841-pppoa
    !
    boot-start-marker
    boot-end-marker
    !
    enable secret 0 CHANGE_YOUR_ENABLE_PASSWORD
    !
    no aaa new-model
    !
    resource policy
    !
    memory-size iomem 5
    mmi polling-interval 60
    !
    no mmi auto-configure
    no mmi pvc
    mmi snmp-timeout 180
    ip subnet-zero
    ip cef
    !
    !
    no ip dhcp use vrf connected
    !
    ! Global pool for the LAN clients
    ip dhcp pool CLIENTS
    import all
    network 192.168.0.0 255.255.255.0
    default-router 192.168.0.254
    dns-server 192.168.0.254
    !
    ! Static assignements for specific clients
    ip dhcp pool pc1
    import all
    host 192.168.0.2 255.255.255.0
    client-identifier 0013.8dd7.2ada
    !
    ip dhcp pool pc2
    import all
    host 192.168.0.3 255.255.255.0
    client-identifier 0018.f327.3137
    !
    ip domain name whatever.it.is
    !
    ! Use ssh
    ! You need to issue
    ! crypto key generate rsa
    ! first
    ip ssh time-out 60
    ip ssh authentication-retries 2
    !
    ! Lets define some user
    username _CHANGE_USERNAME password à CHANGE_USERPASSWORD
    !
    !
    !
    interface Null0
    no ip unreachables
    !
    ! This is LAN side
    interface FastEthernet0/0
    description LAN connection
    ip address 192.168.0.254 255.255.255.0
    ip nat inside
    ip virtual-reassembly
    duplex auto
    speed auto
    no cdp enable
    !
    interface FastEthernet0/1
    no ip address
    speed auto
    !
    ! This is the ATM interface
    ! We\'re doing PPPoA
    interface ATM0/0/0
    no ip address
    no atm ilmi-keepalive
    dsl operating-mode auto
    pvc 8/35
    ubr 160
    encapsulation aal5mux ppp dialer
    dialer pool-member 1
    !
    !
    interface BRI0/1/0
    no ip address
    shutdown
    !
    ! Dialer interface for PPP negotiation
    interface Dialer0
    ip address negotiated
    ip nat outside
    ip virtual-reassembly
    encapsulation ppp
    no cdp enable
    ppp authentication chap pap callin
    ppp chap hostname 04XXXXXXXX@freeadsl
    ppp chap password 0 CHANGE_TO_YOUR_CHAP_PASS
    !
    ppp pap sent-username 04XXXXXXXX@freeadsl password 0 CHANGE_TO_YOUR_CHAP_PASS
    ! Required to get DNS servers
    ppp ipcp dns request
    !
    ip classless
    ip route 0.0.0.0 0.0.0.0 Dialer0
    !
    ! Required to act as a DNS server for the LAN clients
    ip dns server
    !
    ! Oh please no !
    no ip http server
    no ip http secure-server
    !
    ! Do some NAT for LAN clients
    ip nat inside source list 10 interface Dialer0 overload
    access-list 10 permit 192.168.0.0 0.0.0.255
    !
    control-plane
    !
    line con 0
    stopbits 1
    line aux 0
    line vty 0 4
    password 0 CHANGE_TO_SOME_PASS
    login local
    ! We just want ssh, not telnet
    transport input ssh
    !
    end
  • High-power TVBGone

    Posté le 16th mai 2009 leucos 2 commentaires

    This TVBG has been done a long time ago, but I never took time to write about it. It’s quite powerful : you can easily take off TV’s at 100ft, and even works thru your pocket (and pretty far if you wear GoreTex). But guess it, with power comes batteries, and the downside is it’s size, roughly the size of a cigarette pack (all the pictures below are pretty outdated…).

    TVBGone with it's camouflage package

    TVBGone with it

    The design is pretty simple : an AtTiny85, 6 TSAL 6100 IR diodes from Vishay (rated 1A for short pulses), 6+1 NPN transistors. Unlike what is show in the picture below, there is no more jumper (it was used to switch between programming mode and run mode). The tantalum capacitor has been scrounged, and not bought. If you know what coltan is, you know that buying tantalum stuff is rather bad.

    TBGone bottom view

    TBGone bottom viewTVBGone with it

    The thing is powered by 3xAA batteries. There is no current limiter, the only limit is provided by the batteries internal resistance so take care if you want to change supply for a LiPo or whatever, you’ll blow the LEDs for sure. In this case, add a resistor along each LED, or better, use some current regulator.

    For now, the 6 TSAL LEDs are sucking 2.5 Amps without a current limiter.

    TVBGone top view

    TVBGone top view

    The AVR code has been found on the net, and is provided here almost unmodified. The original authors are in the main.c header file, among which, of course, Limor (aka Ladyada).

    I’ve changed the IR codes a bit, removing some duplicates, reordered them too so the most used codes comes first (file with modified codes is PERSOcodes.c).

    One of the problems is that LG TV can not yet be turned off. This is a pain since LGs are everywhere. I don’t have time to reverse engineer timings for LG or use convert Lirc codes for now. But for sure, this would be valuable work. If you do it, please drop me a note.

    EDIT : CaitSith2 dropped a note saying he has more up to date code for TVBG which turns off LGs too (see comments). So you’d better use his code than mine. Thanks CaitSith2 !

    EDIT2 : It seems that CaitSith2 is more high power : 8 TSAL6100, 4xAA… nice !

    In the schematics (tvbgone2_cms), all the little pads near JP1 are for a very weird slide button (I was too leazy to draw an eagle lib part). So don’t panic and adjust for your switch.

    There is another schematic included : tvbgone_mini.sch, which is a variant intended to be build as jewelry. I plan to use CR2477 batteries but I never built it. If you make it, please tell me how things turned.

    The P & R pins are « Program » and « Run » respectively. When done programming, just cut the wire going from the central pad to P, and make a solder bridge between the central pad and the R pad. If you need to reprogram again, remove bridge, and bridge between the central pad and P, etc…

    Get the eagle schematics, grab the code, turn off those TVs and have fun.

  • Fixing ‘IPSEC(initialize_sas): Invalid Proxy IDs’ with dynamic VPNs

    Posté le 9th décembre 2008 leucos Pas de commentaires

    Dynamic VPNs is a Cisco feature that makes a central router accept VPN establishment without specifying a peer or an ACL for the SA.

    The configuration is very simple (even simpler than normal, statically specified tunnels) so when the tunnel doesn’t come up, it is quite frustrating.

    And when you get ‘IPSEC(initialize_sas): Invalid Proxy IDs’, meaning SA ACL doesn’t match on both sides, you start to pull your hairs out : how can’t they match when they are not needer on the headend side ??

    Well, it seems that the headend is checking the remote SA specification (Proxy ID) anyway, and bails out from isakmp when things go wrong.

    Consider this log, saw on a router sitting at 172.22.1.130/27 with

     debug crypto ipsec

    and

    debug crypto isakmp
    *Mar  1 00:45:39.227: ISAKMP: set new node 909606036 to QM_IDLE
    *Mar  1 00:45:39.227: ISAKMP:(0:1:SW:1): processing HASH payload. message ID = 909606036
    *Mar  1 00:45:39.227: ISAKMP:(0:1:SW:1): processing SA payload. message ID = 909606036
    *Mar  1 00:45:39.231: ISAKMP:(0:1:SW:1):Checking IPSec proposal 1
    *Mar  1 00:45:39.231: ISAKMP: transform 1, ESP_3DES
    *Mar  1 00:45:39.231: ISAKMP:   attributes in transform:
    *Mar  1 00:45:39.231: ISAKMP:      encaps is 1 (Tunnel)
    *Mar  1 00:45:39.231: ISAKMP:      SA life type in seconds
    *Mar  1 00:45:39.231: ISAKMP:      SA life duration (basic) of 3600
    *Mar  1 00:45:39.231: ISAKMP:      SA life type in kilobytes
    *Mar  1 00:45:39.231: ISAKMP:      SA life duration (VPI) of  0x0 0x46 0x50 0x0
    *Mar  1 00:45:39.231: ISAKMP:      authenticator is HMAC-SHA
    *Mar  1 00:45:39.231: ISAKMP:(0:1:SW:1):atts are acceptable.
    *Mar  1 00:45:39.231: IPSEC(validate_proposal_request): proposal part #1,
    (key eng. msg.) INBOUND local= 172.22.1.130, remote= 172.22.80.129,
    local_proxy= 192.168.1.0/255.255.255.0/0/0 (type=4),
    remote_proxy= 172.22.80.128/255.255.255.193/0/0 (type=4),
    protocol= ESP, transform= esp-3des esp-sha-hmac  (Tunnel),
    lifedur= 0s and 0kb,
    spi= 0x0(0), conn_id= 0, keysize= 0, flags= 0x2
    *Mar  1 00:45:39.231: IPSEC(initialize_sas): invalid proxy IDs
    *Mar  1 00:45:39.231: ISAKMP:(0:1:SW:1): IPSec policy invalidated proposal
    *Mar  1 00:45:39.231: ISAKMP:(0:1:SW:1): phase 2 SA policy not acceptable! (local 172.22.1.130 remote 172.22.80.129)

    See it ?

    remote_proxy= 172.22.80.128/255.255.255.193/0/0 (type=4),

    the subnet mask 255.255.255.193 comes from a wrong ACL specification :

    permit ip 172.22.80.128 0.0.0.62 192.168.1.0 0.0.0.255

    instead of

    permit ip 172.22.80.128 0.0.0.63 192.168.1.0 0.0.0.255

    So 255.255.255.193 last byte yields a discontinuous mask (11000001) which is not so commonly used :)
    That’s why the tunnel is not coming up, and how you lost the last hour.

  • WRT54G/GS/GL Relay Mod

    Posté le 27th septembre 2008 leucos 2 commentaires

    Sometimes, it could be handy if your router (in this case, a WRT54G) could restart the device that connects it to the internet. For instance, if your ADSL modem needs some reboot or your cable modem needs a kick, having the WRT to do this would be nice.

    This could be especially useful if the modem+router are deployed as an access point somewhere in the wild.

    This usage is not limitating : we’re gonna build a WRT managed relay. What you switch on/off with this relay is your problem. A modem seems a reasonable idea, but you could switch a coffee pot (in this case, you should go with HTCPCP [http://www.ietf.org/rfc/rfc2324.txt]), lights, etc…

    All this is possible with little modification. The behaviour of the system here is to switch the relay for approx. 14 seconds, but this time is also easy to change. You can even use a trim pot instead to make it fully tunable.

    Schematics

    Relay board schematic

    Relay board schematic

    The schematic is rather simple. The board is connected to the internal WRT54G serial port (TX pin). This pin uses LV-TLL signals (0, +3.3V), and logic high is 0V. In other words, when nothing is send out to the serial port by the WRT, the level is low and the TX pin show 3.3V. What we want is to activate the relay when voltage on this pins drop. The trick is to feed the TX pin to the Threshold pin of a 555 timer (see those excellent 555 links in Electronics Club and Mecanno Electronique in french). And this is what happens when we the WRT sends data to the serial port : square wave comes out of second serial port TX pin and triggers the 555. For this to work, the 555 is powered at 6V, and thus triggered when TX voltage drops below 2V (approx 1/3 of VCC). The 6V feed is very primitive and comes from WRT power (12V) sliced in half by a voltage divider. It would be wiser to use a voltage regulator (7805 or al.), but we’re going the easy way here.

    The trigger from the 555 is fed at the base of the 2N2222 transistor which in turns feed the coil enough current to switch.

    Primitive, as I said.

    Assembling it

    First, be aware that doing the bad things below will void your WRT warranty, your modem warranty. You also can burn things or yourself in the process, etc… So do at your own risk. This being said, that stuff has been my first electronics project so it is really easy. « my first electronics project » should also be taken as a warning.

    • Open your WRT54G (or GS, or GL) by pulling the blue cover out
    • Take the WRT PCB out.
    • Solder a wire in the TX pin (pin 3) of the serial port

    Soldering this port is really easy, even I did it without breaking anything or melting the router to a shapeless plastic blob. You’ll find more info and pictures on the LinkSys WRT5G/GS Dual Port Mod Page. You don’t need IDC headers or high end stuff like this. Just solder in the hole. It will be ok as long as you don’t pull too much on the wire.

    The blue front cover has holes inside. These holes can’t be seen from the outside because of the stickers. This is a good place to make a complete hole with a hot wire if you plan to put your PCB relay outside the WRT. For recent models, like the GL, the PCB can probably fit inside.

    • Pull the TX cable through the blue cover and assemble the WRT back
    • Solder the wires with the DC power jacks on the board
    • Cut power cables from modem and WRT. Be sure to cut it at the right place ! You need enough cable to plug the wall wart and enough cable to plug the modem and WRT.
    • Remove some insulating material from the power wires and insert them in the screw clamps. Don’t mess with polarity or which wire go where. You would burn something for sure.
    • Now we need software to get this going. The basic idea is to ping some IP address, and when consecutive failures are detected, the relay is activated and the stuff behind it reboots. You can push the shell script to the WRT running Sveasoft firmware under Administration/Diagnostocs/Run, then paster script and click « Save Startup ». You can do the same with OpenWRT and probably with other firmwares.
    #!/bin/sh</code>

    ########### Tunable Variables #############
    # which host to check
    checkhost="212.27.48.10"

    # how often to check
    checkinterval=20

    # how many failures to activate relay
    activateafter=3

    # where is the wrt_relay_mod
    # serial=/tmp/test
    serial=/dev/tts/1

    # how long should we rest after switching
    rest=120

    # how many log/debug lines do we keep
    keeplines=20
    ########### End Variables #################

    #
    pingfail=0
    logfile=/tmp/wrm.log
    debuglogfile=/tmp/wrm_debug.log
    version=1
    #

    log() {
    echo -n `date` &gt;&gt; $logfile
    echo " : "${1} &gt;&gt; $logfile

    # trim log file
    head -n 8 $logfile &gt; $logfile.tmp
    tail -n $keeplines $logfile &gt;&gt; $logfile.tmp
    mv $logfile.tmp $logfile
    }

    debug() {
    echo -n `date` &gt;&gt; $debuglogfile
    echo " : "${1} &gt;&gt; $debuglogfile

    # trim debug file
    tail -n $keeplines $debuglogfile &gt; $debuglogfile.tmp
    mv $debuglogfile.tmp $debuglogfile
    }

    check_loop() {
    # we sleep $checkinterval seconds
    sleep $checkinterval

    if ping -qn -c 1 $checkhost &gt; /dev/null ; then
    # network is ok
    pingfail=0
    debug "/-\ =&gt; ping ok"
    sleep $checkinterval
    else
    # network seems down
    pingfail=`expr $pingfail + 1`
    debug "/?\ =&gt; $pingfail ping failures"

    if [ $pingfail -ge $activateafter ]; then
    log "relay switched"
    debug "/!\ =&gt; switching relay..."
    echo ACTIVATE &gt; $serial
    debug "/-\ &gt; resting for $rest seconds"
    pingfail=0
    sleep `expr $rest - $checkinterval`
    fi
    fi
    }

    # log few information at boot
    log "######################################"
    log "# wrm daemon version $version starting"
    log "# checkhost=$checkhost"
    log "# checkinterval=$checkinterval"
    log "# activateafter=$activateafter"
    log "# serial=$serial"
    log "# rest=$rest"
    log "######################################"

    # initial rest
    sleep $rest

    # control loop
    while true; do check_loop; done

    Tune variables at your liking. You can see how the relay is software activated : it just writes ‘ACTIVATE’ to the device driving the second serial port. What you write is not important. ’saddam’ and ‘george’ work equally well for instance. You should also restrain yourself from logging too much. The idel situation for deployment is to disable debug and logging. Space is scarce on the WRT.

    Here is the final thing assembler, with the driver modem (a Terayon TJ720). The system works fine but isAssembled setup quite static sensitive. So discharge yourself somewhere before touching the running circuit, or the relay might activate. Also, proper casing should be done. Putting the circuit inside the WRT is possible with latter models (WRT54GS and WRT54GL). This hasn’t been tester though, and might put some noise inside.

    Bill of materials

    Building this stuff shouldn’t take more than 2 hours and if you wish to buy parts, it will cost less than 4€ (3.0€ each by 20 at GoTronic in France).

    Here is the list of components required :

    Component Quantity
    MINIATURE RELAY 6-12V/12V-2A 1
    TWO WAY TERMINAL BLOCK 2
    1K RESIST. CARBON 1/4-5% 2
    47K RESIST. CARBON 1/4-5% 1
    33K RESIST. CARBON 1/4-5% 1
    TRANSISTOR NPN 50V-0.2A 1
    CAPACITOR 10n 1
    CAPACITOR 220u 1
    CAPACITOR 100u 1
    DIODE 1A 1N4007 or eq. 1
    DIODE 1N4148 or eq. 1
    NE555 TIMER 1
    LED 5MM RED (not in schematics) 1
    LEDS 5MM GREEN (not in schematics) 1
    PROTO BOARD (approx 20 holes x 20 holes) or PCB to etch 1

    Besides the board and may be the 555, the rest is easily scavengeable.