LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How Do I Switch From Static IP To DHCP (https://www.linuxquestions.org/questions/linux-networking-3/how-do-i-switch-from-static-ip-to-dhcp-336191/)

Psibur 06-22-2005 04:08 PM

How Do I Switch From Static IP To DHCP
 
Running Slackware (10.1 if that makes much diff). I've always had a static IP for my Slack boxes but I need to switch them to use DHCP. What do I have to do to switch from static IP to DHCP (and back)?

I have a feeling I have to start in /etc/rc.d but not quite sure. I also think I cought something that dhcpcd is my friend here, but haven't been formally introduced. :scratch:

Much thanks in advance...

Bebo 06-22-2005 05:05 PM

You're right in that the solution lies in /etc/rc.d :) However, you don't have to fiddle around with dhcpcd directly. dhcpcd will be called from /etc/rc.d/rc.inet1, which is configured in /etc/rc.d/rc.inet1.conf.

You can configure your IP address settings directly in etc/rc.d/rc.inet1.conf. If you do this, you have to change the appropriate instance of USE_DHCP[n]="" to USE_DHCP[n]="yes", where n is the number corresponding to the NIC which connects to the DHCP server. Meaning, if the output of ifconfig says something like
Code:

eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX 
          inet addr:XXX.XXX.XXX.XXX  Bcast:XXX.XXX.XXX.XXX  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:335384 errors:0 dropped:0 overruns:0 frame:0
          TX packets:263564 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:393359444 (375.1 Mb)  TX bytes:26390656 (25.1 Mb)
          Interrupt:18 Base address:0xe800

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:16788 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16788 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:21083024 (20.1 Mb)  TX bytes:21083024 (20.1 Mb)

then you can see that n is 0 ("eth0").

However, I must say that I find it easier to use the command netconfig, which lets you set your IP address(es) up really easily. I'm sure you remember this from when you installed Slack.

HTH

Bruce Hill 06-22-2005 05:11 PM

Welcome to LQ!

You could edit /etc/rc.d/rc.inet1.conf by hand. Or you could issue "netconfig" as root.

The Revised Slackware Book Project is a good reference. In it the netconfig program is
mentioned, but it's still suggested that we review the configuration ourselves and learn
how this works. I think it's easy, and nice to understand what's happening behind that
user interface.

Psibur 06-23-2005 09:40 AM

Much thanks for all the info guys. I'll definatly pass it on. :)

Chinaman: You're right, the book is quite good. Reading it fervently. :study:


All times are GMT -5. The time now is 09:58 PM.