add static route in Cantos and make sure it wont loose after reboot

1. Adding Routes

[root@localhost ~]# route add -net 10.4.3.0 netmask 255.255.255.0 gw 192.168.129.55
[root@localhost ~]#

Or

[root@localhost ~]# route add -net 10.4.2.0 netmask 255.255.255.0 dev eth0
[root@localhost ~]#

2. Show routing table

[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.129.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
10.4.3.0 192.168.129.55 255.255.255.0 UG 0 0 0 eth0
10.4.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.129.2 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#
if you dont wanna loose, you can add above command to /etc.rc.local
or try this way
add routes in route-eth0 file
 static routes for the eth0 interface would be stored in the /etc/sysconfig/network-scripts/route-eth0 file. The route-interface file has two formats: IP command arguments and network/netmask directives.

The following is a sample route-eth0 file using the IP command arguments format. The default gateway is 192.168.0.1, interface eth0. The two static routes are for the 10.10.10.0/24 and 172.16.1.0/24 networks:

default 192.168.0.1 dev eth0
10.10.10.0/24 via 192.168.0.1 dev eth0
172.16.1.0/24 via 192.168.0.1 dev eth0

Static routes should only be configured for other subnets. The above example is not necessary, since packets going to the 10.10.10.0/24 and 172.16.1.0/24 networks will use the default gateway anyway. Below is an example of setting static routes to a different subnet, on a machine in a 192.168.0.0/24 subnet. The example machine has an eth0 interface in the 192.168.0.0/24 subnet, and an eth1 interface (10.10.10.1) in the 10.10.10.0/24 subnet:

Find out the IP address of eth0 and display IP only

 

Now you just wanted the IP address, use grep to get the IP:
$ /sbin/ifconfig eth0| grep 'inet addr:'Output:

inet addr:192.168.2.1  Bcast:192.168.2.255  Mask:255.255.255.0

To get IP address from use cut command:
$ /sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2Output:

192.168.2.1  Bcast

Finally remove Bcast with awk
$ /sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
Output:

192.168.2.1

How to setup an NFS share from Mac OSX Server to Linux

Set up the NFS share

Download NFS Manager from www.bresink.com/products.html. It’s very low-cost shareware but you can use it free if you don’t mind an occasional pop-up reminder. You could probably set things up without NFS Manager, but it makes things a heck of a lot simpler.

Using NFS Manager, add a new share, browsing for the directory you want to make available – in my case that’s /Volumes/Firewire1. Use the option to allow only specified computers access (depending on your network connection it might not be possible for random hackers to mount your hard drive remotely, but it’s best to be safe). Use the IP address you assigned to the Linux VM, in my example that is 10.0.1.100. You’ll need to hit the “Activate” button iback on the main screen to start the actual processes running.

Configure the share in NFS Manager

Configure the Mac’s firewall

The NFS protocol uses ports 2049 and 111,2 and the Mac’s built-in firewall blocks these by default. Open “System Preferences, Sharing”, and go to the “Firewall” tab. You will see a list of network services that you can click on to enable or disable access – however, NFS is not on the list. Hit “New…” and select “Other” from the dropdown list. In the TCP Port Number(s) field enter “2049,111”. Enter a description such as “NFS”, and click OK.

Edit the new firewall entry

Create new entry in firewall settings

Set up the client side

Before making any changes to your Linux VM, take a backup (or in Parallels Desktop version 3, create a snapshot).

Now in Linux as root, create the directory to use for the share. I’m going to call it “extdrive”, so I’ll enter mkdir /extdrive. Next edit the file /etc/fstab (filesystem table), adding an entry like this (I’m using my external drive example – substitute your own details for IP address and path:

10.0.1.2:/Volumes/Firewire1  /extdrive   nfs

(Confirm that Linux can see the host by pinging the specified IP address, e.g. by entering ping 10.0.1.2 on the command line.) There are other fields for entering more information, but I’m cheating somewhat by letting them all use their system defaults. (However, from checking man nfs it seems the defaults are all pretty sensible, for example if you don’t set explicit read and write packet sizes, client and server negotiate to find the optimal size both can handle.)

 

Now reboot Linux to make sure it worked. What you should see when you log back in is directory called “/extdrive” (or whatever you named it) mapped to the specified path on the Mac.

Check that you can see the shared drive from Linux

Notice that it belongs to “501”, which is the ID of my user account on the Mac. If I create a user and set the ID to 501, that user’s name will be shown instead.

Also notice that the invisible system files are shown (in Finder I only see appParallels VM and william). Obviously you’ll want to avoid messing with those. Perhaps better, share a subdirectory instead of the entire filesystem.

Troubleshooting

By default, the Linux boot process issues a mount command for each entry in /etc/fstab (“filesystem table”). If the new filesystem is not getting mounted, you can investigate what isn’t working by executing the command yourself.

The mount command can be used on the Linux command line to mount a filesystem manually. You’ll need to be connected as the root user, so either enter su - (then enter the root password), sudo su (then enter your own password), or else execute the commands as the currently connected user (e.g. oracle), placing sudo before each command, e.g. sudo mount -v /extdrive.

mount -v /extdrive (the -v is “verbose” mode) will attempt to mount the drive as you specified it in /etc/fstab. However, a common problem is that either the host Mac’s firewall or its NFS server process rejects it, and all you see on the Linux command line is the mount command appearing to hang. To check what’s going on, first go back to Firewall tab in the Mac’s Sharing preferences, and hit the Advanced option, enable firewall logging if it isn’t already enabled, and hit Open Log. This bring up a Console window showing the actual Firewall log in real time. Now go back to Linux and re-enter the mount command, and watch for “deny” entries appearing in the Firewall log. For example, when using NFS with Xubuntu I got log entries like this:

Sep 23 09:50:14 starbase-2 ipfw:  12190 Deny TCP 10.0.1.201:785 10.0.1.2:1011 in via en0
Sep 23 09:50:38 starbase-2 ipfw:  12190 Deny TCP 10.0.1.201:785 10.0.1.2:1011 in via en0
Sep 23 09:51:26 starbase-2 ipfw:  12190 Deny TCP 10.0.1.201:785 10.0.1.2:1011 in via en0

10.0.1.201 was the Xubuntu VM, and it was attempting to connect through port 1011 which I had not authorised. I added 1011 to the “TCP port numbers” list in the firewall settings to allow these connections.

If nothing is appearing in the Firewall log, then either it can’t see the host at all (in my example 10.0.1.2 – you may need to double-check that you have entered the right IP address) or else the NFS server is not authorising the connection. Go back over the NFS Manager settings and make sure that the Linux VM’s IP address is correctly specified. It should be entered in /etc/hosts, you should be able to ping it from the Mac’s command line, and it should be listed in the “List of computers or computer groups” window in NFS Manager.

 

Courtesy: http://www.williamrobertson.net/documents/nfs-mac-linux-setup.html

install NFS server Centos / Red hat

1. Install NFS and Create Directories

The first step is to create a NFS server if one is not already set up. The client OS filesystem lives (is stored) on that NFS server. As part of the PXE boot process a host with a PXE boot enabled network card, will issue a broadcast for a an IP address, and be provided that IP assignement by DHCP server aloing with a optional field for a so-called ‘next-server’ and an initial boot image to chain load after the minimal boot image used by the network card (from ROM, or other source) . The host the retreives its files and configurations from the NFS share configured in this section.

Having spare disk space available in the NFS export becomes a necessity as one starts adding more than one variety of an installation, because the entire client system OS will be copied to the NFS server. Customarily, the end user /home is not carried in those images, but separately mounted. Go ahead and install the NFS packages if they aren’t already installed on your server.

 

# yum install nfs-utils nfs-utils-lib sytem-config-nfs

Next, create the directories that you will be needing later on. These will be the actual NFS shares specified. If you want to put these somewhere else, or you can to specify different names, do so. You can share them from anywhere. The first directory will host a server installation of CentOS4, and the second directory a CentOS installation with a desktop environment.

 

# mkdir -p /var/backup

 

2. Configure NFS Mounts

Now you need to create the actual shares with read-write permission and start the NFS server.

 

# vim /etc/exports
/var/backup              *(rw,sync,no_root_squash)

Start the NFS server and verify the NFS shares are ok and start the service. If NFS services are already running, then reload them.

 

# service nfs start (reload)
# chkconfig nfs on
# nfs-export -l

Client side Mount

edit your  /etc/fstab

# vi /etc/fstab

add this line

server_ip:/var/backup /mnt/backup nfs defaults 0 0

exit and run this

# mount -a

check the mount point with

 

#df -h

 

 

WP Twitter Auto Publish Powered By : XYZScripts.com