Showing posts with label opensource. Show all posts
Showing posts with label opensource. Show all posts

Tuesday, 11 March 2014

Replace VI with VIM on Debian 7

Make sure you can access internet before attempting this.
  • Open the terminal
  • apt-get install vim
  • sudo vi /etc/vim/vimrc
Uncomment the "syntax on" line to enable color coding that vim comes with. This will replace vi with vim, if you edit a file with say "vi .bashrc" it should show you color coded text instead of just black and white.

Thursday, 20 February 2014

Configuring and Deploying DNS servers (primary, secondary, root and cache on centos 6.5) - Part 3 - Root and Cache

Configuration on Root DNS Server:

The root zone maintains information regarding top-level domains. Root-zone servers for internet top-level domains are already deployed. With this you can create your own internet naming scheme, which is usually done in intranets who have their own top-level domains
  • Install bind packages
    • yum install bind bind-utils bind-chroot bind-libs
  • Edit named.conf
    • vi /etc/named.conf
listen-on port 53 { 192.168.12.4; }; //change this to your ip address
*remove the allow-query line
*optional remove recursion line

 zone "." IN {
        type master;
        file "root.net";
      };



  • Create and edit root.net
    • vi /var/named/root.net
 $TTL 86400
@    IN    SOA    root.msm.net.    admin.root.msm.net. (
            535 ; serial
            3H ; refresh
            15M ; retry
            1W ; expiry
            1D ) ; minimum
@                IN    NS    root.msm.net.
root.msm.net.    999999        IN    A    192.168.12.4 //root servers ip and fqdn
msm.net.            IN    NS    ns.msm.net. //primary server's fqdn and zone name
12.168.192.in-addr.arpa        IN    NS     ns.msm.net. // reverse zone named and fqdn of primary dns server
ns.msm.net.            IN    A    192.168.12.2 //fqdn and ip of primary dns server, you can also add similar entries for secondary dns below



  • Open Firwalls
    • iptables -I INPUT -p tcp --dport 53 -j ACCEPT
    • iptables -I INPUT -p udp --dport 53 -j ACCEPT 
  •  edit resolv.conf
    • vi /etc/resolv.conf
search msm.net
nameserver 192.168.12.4 //resolve to its own ip address just to check if server is functioning



  • Start named daemon
    • service named start
  • Query some records that are stored in primary server's database
    • nslookup
      • cache.msm.net 

 Configuration on Cache DNS server:

when DNS(bind named) is installed, by default it configures the machine as a caching server. All we have to do is change the file-name in named.conf and create a file accordingly to point towards our own root DNS server.

  • Install bind packages
    • yum install bind bind-utils bind-chroot bind-libs 
  •  Edit named.conf
    • vi /etc/named.conf

listen-on port 53 { 192.168.12.5; }; //change this to your ip address
*Remove the allow-query line
*Remove dnssec-lookaside auto;
*DON'T remove the recursion line. Of all the servers, this is the only one that must do recursion

 zone "." IN {
        type hint;
        file "file.ca";
      };


*Remove include "/etc/named.root.key";

  • Create and edit file.ca
    • vi /var/named/file.ca
  .        999999    IN    NS    root.msm.net. \\fqdn of root dns server
root.msm.net.    999999        A    192.168.12.4 \\fqdn and ip address of root dns server


  • Open Firwalls
    • iptables -I INPUT -p tcp --dport 53 -j ACCEPT
    • iptables -I INPUT -p udp --dport 53 -j ACCEPT 
  •  edit resolv.conf
    • vi /etc/resolv.conf
search msm.net
nameserver 192.168.12.5 //resolve to its own ip address


  • Start named daemon
    • service named start
  • Query some records that are stored in primary server's database
    • nslookup
      • cache.msm.net
 If this is successful then change the /etc/resolv.conf in all the DNS servers to point to caching server IP address to reduce the load on Primary/Secondary and distribute it towards cache.

Prefer a Video Walkthrough?



Check this wiki page for more information on what's being done
http://en.wikipedia.org/wiki/Alternative_DNS_root

 That's all folks.
 Enjoy.

Tuesday, 4 February 2014

Configuring and Deploying DNS servers (primary, secondary, root and cache on centos 6.5) - Part 2 - Secondary DNS

This walk-through assumes that you have initial deployment of Primary DNS server. Look at my previous post for that.

Configuration on Primary DNS server:

  • edit /etc/named.conf
add the allow transfer statement in your zone declaration(both forward and reverse)

 zone "msm.net" {
        type master;
        file "msm.net.db";
        allow-transfer { 192.168.12.3; };
};

zone "12.168.192.in-addr.arpa" {
        type master;
        file "msm.net.rev.db";
        allow-transfer { 192.168.12.3; };
};

  •  Allow firewall to communicate on tcp/udp port 53
    • iptables -I INPUT -p tcp --dport 53 -j ACCEPT
    • iptables -I INPUT -p udp --dport 53 -j ACCEPT
  • Restart the named deamon
    • service named restart

Configuration on Secondary DNS server:

Make sure you have internet access.
  • Install Bind packages
    • yum install bind bind-utils bind-chroot bind-libs
  • edit /etc/named.conf
 listen-on port 53 { 192.168.12.3; }; //Ip address of the machine
*Remove the allow-query line
*Optional: remove recursion statement and the "." zone to disable recursion and caching.

 zone "msm.net" { //your forward zone statement, same as primary
        type slave; //slave sets this server as slave
        file "msm.net.db"; //the file name that you created in primary
        masters { 192.168.12.2; }; //this is telling the server that this ip is my primary dns's ip
        allow-transfer { none; };
};

zone "12.168.192.in-addr.arpa" { //reverse lookup zone statement, same as primary
        type slave; //this sets this server as a slave of this reverse zone
        file "msm.net.rev.db";  //the file name that you created in primary for reverse  zone
        masters { 192.168.12.2; }; //primary server's ip address
        allow-transfer { none; };
};




  • Add exception in SELINUX
    •  setsebool -P named_write_master_zones 1
  • make name the owner of /var/named directory
    • chown named:named /var/named
  • Start the named daemon
    • service named start
  • Check logs if everything went well. It should say zone loaded and file transfered
    • tail -30 /var/log/messages
 named[21296]: transfer of 'msm.net/IN' from 192.168.12.2#53: Transfer completed: 1 messages, 7 records, 206 bytes, 0.001 secs (206000 bytes/sec)


If everything went fine then you should see your zone files under /var/named automatically transferred by starting the named daemon, this transfer of file is called a zone transfer.

Prefer a video walk-through? have a look...

Wednesday, 29 January 2014

Create isolated network on Virtual Machine Manager - Centos 6.5

Since most of the Linux administration practice is done in a virtual environment, I thought I should create a video about it, as I am aware that some students at my college struggle with it in their labs. Please let me know if I missed anything or did not explain anything clearly.

Thanks,




Saturday, 11 January 2014

ASUS RT N16 + OpenWRT + nodogsplash = WiFi Hotspot (For beginners)



 
1.                  Make sure you are directly connected to the router through a cable
·         Take an ethernet cable from your ASUS modem and plug it into your pc/laptop

2.                   Now access your modem by going into the browser and typing: 192.168.1.1
·         Go to administration tab and click on Firmware upgrade/update
NOTE: Please use internet explorer for all of these configurations. There are some issues reported in other browsers.
       
3.                   You will have to load a DD-WRT basic image first to load the openWRT image. You cannot directly load openWRT image for some reason I dont know of
4.                   Once the image is downloaded just click on browse on the ASUS firmware upgrade page and browse to the DDWRT image and upload it

5.                   router will restart and it will ask you to set a root username and password. Just set anything, you won't be using ddwrt for very long.

6.                   Now download the working openWRT image for RTN16 from here: http://downloads.openwrt.org/barrier_breaker/14.07/brcm47xx/mips74k/
·         Download the image named "openwrt-brcm47xx-mips74k-squashfs.trx"

7.                   Now access your routers website again: 192.168.1.1

8.                   Go to Administration -> Firmware Upgrade/Update

9.                   Browse to the squash.trx image and upload it. Router will restart by itself.

10.               OpenWRT does not come with the a Web User Interface, and using it is pretty much optional.
We will be installing a WEB UI just to make things easier.

11.               Open a command prompt sessions (cmd, can be opened by searching for cmd in start menu)

12.               type : telnet 192.168.1.1

13.               Now you should be connected to your router.

14.               Now take an ethernet cable from your Rogers modem and plug it into the WAN port at the back of your ASUS router(This should give your router internet access)

15.              Type these commands in the terminal
·         opkg update
·         opkg install luci
·         opkg upgrade libuci uci libc opkg busybox base-files dnsmasq libiptc dropbear mtd wl libgcc ppp wlc

16.              Now install NodogSplash
·         opkg install nodogsplash

17.              Configure uhtppd daemon to work on port 8080 (so you can access luci even when you are not authorized to go the internet)
·         vi /etc/config/uhttpd
·         replace line "list listen_http                       0.0.0.0:80" with "list listen_http 0.0.0.0:8080"

18.              Configure nodogsplash
·         There is a lot of options with nodogsplash, I did not change much except that I modified the redirect URL, so if the client gets the splash page and he/she authenticates, instead of going to the website they wanted to go, it will redirect them to the URL I want them to go, then they can server all the internet they want.
·         vi /etc/nodogsplash/nodogsplash.conf
·         you can change the value of "RedirectURL" to the website if you want to the redirection, otherwise leave it.
·         One thing you must do is add port 8080 to firewall rule. Look for "for administration from the GatewayInterface.  If not,  # comment these out."
·         add below port 443 this line "FirewallRule allow tcp port 8080"

19.              Start uhttpd and nodogsplash daemon
·         /etc/init.d/uhttpd enable
·         /etc/init.d/uhttpd start
·         /etc/init.d/nodogsplash enable
·         /etc/init.d/nodogsplash start

20.              Open your web browser and type "192.168.1.1:8080"

21.              Go to Network > WiFi and click on enable.

22.              Now if you connect through wifi you will get the default splash page that comes with nodogsplash. If you dont get it then restart the nodogsplash service by /etc/init.d/nodogsplash stop
            /etc/init.d/nodogsplash start

If you want to modify the splash page, which you most like would want to, then you can do so by vi /etc/nodogsplash/htdocs/splash.html
you can write your own html code there.
Let me know in the comments bar for any questions.
Enjoy!

My SOURCES:
http://www.youtube.com/watch?v=nw4bo4rXGgQ
https://projectfirewall4.wordpress.com/2012/02/01/installing-openwrt-firmware-on-asus-rt-n16-router/#comment-21
http://www.dd-wrt.com/wiki/index.php/Asus_RT-N16#How_to_restore_to_factory_firmware
http://wiki.openwrt.org/doc/howto/wireless.hotspot.nodogsplash
http://wiki.openwrt.org/doc/uci/uhttpd

Sunday, 15 December 2013

Pkgdb2 fully setup on ireland - Official release 0.3

My goal for Release 0.3 in the beginning was to deploy Fedora Package Database and make it work with fedpkg. However, pkgdb was getting outdated so I worked on installing pkgdb2. I managed to deploy a development instance of it for my 0.1, 0.2 I could not do much as it was getting hard to communicate with Pierre.

Now, I have successfully deployed pkgdb2 on

ireland.proximity.on.ca:8080/pkgdb2

It is completely functional and nothing is broken. It has a database that it is communicating with but there is no data in it as of yet, as i did not understand all the table relationships and did not have time to look into it. Nonetheless, there is no reason why it would not work when data is put into it, because the website is connecting to the right database.

I was told to deploy the pkgdb2 on ireland on a virtual host so i set it up on port 8080. I have properly configured the firewall to allow port8080.
I requested the packages list that needed to be put into the database and I haven't got it yet, however, we have the data scheme now so that getting the packages information in there should not be a big issue. Also, if we click login on the website it is going through FAS authentication, in the future we may set up our own authentication system but for now this is working. Ideally, Anybody who is in sytem-admin or package-maintaner group in FAS should be able to modify the packages through th GUI(it is not tested yet).

The database scheme can be checked here: http://ireland.proximity.on.ca:8080/tables.txt

The database dump is also there on ireland. As of yet, the website is communicating with an empty database based on mysql.

Enjoy the holidays.

Pkgdb2- Troubleshooting the installation and Improvement suggestions

Suggestions to the Package author:

  1. Please include a list of required packages in the instructions
  2. Sqllite database works in development version but does not work with the deployment on Fedora19. I have checked it several times on different machines. So we can either convert the data to other databases or fix the sqllite version.
  3. The package "Python Fedora" does not work properly when installed through yum. It has to be installed through github. We can include that in the instructions as well.
  4. There is this line in pkgdb2.wsgi which suggests to give a path to "pkgdb2" which is actually asking the path to the clone "packagedb2". I was really confused here :). Then I got to know how python import works to figure it out.
  5. Also, after installing python-flask from yum, it had to be uninstalled through pip for the FAS login to work, threebean told me that. I have no idea why.
That's about it, thank you very much for the help.

Troubleshooting installation issues:

the most annoying errors were python import errors. If you we don't know how python is working, we will be confused.

"Error importing so and so module" is just python's way of saying you have not met the dependencies and some modules are missing. Whatever module python fails to load, please check if you have installed all the required packages.

Might get some errors with mysql installations. Fedora 19 comes with Mariadb, if you are familiar with it go ahead, otherwise you will have to remove mariadb and install mysql. After installing mysql, sometimes it asks for a password and the default "mysql" password does not work. The issue has been discussed here:

http://www.webhostingtalk.com/showthread.php?t=875255

Also, when converting database, if it fails to convert. Then its probably missing the change that had to be made on the dumpfile. Regardless, if it fails, the database has to be drop and created again for the converter to work.

That's all folks :)


How to install pkgdb2 (Fedora Package Database) from scratch

This cookbook assumes that Fedora 19 is freshly installed, with some design and development tools that the Fedora setup offers.

Install the Required Packages:

$ yum install vim git python-flask \
python-flask-wtf python-wtforms \
python-kitchen python-sqlalchemy \
 postgresql-server postgresql-plpython \
python-psycopg2 mod_wsgi memcached \
 community-mysql-libs community-mysql-devel \
 community-mysqlcommunity-mysql-server \
  python-dogpile-cache python-openid-teams \
  python-openid-cla python-bugzilla python-memcached \
  python-docutils python-dateutil \
 python-urllib3 MySQL-python \
 python-pip


$ git clone https://github.com/fedora-infra/python-fedora.git

$ cd python-fedora

$ python ./setup.py install

$ cd ~

Getting the Data from the sqllite database and installing pkgdb2 libraries:


$ git clone https://github.com/fedora-infra/packagedb2.git

$ cd packagedb2

$ python ./setup.py build

if it works properly then say:

$ python ./setup.py install

you may remove the build if you want.

$ python createdb.py

$ cd /var/tmp

Converting the data dump to and inserting it into MySQL:


$ service mysqld start

$ check: tail /var/log/messages
see if it started successfully "It should say 'Started MYSQL database Server'"

$ mysqladmin -u root password yourpassword


Download this awsome sqllit to mysql script:

www.redmine.org/attachments/download/8273/sqlite3-to-mysql.py

and place it under /var/tmp

go to /var/tmp : $ cd /var/tmp

$ sqlite3 pkgdb2_dev.sqlite .dump > mydump

unfortunately, we will have to modify the dump a little bit before we can start converting:

$ vi mydump












Change this line, and two more lines



$ mysql -u root -p

mysql> create database pkgdb2;
mysql> exit

$ cat mydump | python sqlite3-to-mysql.py | mysql -u root -p pkgdb2 --default-character-set=utf8

if it executes without saying anything, that means it was successful.

Configuring pkgdb2:


Now lets get back to configuring our pkgdb2.

$ cd ~/packagedb2/

$ mv ./utility/pkgdb2.cfg.sample ./utility/pkgdb2.cfg

$ vi ./utility/pkgdb2.cfg

comment the postgres line and un-comment the mysql line. Change the admin groups to Fedora Groups you are part of, or whatever groups you want to be included in the package admin groups. Also change the FAS username and Password line to reflect your FAS credentials, it can be set to none if you do not want FAS integration. Refer to the screen-shot:


Single quotes around the values are important.




Once that is done, we will have to modify our wsgi script.
$ vi pkgdb2.wsgi

Un-comment and adjust the values as shown:


 Then we will have to edit the default-config.py script to reflect our new database:

$ vi /lib/python2.7/site-packages/pkgdb2-0.1.0-py2.7.egg/pkgdb2/default_config.py


DB_URL = 'mysql://root:mypassword@localhost/pkgdb2'

then copy the pkgdb2.conf file to http configuration directory.

$ cp pkgdb2.conf /etc/httpd/conf.d

$ vi /etc/httpd/conf.d/pkgdb2.conf

make the following changes:



























Restart Apache and Mysql.
$ service httpd restart
$ service mysqld restart

Security Issues:


Open the http port:

$ iptables -I INPUT -p tcp --dport 80 -j ACCEPT

You may try to access the server, but it will give you a 403 forbidden most probably because of SELINUX or permissions missing on some of the folders. You may chose to disable SELINUX(not recommended) or make exceptions. You can make exceptions like this:

Try to access the website, get the 403 error and then come back to terminal and type

Do a tail /var/log/messages

look for this command, copy it and run on your terminal:
sealert -l a66201ea-062a-4a4b-8d2f-eaf29d3cd855

it will give you some things that are being blocked by SELINUX, and it will give you the boolean, just take the boolean and make exceptions:

setsebool -P httpd_read_user_content 1

Finishing Touch:


make sure you have execute(x) permission for everybody in the whole path to pkgdb2.cfg and pkgdb2.wsgi

also do: pip uninstall flask

and install/check if flask is installed with yum: yum install python-flask.

Now restart the services again

$ service httpd restart
$ service mysqld restart

Go to your favourite browser and type: localhost/pkgdb2
and you will see the deployement.

Any issues regarding this installation you can either ask me on the comments or directly talk to the package authors on github
they are really helpful people.



Got the database to work with pkdgb2 - \o/ -

Remember the database that I converted to mysql? yes, an innovation that I did :) I got mysql database to work with pkgdb2 so the link is not broken anymore. pkdgdb2 was not officially tested with mysql, therefore, I became the first person to do it. Although the pkgdb2 was tested with sqllite database, it was not working with it. I will update my blog with more details later on. Meanwhile, you can check the working version of pkgdb2 here: http://ireland.proximity.on.ca:8080/pkgdb2

Every Tab should work except the "login" button. That goes to FAS login, so I dont think we need to get it working.

Saturday, 14 December 2013

Successfull Deployment of Fedora Package Database(pkgdb2) on ireland(could be my release 0.3 if I cannot get help to test it with a database)

As I said in my last blog post that I would try it on a new VM. I installed Fedora 19 from scratch and this time I did not install pkgdb2 under python/site-scripts, however, I ran it directly from clone to see if that makes a difference. Unfortunately, it did not make any difference. We know for sure that it is hitting the right database but somehow the connection is not opening up properly. I have left a message for Pierre on github and I am online since about 36 hours with very little sleep, waiting to catch him on IRC.

I got access to ireland on Friday, and was told by Chris to deploy the the instance on there. Therefore, however much installation was completed, I successfully set it up Fedora Package Database on ireland.proximity.on.ca. Also, I set it up on virtual-host running on port 8080. If anybody wants to check out the deployment they can do so on this url: http://ireland.proximity.on.ca:8080/pkgdb2

Keep in mind, as there is no database to test with, if you click on any link you will get a 500 internal server error as the config files are not properly communicating with the sample sqlite database. Here is a screen-shot of the instance:





















 

In my desperation of testing my achievement with a database, I even converted the sample database to mysql and tried to test it with it. I thought I had to change only a couple of "dbi_url" lines, however, there was much to change in the core python scripts that I do not possess knowledge of.

If I could not test it with a database by tomorrow 6pm then I will just document the process of pkgdb2 deployment(as far as I could deploy it).

Pkgdb2 - 5 hours of head scratching till 6 in the morning

Thursday night after I finished my exams and sat down to install pkgdb2, I made some progress but got stuck in getting a database together to test the pkgdb2 with. Luckily, I found Pierre- the package author, online 1 in the morning.

I started asking him questions and we were trying to resolve why the template database that comes with the clone, not working with this installation. We checked all the important python scripts in a spree of "fpaste" then figured out that my mod_wsgi file is pointing towards the clone and not the installed pkgdb2 directory. So we fixed that and I installed Sqlite manager to see if the database is good and it was. Then we were checking the httpd logs and it still says "table Package" not found. We know from the trouble shooting "print" statements in the script that it is pointing towards the right database but still it gave the same error. Even Pierre said "Now even I don't know what is wrong" :)

Anyhow, I installed A new VM to conduct a fresh installation from scratch and see if it works this time.

How to add "Discord" in Steam's Big Picture Mode

 With the release of Steam deck a lot of people are turning into Steam Deck Big Picture Mode(BPM) to enjoy an exclusive gaming experience, t...