VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: Changing IP on the fly?  (Read 1125 times)

Windozer

  • Vectorite
  • ***
  • Posts: 386
  • Have Vector Linux, Will Travel.
Changing IP on the fly?
« on: January 18, 2009, 09:20:21 am »

OK, I'm stumped... this has to be easy...

1. Need to change at will from a DHCP assigned IP address to a fixed IP - and vice versa (Without having to reboot and without using VASM, if possible.)

Can I do this from a CLI?

Is it some flavor of ifconfig or eth(n) ?

2. Similarly, this machine is powered up at the same time as its DSL modem/switch/DHCP server. The machine screams so fast with VL  8) that it will actually boot to GUI level before the DSL modem has synced and made an IP address available... that leads to the problem of having no IP address!
Tried eth0 down.. eth0 up but that had some side effects that I don't understand yet.

And, as always, your help is much appreciated!

cheers,
- Howard in FL
~~~~~~~~~
Logged
483,617th Registered Linux Snoozer

bigpaws

  • Vectorian
  • ****
  • Posts: 1869
Re: Changing IP on the fly?
« Reply #1 on: January 18, 2009, 11:16:15 am »

It depends on what you want.

If it is just that the DSL modem is slow then you can
simply wait to start the machine. You can also just assign an ip fulltime.

Using netconfig vs VASM is not much different in speed.

You can write a bash script to handle it all as well since it appears you know what you want
something like this:

ifconfig down
dhcpcd -k &&
ifconfig eth0 up &&
dhcpcd eth0

Then make the file executable chmod +x filename

Then just call it as root ./filename

To assign the address would be another bash script:

ifconfig eth0 down
dhcpcd -k
ifconfig eth0 192.168.1.1 netmask 255.255.255.0
route add default gw 192.168.1.2 (NOTE: this is the DSL modem address)

Then make it executeable chmod +x filename

Then when you want a statis ip you can do this ./filename

HTH

Bigpaws

Logged

Windozer

  • Vectorite
  • ***
  • Posts: 386
  • Have Vector Linux, Will Travel.
Re: Changing IP on the fly?
« Reply #2 on: January 18, 2009, 04:34:05 pm »

Thanks Bigpaws

is there a way to get ipconfig to /release the DHCP and then have it (re)assign (/renew) a new one?

I know how to do this in windows, but...
« Last Edit: January 18, 2009, 05:07:15 pm by WinDoze »
Logged
483,617th Registered Linux Snoozer

bigpaws

  • Vectorian
  • ****
  • Posts: 1869
Re: Changing IP on the fly?
« Reply #3 on: January 18, 2009, 06:21:19 pm »

dhcpcd -k

That kills dhcp and then dhcpcd eth0 call a
dhcp server for an ip.

Bigpaws
Logged