Setup a DNS proxy in CentOS

Today we are going to learn how to install a DNS server and client using CentOS. The DNS server is perhaps the most important part of the deal. However, there are plenty of support client OSs which can be either Windows, Linux, or Mac.

Server:

So first we go to the server and install iodine. Make sure you don’t have any other process that is using 53. If you do just change it so something else and use -b option in iodined server to relay any

yum search iodine
yum install iodine.x86_64

Then run the command

# iodined -P mypass 172.16.0.1 ns1.yourserver.com
Opened dns0
Setting IP of dns0 to 172.16.0.1
Setting MTU of dns0 to 1130
Opened UDP socket
Listening to dns for domain ns1.yourserver.com
Detaching from terminal…

To make iodined a service just write this to /etc/init/iodined.conf

start on runlevel [2345]
stop on runlevel [S016]

respawn
respawn limit 150 25
expect daemon
exec iodined -P mypass 172.16.0.1 ns1.yourserver.net 2>&1 >/tmp/iodine_boot.log

Client

Run the same command to install iodine. I’ll assume CentOS is the clients platform

yum install iodine.x86_64

Then start iodine

iodine -r -f -P mypass ns1.yourserver.com

To automaticly start it in the client side use this upstart job in file /etc/init/iodine.conf

start on runlevel [2345]
stop on runlevel [S016]
respawn
respawn limit 150 25
exec iodine -r -f -P mypass 1.2.3.4 ns1.yourserver.net >/tmp/iodine_boot.lo

And that’s it. To run the client side just type start iodine. After you run your client you just need to ping 172.16.0.1, which is the server ip address.

Make a very simple link webcrawler in CentOS

This WebCrawler will be made in Python using Beautiful Soup. It will simple collect data form a webpage and store every “href” inside that webpage. In order to work you must install python and BS. Normally Python should be installed already so theres BeautifulSoup missing.

yum install python-BeautifulSoup.noarch

Afterwards all you need is to make a file program.py and save this source in it.

#!/usr/bin/python

import urllib2,os,sys
import BeautifulSoup

if len(sys.argv) > 1 :
 origin_url = str(sys.argv[1])
else :
 # Must have http://
 origin_url = "http://www.stupidness.com/"

request = urllib2.Request(origin_url)
response = urllib2.urlopen(request)

soup = BeautifulSoup.BeautifulSoup(response)
href_array=[]

for a in soup.findAll('a'):
 link=a['href']
 if len(link) > 0 :
 if 'http://' in link :
 href_array.append(a['href'])
 else :
 href_array.append(os.path.dirname(origin_url)+a['href'])

print href_array

With this simple scraper/crawler you will get any href from a webpage.

To use this just type

python program.py

Stream from Blackmagic Decklink Recorder using FFMpeg

This a quick and dirty solution to stream from a Decklink Recorder card (i.e. blackmagic capture board) using ffmpeg. In my case I used an old Ubuntu 11.10 and installed all debians provided by Blackmagic and FFMpeg/avconv. There should be no secret installing those.

I also used the bmdtools git project. This is the best project to make sure your blackmagic board is working.

Requisits:

  • FFMpeg version 2.1.2
  • Blackmagic Design Desktop Video 9.8 – Driver and Utilities
  • bmdtools

Comand line

./bmdcapture -m 13 -C 1 -V 3 -F nut -f pipe:1|ffmpeg -i - -q 5 -r 25 -f mpegts udp://10.0.0.4:5010

bmdtools

  • -m : refers to the mode used in the capture. In this case I captured from a Amino HDMI STB using 720p 50Hz
  • -C : refers to the card index. I had two in this case so I used the second one
  • -V : refers to the input used. In  this case HDMI
  • -F : refers to the output mode.
  • -f : output type. In this case stdout

ffmpeg

  • -i : refers to the input. In this case stdin.
  • -q : this is a quality scale. The lower the better
  • -r : frames per second
  • -f : output format. Mpeg Transport stream. As no video nor audio codec was specified, ffmpeg uses the transport stream compliant codecs, meaning MPEG Video and MPEG Audio.

This is the quickest way to stream your capture video/audio. For a long term solution I would suggest capturing and streaming using VLC.