Rss Feed Tweeter button Facebook button Technorati button Reddit button Linkedin button Webonews button Delicious button Digg button Flickr button Stumbleupon button Newsvine button

A Waage Blog

Ruby, Rails, Life

Archive for the ‘Networking’ Category

CentOS NFS How-to Guide: Exporting and Mounting a NFS Drive

with one comment

This guide shows you how to start an NFS service on one (host) machine, export the NFS drive, and then connect to that NFS drive from a client machine.

## On the NFS host machine:

#Start Portmap service if needed.
#NFS uses portmap and a bunch of ports (that you can set in /etc/sysconfig/nfs) if you want.
See this link for more details on NFS ports.

#Start portmap service

service portmap status
service portmap start (if needed)

#Start NFS

service nfs start

#Edit /etc/exports
#Reference: https://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/ref-guide/s1-nfs-server-export.html

Format is (select the options you want):
[Directory to export] [Hosts to allow](options)

/home/just_testing 192.168.0.0/24(rw,async,wdelay,root_squash)

#Run exportfs to refresh NFS exports

exportfs -av

Be sure the proper ports are open on iptables
Reference: http://pario.no/2008/01/15/allow-nfs-through-iptables-on-a-redhat-system/

## Now on your NFS client machine:
Start portmap

service portmap start

Create a mount point and mount the NFS drive. Remember to use your own server’s IP address:

mkdir /mnt/nfs-usbdisk
mount 192.168.0.2:/home/just_testing /mnt/nfs-usbdisk

Voila ! Tail your logs if you have any problems !

Written by Andrew Waage

April 8th, 2010 at 7:22 pm

Posted in Networking, linux

Tagged with , , , ,

Resolve a hostname from an IP address in Ruby (Reverse-DNS)

with one comment

It sounds easy, but I tried a lot of things before finding the solution I used.

I tried using:

`host 66.249.67.49` or
`nslookup 66.249.67.49`

These were fine, but it seems a bit hacky to use the shell. Also, it would require some sort of parsing to get the hostname that I want.

Browsing the web, I found a couple solutions that almost worked.

s = Socket.getaddrinfo('66.249.67.49',nil)
hostname = s[0][2]

This solution worked in IRB, worked in console, but for some reason would not work when I was running my mongrel server and trying to perform the exact same method call from a web-browser. ( I still don’t know why).

Digging around a bit more, I came up with this simple solution:

host = Resolv.new.getname('66.249.67.49')

Is it really that easy?? Give it a shot and let me know your thoughts !!

Written by Andrew Waage

October 9th, 2009 at 2:47 pm