2011/10/09

Managing the Cisco SGE2000 switch from Linux remotely

Today I had to access a new switch fresh out the box to manage for the first time, the Cisco SGE2000 24-port Gigabit Switch!

To manage the switch remotely I chose to plug a second network interface card (NIC) in a general purpose linux server with Debian GNU/Linux. Here is the previous network configuration:

# cat /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo eth2
iface lo inet loopback

# The primary network interface
allow-hotplug eth2
iface eth2 inet static
        address 192.168.24.111
        netmask 255.255.255.0
        network 192.168.24.0
        post-up iptables-restore < /etc/iptables.up.rules


In my network the gateway is located at 192.168.24.1.
Why using the eth2 for the default network access? Well, I needed the server to have a wake-on-lan capable NIC.

As indicated in the the quick start guide, to configure the switch over IP with Web GUI you should connect a PC to any of the non-stacking ethernet ports with an Ethernet cable.

"The default static IP address is 192.168.1.254 and the default management VLAN for the static IP address is VLAN 1. The default user name is admin and the default password is admin."

Well, if you have a second NIC available in a linux box connected to the switch you just can use it to manage the switch. Remember that the first NIC is need to access remotely the linux box as usual. You don't just have to be physically there :-) Just plug the cable and do it from your desktop (may be from your home?).

The new network configuration is:


# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo eth2
iface lo inet loopback

#Switch management
auto eth0
allow-hotplug eth0
iface eth0 inet static
        address 192.168.1.111
        netmask 255.255.255.0
        network 192.168.1.0
        gateteway 192.168.1.254


# The primary network interface
allow-hotplug eth2
iface eth2 inet static
        address 192.168.24.111
        netmask 255.255.255.0
        network 192.168.24.0
        post-up iptables-restore < /etc/iptables.up.rules

The NIC that I will use to manage the switch is eth0 (I use the eth2 as the default because the wake-on-lan feature), the network and the gateway indicated here are needed because because we are avoiding to stand in front of the switch with a laptop connected directly. We talk now talk with switch directly.

The network configuration is now:

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1c:c0:a1:7b:df 
          inet addr:192.168.1.111  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21c:c0ff:fea1:7bdf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:719 errors:0 dropped:0 overruns:0 frame:0
          TX packets:401 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:369094 (360.4 KiB)  TX bytes:37445 (36.5 KiB)
          Memory:e3200000-e3220000

eth2      Link encap:Ethernet  HWaddr 5c:d9:98:9e:ab:7a 
          inet addr:192.168.24.111  Bcast:192.168.24.255  Mask:255.255.255.0
          inet6 addr: fe80::5ed9:98ff:fe9e:ab7a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:34219 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15991 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10273485 (9.7 MiB)  TX bytes:3165535 (3.0 MiB)
          Interrupt:18 Base address:0x4000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3742 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3742 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:18011813 (17.1 MiB)  TX bytes:18011813 (17.1 MiB)


The route table is now:

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.24.0    0.0.0.0         255.255.255.0   U     0      0        0 eth2
0.0.0.0         192.168.24.1    0.0.0.0         UG    0      0        0 eth2


And now we access the switch's web interface from the linux box. In my case I just started a vncserver (local port forwarding with ssh) and login remotely from my home :-)


























We can access the telnet interface as well:

$ telnet 192.168.1.254


Now you may need this administration guide.

Enjoy!

2011/09/18

Dial up from Debian GNU/Linux and USB Modem Claro ZTE

When I am far away from a wired connection to internet, a USB Modem turns out to be just acceptable. Because this is not so frequent for me I log it now for future references.

Here I describe the procedure to connect through Claro, a telecom company established in Chile.

The hardware is a HSDPA USB Modem MF626 and Compaq 6715s laptop running Debian GNU/Linux Squeeze.

First, we need the package(s) for wvdial.
You may need some dependencies... yep, it may turn out to be the hen and egg problem (I used another laptop with a colorful operating system).

#apt-get install wvdial

Second, you run the autoconfiguration utility:

#wvdialconf

Third, check the configuration file written in /etc/wvdial.conf:

#cat /etc/wvdial.conf

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
New PPPD = yes
Phone = *99#
Modem = /dev/ttyUSB2
Username = claro
Password = claro
Baud = 112800


Verify the values, in my case the modem was not found in the place reported (/dev/ttyUSB1).

Fourth, run the dialer:

wvdial
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT 3600000
--> Carrier detected.  Waiting for prompt.
--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Sat Sep 17 18:03:22 2011
--> Pid of pppd: 11384
--> Using interface ppp0
--> pppd: �[7f]
--> pppd: �[7f]
--> pppd: �[7f]
--> pppd: �[7f]
--> pppd: �[7f]
--> local  IP address 186.172.53.253
--> pppd: �[7f]
--> remote IP address 10.64.64.64
--> pppd: �[7f]
--> primary   DNS address 8.8.8.8
--> pppd: �[7f]
--> secondary DNS address 8.8.4.4
--> pppd: �[7f]


If your connection is still not working, try bringing down any other network interface:

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1a:4b:77:59:eb 
          inet addr:192.168.0.29  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:16

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:747 errors:0 dropped:0 overruns:0 frame:0
          TX packets:747 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:70604 (68.9 KiB)  TX bytes:70604 (68.9 KiB)

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0

# ifdown eth0

Try again:

# elinks www.google.com


It worked.

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 ppp0
# ifconfig
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1149 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1149 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:266335 (260.0 KiB)  TX bytes:266335 (260.0 KiB)

ppp0      Link encap:Point-to-Point Protocol 
          inet addr:186.172.53.253  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:5935 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5673 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:4872033 (4.6 MiB)  TX bytes:1055978 (1.0 MiB)

2011/09/09

Sending an email using maven-postman-plugin and smtp.gmail.com

I configured maven to send a notification after deploying successfully an artifact.

Because this is done from my home server I chose to use gmail as my smtp server:

<plugin>
    <groupId>ch.fortysix</groupId>
    <artifactId>maven-postman-plugin</artifactId>
    <version>0.1.6</version>
    <executions>
        <execution>
            <id>send_an_email</id>
            <phase>deploy</phase>
            <goals>
                <goal>send-mail</goal>
            </goals>
            <inherited>true</inherited>
            <configuration>
                <mailhost>smtp.gmail.com</mailhost>
                <mailport>465</mailport>
                <mailssl>true</mailssl>
                <mailAltConfig>true</mailAltConfig>

                <mailuser>your_gmail_emailer_account@gmail.com</mailuser>
                <mailpassword>your_gmail_emailer_password</mailpassword>

                <from>your_gmail_emailer_account@gmail.com</from>
                <receivers>
                    <receiver>some_receiver@mail.domain</receiver>
                    <receiver>some_another_receiver@gmail.com</receiver>
                </receivers>

                <subject>Important subject</subject>
                <failonerror>true</failonerror>
                <htmlMessage>

                    <![CDATA[
                    <p>Partner, we have a new deployment!</p>
                    <br>
                    <p>Have a nice day.</p>
                    ]]>
                </htmlMessage>
            </configuration>
        </execution>
    </executions>
</plugin>


Important:

a) Put the declaration after the deployment declaration, this way if something goes wrong the email will not be send.

b) The <inherited> mark is needed only if you put this declaration in some parent pom and another child module is the deployed one. To maintain the order you may have to put the main declaration of your deployment first in the parent pom. Remember that "The order of execution depends on the order in which the goal(s) and the build phase(s) are invoked".

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>upload</id>
            <phase>deploy</phase>
        </execution>
    </executions>
</plugin>


<plugin>
    <groupId>ch.fortysix</groupId>
    <artifactId>maven-postman-plugin</artifactId>
    ...
    ...
    ...
</plugin> 

c) The plugin didn't work until I declared the <mailAltConfig> (check out this and this).

In my case I only send the email when "production" deployment is done (I love profiles!).

What about this?

mvn deploy -Pprod

Nice!

2011/09/01

BBC Radio Stream in Windows and Linux

You may listen to the BBC Radio Streams available from this webpage:

In Windows you may add the URLs to Winamp:















But a list of multiple URLs is added (?)... ok, I don't know why... I just played the first one and deleted the trash.



After playing, the URL just showed right.



And then you can save the playlist.



In Linux (I'm using Debian GNU/Linux Squeeze) you can use vlc:

sudo apt-get install vlc

You just copy the link location and then add it into vlc pressing [CTRL+N]:



















The playlist that you saved from Winamp may be play in vlc, nice!