LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-26-2007, 03:31 PM   #1
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slackware, debian, ubuntu
Posts: 666

Rep: Reputation: 39
is there an "ifconfig dhcp" command ?


hello everyone,
i am running linux(debian, but doesn't really matter) on an arm processor.
i need to be able from an application on that board to change the ip.
now the call for a static ip is easy
ill just to a system() call as:

system("ifconfig eth0:1 192.168.1.156");

but if i want, at runtime (ie without needing to write code that tweaks /etc/network/interfaces)
to change from static to dynamic ip. how will i do that?

basically, if there is something like

system("ifconfig eth0:1 dchpd start"); //or smth like that...

that would be awesome..
but is there anyway i can use ifconfig to instruct the system to take addresses from the dhcp?
thank you for your help
nass
you get
 
Old 03-26-2007, 03:34 PM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
What about running "dhcpcd eth0" or "dhclient eth0" (I'm not sure which Debian provides)?
 
Old 03-26-2007, 03:57 PM   #3
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 342

Rep: Reputation: 38
Try dhclient, that is the daemon process responsible for configuring your interface(s) by using the dynamic host configuration protocol, or the bootp protocol.

man dhclient will tell you all about it, or if you are using kde, run command: #dhclient

Best regards

Andy
 
Old 03-26-2007, 05:31 PM   #4
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved to Linux-General as this isn't a Slackware problem.
 
Old 03-27-2007, 07:00 PM   #5
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slackware, debian, ubuntu
Posts: 666

Original Poster
Rep: Reputation: 39
yes, i see.
so if i am to switch from static to dynamic (and provided i have a static in /etc/network/interfaces) during a startup script,

i should NOT run:
ifconfig eth0:1 192.18.0.2
route del default gw 192.168.0.1
route add default gw 192.168.0.1

instead, i should run

dhclieth eth0:1 #or however else it should be called

right?
nass
 
Old 03-28-2007, 11:56 AM   #6
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 342

Rep: Reputation: 38
Not sure you need to delete routes, unless you configured those statically as well.

The dhclient takes care of configuring IP address, DNS servers, and Gateway, which means that it will add the appropriate route entries too.

Try for yourself from the console:

ifdown eth0
dhclient eth0

And see what happens
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
tying "dhcpcd" into "ifconfig" up and down Riddick Linux - Software 8 09-10-2005 07:14 PM
Lost DHCP Lease when putting computer in "Standby" mode for a "long" time pnellesen Linux - Networking 1 01-06-2005 11:44 PM
ifconfig "command not found" NNP Linux - Networking 2 11-17-2004 12:55 PM
problem using ifup and ifconfig "command not found" sicgixxer Linux - Networking 2 11-11-2004 09:39 PM
ifconfig "command not found"...? GDDYUP Linux - Networking 1 09-30-2001 01:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration