Showing posts with label etc. Show all posts
Showing posts with label etc. Show all posts

Saturday, November 9, 2013

How to access vmware hosted in local system via another computer in network

My local setup is CentOS installed(hosted in vmware) in Ubuntu machine

These are the steps i.e. needed to perform in ubuntu machine

1)Enable IP forwarding

#vi /etc/sysctl.conf

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

2)Forward the port to the virtual machine (I needed to forward my ubuntu machine 8081 port to 80 port of vmware machine)
#iptables -A INPUT -p tcp --dport 8081 -j ACCEPT

3)Changing in vmware nat.conf file to accept forwarded traffic

#vi /etc/vmware/vmnet8/nat/nat.conf

[incomingtcp]

# Use these with care - anyone can enter into your VM through these...
# The format and example are as follows:
#<external port number> = <VM's IP address>:<VM's port number>
8081 = 172.16.3.128:80

4)stop and start ufw (May be not necessary)

5)After shutting down vmware.Restart vmware via

#/etc/init.d/vmware restart

After performing all these steps try to access <this computer ip>:8081 via another network and it is responded by vmware hosted machine.
(For testing purpose you can check the traffic on both machine

i)In ubuntu machine(i.e. accepting 8081 port)
#tcpdump -i any "port 8081"

ii)Vmware hosted machine that is accepting 80 port
#tcpdump -i any "port 80"
)

Friday, April 29, 2011

Handling uninitialized value in perl

In perl* when you find this error "Use of uninitialized value in concatenation (.) or string at".It means you try to use uninitialized(empty valued) variable.


For example you try to print

my $name;

print "Hi $name ";


Then it will print the message "Use of uninitialized value in concatenation ......."


To overcome from this message you need to check either this variable is initialized or not.For this we used "defined"

If we use 

defined EXPR -->Returns true if expr has some value otherwise false

then our line

print "Hi $name ";


now modified to


if(defined $name)

{

print "Hi $name ";

}

else

{

print "Hi ";

}


*I not programmed in perl.This is what i learn in the time of troubleshooting the old scripts.