I need your help in configuring my ubuntu desktop at work.
My company just moved to a new location. And my ubuntu box behaves strangely after the move.
My ubuntu is configured to get a dynamic IP. Before the move, it's dynamic IP was 192.168.5.41
. I had kept it's running for weeks, so the IP stayed the same before the move.
After the move, I restarted my ubuntu and the IP changed to 192.168.4.120
, which is fine. However, the perl program I wrote before still returns the OLD IP - 192.168.5.41
I have several ubuntu machines and they are all configured the same (I did not set the ip/hostname in /etc/hosts for all the machines I have
). What puzzles me is that only one has this problem!!
Below is the output of 'ifconfig'
eth0 Link encap:Ethernet HWaddr 00:19:bb:df:4d:bd
inet addr:192.168.4.120 Bcast:192.168.255.255 Mask:255.255.0.0
inet6 addr: fe80::219:bbff:fedf:4dbd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1587653 errors:11 dropped:0 overruns:0 frame:31
TX packets:337638 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:778624182 (778.6 MB) TX bytes:54320583 (54.3 MB)
Below is my small testing perl code:
my $host = hostname;
print "\$host = $host\n";
my @tmp = gethostbyname($host);
my $x = join ',', @tmp;
print "\$#tmp = $#tmp\n";
print "\$x = $x\n";
#my($ip) = inet_ntoa( (gethostbyname($host)) );
my $tt = (gethostbyname($host));
my($ip) = inet_ntoa($tt);
print "$0.. \$ip = $ip\n";
Below is the test run of my perl code:
$host = orion
$#tmp = 4
$x = orion.mycompany.com,,2,4,À¨)
PuTTY./getLocalIP.pl.. $ip = 192.168.5.41
1) Again, why does it return the old ip? This cannot be a random thing!!
2) why does gethostbyname() return some kind of trash (in red)?
3) why do I see 'PuTTY' here? I am using Putty on a win 7 machine to connect to the ubuntu in question.
Many thanks in advance for the help!!!