Sunday, December 6, 2009

Ubuntu - fixing the issue of /etc/resolv.conf being overwritten - edit /etc/dhcp3/dhclient.conf instead!

When you need a DNS server in order to access any sites, and since editing /etc/resolv.conf doesn't always work (because it gets overwritten regularly), thus this won't work work in /etc/resolv.conf:

search yahoo.com
namesever 10.1.10.2

(in my example, 10.1.10.2 is the IP of my router, which in turn has the proper DNS servers from Comcast, but I could use the DNS servers from Comcast just as well)

Since editing the /etc/resolv.conf may not work, instead, nano /etc/dhcp3/dhclient.conf and at the end of the file, add the entries.
Example for Comcast:

supersede domain-name "example.com"
prepend domain-name-server 68.87.74.162, 68.87.68.162

(where the domain-name-server can be a list, comma separated)

Saturday, December 5, 2009

Setting up MRTG on a managed switch (ex: on a SMC8024L switch)

Basic idea:

1
SMC switches have default IP 192.168.2.10, log into the switch via http interface from a PC on the same configured network, change IP (i.e. 10.1.10.10) and community string (from "public" to "digitalagora")

2
Install the snmp tools (example used Ubuntu), or "apt-cache search snmp" and find your favorite tools.
apt-get install snmp

3
Test if you see the switch:

snmpwalk -v 2c -Os -c digitalagora 10.1.10.10 system

sysDescr.0 = STRING: SMC8024L
sysObjectID.0 = OID: enterprises.202.20.59
sysUpTimeInstance = Timeticks: (981900) 2:43:39.00
sysContact.0 = STRING: SYSTEM CONTACT
sysName.0 = STRING: SMC8024L2
sysLocation.0 = STRING: SYSTEM LOCATION
sysServices.0 = INTEGER: 3

4
install mrtg by following: http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html Example:

wget http://www.zlib.net/zlib-1.2.3.tar.gz
gunzip -c zlib-*.tar.gz | tar xf -
rm zlib-*.tar.gz
mv zlib-* zlib
cd zlib
./configure
make
cd ..


5
run the cfgmaker tool to create your /etc/mrtg.cfg file, by telling it to connect to the digitalagora community @ the switch's ip. This creates a nice big config file with all the snmp info, provided that there was traffic on those ports. Otherwise, they're commented out.

cfgmaker --global 'WorkDir: /opt/website/mrtg' \
--global 'Options[_]: growright' \
--output /etc/mrtg.cfg \
digitalagora@10.1.10.10


6
run mrtg so that it sees the latest settings
env LANG=C /usr/bin/mrtg /etc/mrtg.cfg


7
Rebuild the web site's index file
indexmaker /etc/mrtg.cfg > /opt/website/mrtg/index.html


8
Look at the output.
http://localhost/mrtg/

Wednesday, December 2, 2009

Tinyproxy - enabing "Anonymous Host" and "Anonymous Authorization"

Testing headers at: www.digitalagora.com/headers


Client's headers when hitting digitalagora.com through Tinyproxy with disabled settings:
#Anonymous "Host"
#Anonymous "Authorization"
where in my example 8 header fields are showing:

Host = digitalagora.com
Connection = close
Via = 1.1 firewallserver (tinyproxy/1.6.5)
Accept = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent = Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/3.0.15
Accept-Charset = ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding = gzip,deflate
Accept-Language = en-us,en;q=0.5



Client's headers when hitting digitalagora.com through Tinyproxy with enabled settings:
Anonymous "Host"
Anonymous "Authorization"
where in my example 3 header fields are showing:

Host = digitalagora.com
Connection = close
Via = 1.1 firewallserver (tinyproxy/1.6.5)

Tuesday, December 1, 2009

Ubuntu and Apache: How to fix the error: "you have chosen to open ... which is a: application/x-httpd-php"

Ubuntu and Apache

How to fix the error: "you have chosen to open ... which is a: application/x-httpd-php"


Edit the Apache configuration file:
sudo nano /etc/apache2/apache2.conf

Find these 2 lines:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

Comment them by adding a pound sign in front:
#AddType application/x-httpd-php .php .phtml
#AddType application/x-httpd-php-source .phps

Add the following 2 lines right under the first 2 lines:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

Restart Apache:
sudo /etc/init.d/apache2 restart

Close your browser to clear its cache, and access your web page again.

Done.

-----

In a little more detail:

You can telnet to port 80 and view the web page. From the prompt, type:
telnet localhost 80
and then type "GET / HTTP/1.0" without the quotes, and press ENTER two times.
Note that there is a space before the slash and a space after the slash.
The page should then display. Here is an example of before the fix:

root@myfunserver:~# telnet localhost 80
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.0

HTTP/1.1 200 OK
Date: Tue, 01 Dec 2009 21:40:03 GMT
Server: Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.4 with Suhosin-Patch
Last-Modified: Fri, 20 Nov 2009 08:18:29 GMT
ETag: "b7a6b-f-478c91ee61f40"
Accept-Ranges: bytes
Content-Length: 15
Connection: close
Content-Type: x-httpd-php

Website works

Connection closed by foreign host.
root@myfunserver:~#

Notice that the Content-Type is: x-httpd-php. Now, after the change:

root@myfunserver:~# telnet localhost 80
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.0

HTTP/1.1 200 OK
Date: Tue, 01 Dec 2009 21:40:03 GMT
Server: Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.4 with Suhosin-Patch
Last-Modified: Fri, 20 Nov 2009 08:18:29 GMT
ETag: "b7a6b-f-478c91ee61f40"
Accept-Ranges: bytes
Content-Length: 15
Connection: close
Content-Type: text/html

Website works

Connection closed by foreign host.
root@myfunserver:~#

Notice that the content type is text/html.

How to play videos in Ubuntu

sudo apt-get update
sudo apt-get install vlc vlc-plugin-esd