Networking Forums

Networking Forums > Computer Networking > Linux Networking > How do I change IP address dynamically?

Reply
Thread Tools Display Modes

How do I change IP address dynamically?

 
 
linuxlover992000@yahoo.com
Guest
Posts: n/a

 
      06-20-2006, 01:55 PM
I have a Fedora Core 4 server which usually is assigned the IP address
of 192.168.0.160.

I would like to be able to changed it *temporarily* (i.e. for a special
session until I restore it manually) to 192.168.0.31.

At the command line, as root, I type:

ifconfig eth0 192.168.0.31

The IP address indeed changes as expected, but for some strange reason
it no longer has connection to the internet via the router
(192.168.0.1). When I try to ping some known Internet host, it says:

"connect: Network is unreachable"

(it disn't say so before executing the "ifconfig eth0" command).

Now the interesting thing is that if I type "ifconfig eth0
192.168.0.160", to (supposedly) restore it to its original state, is
remains in the problematic state of "connect: Network is unreachable"
(until I reboot).

It appears that there is something else that needs to be re-configured
along with the IP address (which is on the same subnet), in order for
this "innocent change" to work. But what is it?

Do I really have to shutdown the interface entirely ("ifconfig eth0
down") before changing the IP address?

I am interested in changing the IP address *without rebooting* the
server.

Thanks!
Lynn

 
Reply With Quote
 
 
 
 
slackware guy
Guest
Posts: n/a

 
      06-20-2006, 02:35 PM

(E-Mail Removed) wrote:
> I have a Fedora Core 4 server which usually is assigned the IP address
> of 192.168.0.160.
>
> I would like to be able to changed it *temporarily* (i.e. for a special
> session until I restore it manually) to 192.168.0.31.
>
> At the command line, as root, I type:
>
> ifconfig eth0 192.168.0.31
>
> The IP address indeed changes as expected, but for some strange reason
> it no longer has connection to the internet via the router
> (192.168.0.1). When I try to ping some known Internet host, it says:
>
> "connect: Network is unreachable"
>
> (it disn't say so before executing the "ifconfig eth0" command).
>
> Now the interesting thing is that if I type "ifconfig eth0
> 192.168.0.160", to (supposedly) restore it to its original state, is
> remains in the problematic state of "connect: Network is unreachable"
> (until I reboot).
>
> It appears that there is something else that needs to be re-configured
> along with the IP address (which is on the same subnet), in order for
> this "innocent change" to work. But what is it?
>
> Do I really have to shutdown the interface entirely ("ifconfig eth0
> down") before changing the IP address?
>
> I am interested in changing the IP address *without rebooting* the
> server.
>
> Thanks!
> Lynn


Red Hat EL (and I assume fedora) has scripts for handling the interface
confguration under
/etc/sysconfig/network-scripts.

The normal practice is to down the interface before making
configuration changes. I haven't
tried reconfiguring an active interface myself but I would prefer (if
not using the scripts) 'ifconfig eth0 down' then make the change then
'ifconfig eth0 up'.

Dean

 
Reply With Quote
 
linuxlover992000@yahoo.com
Guest
Posts: n/a

 
      06-20-2006, 02:55 PM
slackware guy wrote:
>
> Red Hat EL (and I assume fedora) has scripts for handling the interface
> confguration under
> /etc/sysconfig/network-scripts.
>
> The normal practice is to down the interface before making
> configuration changes. I haven't
> tried reconfiguring an active interface myself but I would prefer (if
> not using the scripts) 'ifconfig eth0 down' then make the change then
> 'ifconfig eth0 up'.
>


Dean, thanks for your quick reply. What I forgot to mention was that I
am doing this remotely (i.e. via telnet), so the operation has to be
"atomic". That is, by the end of the execution of the command, I have
to be able to access the server again, albeit via a new telnet session
(to the new IP address).

I actually tried just that. I typed in one line:

~> ifconfig eth0 down; ifconfig eth0 192.168.0.31; ifconfig eth0 up

and indeed I was able to telnet again - but the problem I described in
my original posting still persists!

I knew about about RedHat's network-scrips (some of these files are not
really scripts, just plain configuration data such as ifcfg-eth0), but
I thought these are more appropriate for permanent changes.

Any idea how I can *dynamically* (i.e. without needing to reboot and
without needing to use an interactive tool) change the IP address
(within the same subnet - everything else remains the same, including
gateway and DNS) in Fedora?

Please notice that the problem exists only in regard to connecting to
the Internet. Connection within LAN remains OK in any of the ways I
described so far.

In the meanwhile I will continue to explore...

Thanks!
Lynn

 
Reply With Quote
 
Philipp Pagel
Guest
Posts: n/a

 
      06-20-2006, 02:56 PM
(E-Mail Removed) wrote:
> At the command line, as root, I type:


> ifconfig eth0 192.168.0.31


> The IP address indeed changes as expected, but for some strange reason
> it no longer has connection to the internet via the router
> (192.168.0.1). When I try to ping some known Internet host, it says:


> "connect: Network is unreachable"


Your routing is messed up. Have a look at the output of

route -n

before and after your IP change.

cu
Philipp

--
Dr. Philipp Pagel Tel. +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186
Technical University of Munich
http://mips.gsf.de/staff/pagel
 
Reply With Quote
 
Paul Black
Guest
Posts: n/a

 
      06-20-2006, 03:12 PM
(E-Mail Removed) wrote:
> It appears that there is something else that needs to be re-configured
> along with the IP address (which is on the same subnet), in order for
> this "innocent change" to work. But what is it?


The default route.


--
Paul
 
Reply With Quote
 
kevin@mtel.co.uk
Guest
Posts: n/a

 
      06-20-2006, 04:03 PM
having trawled the ifconfig man page there is an option to add / delete
an ip address
ifconfig <if> add <ipaddress>
ifconfig <if> del <ipaddress>

i've tried this and it appears pretty much instant. I'm not saying it
will fix your problem, but it seems to be accessible instantly, without
screwing remote access, because i did it via xterm.

HTH

kevin

 
Reply With Quote
 
slackware guy
Guest
Posts: n/a

 
      06-20-2006, 04:04 PM

Paul Black wrote:
> (E-Mail Removed) wrote:
> > It appears that there is something else that needs to be re-configured
> > along with the IP address (which is on the same subnet), in order for
> > this "innocent change" to work. But what is it?

>
> The default route.
>
>
> --
> Paul


One question I would ask at this point is what is your netmask ? If it
is the old class C (255.255.255.0 or /24) then that change should not
impact your ability to access your default gateway.

For example, if your netmask is /25 or greater (255.255.255.128) then
going from .160 to .31 will change your default gateway and you would
change your default using the 'route' command.

Of course you would have to speak with your metwork engineers to get
the new routing information.

Dean

 
Reply With Quote
 
slackware guy
Guest
Posts: n/a

 
      06-20-2006, 04:08 PM

slackware guy wrote:
> Paul Black wrote:
> > (E-Mail Removed) wrote:
> > > It appears that there is something else that needs to be re-configured
> > > along with the IP address (which is on the same subnet), in order for
> > > this "innocent change" to work. But what is it?

> >
> > The default route.
> >
> >
> > --
> > Paul

>
> One question I would ask at this point is what is your netmask ? If it
> is the old class C (255.255.255.0 or /24) then that change should not
> impact your ability to access your default gateway.
>
> For example, if your netmask is /25 or greater (255.255.255.128) then
> going from .160 to .31 will change your default gateway and you would
> change your default using the 'route' command.
>
> Of course you would have to speak with your metwork engineers to get
> the new routing information.
>
> Dean


Whoops! you said it was on the same subnet. The other posters have
pointed you in the right direction. The network routing is probably
askew

 
Reply With Quote
 
Dale Dellutri
Guest
Posts: n/a

 
      06-20-2006, 04:15 PM
On 20 Jun 2006 07:55:36 -0700, (E-Mail Removed) wrote:
> slackware guy wrote:
> >
> > Red Hat EL (and I assume fedora) has scripts for handling the interface
> > confguration under
> > /etc/sysconfig/network-scripts.
> >
> > The normal practice is to down the interface before making
> > configuration changes. I haven't
> > tried reconfiguring an active interface myself but I would prefer (if
> > not using the scripts) 'ifconfig eth0 down' then make the change then
> > 'ifconfig eth0 up'.
> >


> Dean, thanks for your quick reply. What I forgot to mention was that I
> am doing this remotely (i.e. via telnet), so the operation has to be
> "atomic". That is, by the end of the execution of the command, I have
> to be able to access the server again, albeit via a new telnet session
> (to the new IP address).


> I actually tried just that. I typed in one line:


> ~> ifconfig eth0 down; ifconfig eth0 192.168.0.31; ifconfig eth0 up


> and indeed I was able to telnet again - but the problem I described in
> my original posting still persists!


> I knew about about RedHat's network-scrips (some of these files are not
> really scripts, just plain configuration data such as ifcfg-eth0), but
> I thought these are more appropriate for permanent changes.


> Any idea how I can *dynamically* (i.e. without needing to reboot and
> without needing to use an interactive tool) change the IP address
> (within the same subnet - everything else remains the same, including
> gateway and DNS) in Fedora?


> Please notice that the problem exists only in regard to connecting to
> the Internet. Connection within LAN remains OK in any of the ways I
> described so far.
>...


Other posters have suggested that the default route must be re-done,
but I don't think that's true. However, doing
route -n
before and after will tell.

Perhaps the problem is not in the system that you're changing.
Perhaps it's in the gateway itself.

Can you log into the gateway (I assume it's a router) and look at its
arp cache before and after the change? Can you traceroute or
tracepath from the gateway to changing system before and after (and
from the changing system to the gateway)?

--
Dale Dellutri <(E-Mail Removed)> (lose the Q's)
 
Reply With Quote
 
slackware guy
Guest
Posts: n/a

 
      06-20-2006, 04:22 PM

Dale Dellutri wrote:
> On 20 Jun 2006 07:55:36 -0700, (E-Mail Removed) wrote:
> > slackware guy wrote:
> > >
> > > Red Hat EL (and I assume fedora) has scripts for handling the interface
> > > confguration under
> > > /etc/sysconfig/network-scripts.
> > >
> > > The normal practice is to down the interface before making
> > > configuration changes. I haven't
> > > tried reconfiguring an active interface myself but I would prefer (if
> > > not using the scripts) 'ifconfig eth0 down' then make the change then
> > > 'ifconfig eth0 up'.
> > >

>
> > Dean, thanks for your quick reply. What I forgot to mention was that I
> > am doing this remotely (i.e. via telnet), so the operation has to be
> > "atomic". That is, by the end of the execution of the command, I have
> > to be able to access the server again, albeit via a new telnet session
> > (to the new IP address).

>
> > I actually tried just that. I typed in one line:

>
> > ~> ifconfig eth0 down; ifconfig eth0 192.168.0.31; ifconfig eth0 up

>
> > and indeed I was able to telnet again - but the problem I described in
> > my original posting still persists!

>
> > I knew about about RedHat's network-scrips (some of these files are not
> > really scripts, just plain configuration data such as ifcfg-eth0), but
> > I thought these are more appropriate for permanent changes.

>
> > Any idea how I can *dynamically* (i.e. without needing to reboot and
> > without needing to use an interactive tool) change the IP address
> > (within the same subnet - everything else remains the same, including
> > gateway and DNS) in Fedora?

>
> > Please notice that the problem exists only in regard to connecting to
> > the Internet. Connection within LAN remains OK in any of the ways I
> > described so far.
> >...

>
> Other posters have suggested that the default route must be re-done,
> but I don't think that's true. However, doing
> route -n
> before and after will tell.
>
> Perhaps the problem is not in the system that you're changing.
> Perhaps it's in the gateway itself.
>
> Can you log into the gateway (I assume it's a router) and look at its
> arp cache before and after the change? Can you traceroute or
> tracepath from the gateway to changing system before and after (and
> from the changing system to the gateway)?
>
> --
> Dale Dellutri <(E-Mail Removed)> (lose the Q's)


Quick question, what is the difference between route -n and netstat
-rn? The output looks the same on my box. Is there a difference?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically Change SSID fernandez.dan@gmail.com Wireless Internet 1 06-20-2008 01:04 AM
TCP/IP Address Change Mark Windows Networking 1 06-24-2006 04:18 PM
Change IP Address Bones Wireless Networks 5 01-29-2006 08:18 PM
change MAC address can change IP address of a machine? apngss@yahoo.com Linux Networking 7 01-05-2006 11:09 PM
change MAC address can change IP address of a machine? apngss@yahoo.com Wireless Internet 7 01-05-2006 11:09 PM



1 2 3 4 5 6 7 8 9 10 11