Hi Experts,
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'
Below is my small testing perl code:
Below is the test run of my perl code:
My questions:
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!!!
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'
Code:
% ifconfig
eth0 Link encap:Ethernet HWaddr 00:19:bb:df:4d:bd
inet addr:[b][COLOR=red]192.168.4.120[/color][/b] 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
collisions:244622 txqueuelen:1000
RX bytes:778624182 (778.6 MB) TX bytes:54320583 (54.3 MB)
Interrupt:17
Below is my small testing perl code:
Code:
#! /usr/bin/perl
use strict;
use warnings;
use Sys::Hostname;
use Socket;
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))[4] );
my $tt = (gethostbyname($host))[4];
my($ip) = inet_ntoa($tt);
print "$0.. \$ip = $ip\n";
exit;
Below is the test run of my perl code:
Code:
% ./getLocalIP.pl
$host = orion
$#tmp = 4
$x = orion.mycompany.com,,2,4,[b][COLOR=red]ˬ[/color][/b])
[b][COLOR=red]PuTTY[/color][/b]./getLocalIP.pl.. [b]$ip = 192.168.5.41[/b]
% [b][COLOR=red]PuTTY[/color][/b]
My questions:
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!!!