This site is now 100% read-only, and retired.

Question: How to move Debian network from static IP to DHCP

Posted by rmcgowan on Thu 11 Aug 2005 at 04:23

I'm using Woody currently, connected to a DSL modem/router that allowed me to set up systems eitehr with DHCP or static IP addresses. Since this was a home networking setup, it was easier to go static.

I'm converting to cable modem to broadband router, where the router appears to only work with DHCP (appears, because, for now, I can't access it to see what it does internally and the docs don't say).

The hardware on the intranet side is all set up. I'm waiting for the cable modem install, so all I'm expecting at this point is to see the router and be able to connect to it.

So now I need to change how eth0 is set up. Based on what I know, I thought it was enough to change /etc/network/interfaces so the entry for eth0 was dhcp rather than static and comment out the static related lines. I did this and ran:

ifconfig eth0 down; ifconfig eth0 up; ifconfig eth0

Though marked up, the interface had no IP address. I then tried rebooting the system and re-ran the above. Still no IP address.

What am I missing? Are there other steps I need to do, or am I misunderstanding how this works (always possible;)?

Bob

 

 


Re: Question: How to move Debian network from static IP to DHCP
Posted by Steve (82.41.xx.xx) on Thu 11 Aug 2005 at 03:43
[ View Weblogs ]

It sounds like you've done the right thing. The only obvious comment is that you must have a DHCP client installed.

If you don't have one then you'll not be able to request/receive an address properly. So before you make the change from static to dhcp make sure you run:

apt-get install dhcp-client

Or

apt-get install pump

Either of those should do - personally I prefer to use pump. Once you have it installed you should be able to make the change successfully.

(You can usually force an assignment with the client too, eg "pump -i eth0").

Steve
-- Steve.org.uk

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by grimoire (82.69.xx.xx) on Thu 11 Aug 2005 at 11:59
As mentioned below, the trouble is that the original poster is using ifconfig instead of ifup and ifdown. ifconfig sets the state of the device within the kernel; ifup and ifdown are the ones that read /etc/network/interfaces.

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by LennyCZ (212.4.xx.xx) on Fri 20 Nov 2009 at 12:47
Thanks a lot, I have been struggling with network interfaces on Linux too long without knowing this! :-D

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by Anonymous (66.245.xx.xx) on Thu 11 Aug 2005 at 04:13
have you tried "man 5 interfaces" ?

just add (assuming its eth0):
auto eth0
iface eth0 inet dhcp

then /etc/init.d/netowrking restart

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by Steve (82.41.xx.xx) on Thu 11 Aug 2005 at 04:15
[ View Weblogs ]

It sounds to me exactly like that has been tried; but it didn't work.

I'd suspect the lack of dhcp-client more than anything else..

Steve
-- Steve.org.uk

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by Anonymous (193.195.xx.xx) on Thu 11 Aug 2005 at 07:40
Isn't dhcp-client installed by default on woody though?

I'm pretty sure it is, but can't work my way round the Debian websites enough to find out...

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by Steve (82.41.xx.xx) on Thu 11 Aug 2005 at 08:16
[ View Weblogs ]

I'm pretty sure it was, but I know I usually remove any DHCP software on machines I use when they have static IP addresses.

That is just because I tend to remove non-essential packages upon my systems, even compilers if I don't need them.

When you have less software installed you're less at risk of compromise; and you can keep track of the system better.

Steve
-- Steve.org.uk

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by thomasking (68.92.xx.xx) on Fri 9 Sep 2005 at 02:02
How about how to add a additonal static IP to a DHCP interface? Say the computer looses its leases a lot, but you need to have a static IP to connect to it with, and DYN-DNS is not an option.

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by thomasking (68.92.xx.xx) on Fri 9 Sep 2005 at 02:07
nevermind. I found the answer here:

Making services easy to migrate: Virtual Addresses

(by Steve, of course)

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by Anonymous (62.101.xx.xx) on Thu 11 Aug 2005 at 06:30
You should not use ifconfig, but ifup/ifdown.
ifdown eth0
ifup eth0
After a reboot, everything should be configured as in /etc/network/interfaces without running any commands, so there may be another error.

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by bsod (204.50.xx.xx) on Thu 11 Aug 2005 at 09:45
Maybe you have iptables blocking DHCP request ? If so, try this :
iptables -A INPUT -i eth0 -p udp --sport 67:68 --dport 67:68 -m mac --mac-source 00:0X:XX:XX:XX:XX -j ACCEPT
I specified my modem MAC adress, but you don't really need that. I have everything open in "-A OUTPUT", so I only have a rule for "INPUT".

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by rmcgowan (143.127.xx.xx) on Thu 11 Aug 2005 at 15:39
Thanks, all, for your comments. My responses, in no particular order.

My networking experience with Linux is minimal, so I was aware of ifup and ifdown but did not connect on their purpose. My prior experience with ifconfig was to change stuff on the fly and I just 'naturally' went with what I remembered. So my initial interfaces file change clearly had no impact when I did the ifconfig.

However, I did do a reboot, which should have worked but didn't. So, the base problem is probably the missing DHCP client package as mentioned by Steve in the first response. I can't check until later, however, as the machine is at home and I'm at work.

Thanks for all the help and suggestions, it will all help me improve my understanding of how this stuff works.

Bob

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by Anonymous (70.177.xx.xx) on Thu 11 Aug 2005 at 18:21
Moot point I suppose but the new(?) router would most likely be perfectly happy with static addresses. You should be able to 'talk' to the router even though the cable modem isn't connected yet; but do power it up first. ;)

Neither 'static' nor 'dhcp' has any real advantage over the other, static addresses are not more secure for wireless, as you may have read or heard, and dhcp can at times be troublesome.

I used to have problems with dhcp on 2.x Debian versions so I got used to connecting manually with a script at startup:

#!/usr/bin/sh
ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up #computer
route add -net 192.168.1.0 netmask 255.255.255.0 eth0 #network
route add default gw 192.168.1.1 eth0 #router/gateway

It worked just fine for years.

robin


[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by Anonymous (193.237.xx.xx) on Thu 11 Aug 2005 at 20:28
"but the new(?) router would most likely be perfectly happy with static addresses"

Yes, and is precisely what I plan to do.

My home network is on a randomly chosen class /24 subnet of the RFC1918 10.x.x.x./8 network (the other two allocations in RFC1918 were intended for devices that can't handle variable length subnet masks 172.16 192.168, since everything handles them these days they are effectively obselete).

My Debian desktop, is also the DHCP server, and a DNS server, so it has a static IP address. And I will drop the new router in with the same IP address as the old router as I switch from ISDN to ADSL, continuing to use NAT to hide the RFC1918 addresses. So I won't have to change any static or already allocated dynamic IP addresses locally. I will lose any active TCP connections, but I can live with that if it means getting broadband ;)

And should my home network be absorbed into some huge corporate Intranet I'd have to be very unlucky for my /24 to have already been allocated.

Isn't that what home networks are for? Massively over engineered, and adhering as closely as you know to best industry practice. So when you come home from a day at the Office with all the nasty shortcuts, and inherited chaos, it all seems sane, orderly, and just works.

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by peterhoeg (193.163.xx.xx) on Fri 12 Aug 2005 at 16:21

Amen brother!

Real men (well, me at least) run a class A network at home, user accounts in LDAP, passwords using kerberos5 and soon virtual xen hosts for services, cfengine for configuration distribution and all configuration in a subversion repository.

Total network size: 5 devices

Total amount of users: 2

Check list:

  • Forever to set up, check
  • Countless hours (typically late at night) in front of the monitor - cursing, check
  • Massively overengineered, check

But hey - we still do it... Because we can!

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by rbochan (24.92.xx.xx) on Fri 12 Aug 2005 at 13:37
[ View Weblogs ]
etherconf

Aside from doing it manually like others have posted, it's simple, and lets debconf keep track of your network info.

...Rob
The American Dream isn't an SUV and a house in the suburbs; it's Don't Tread On Me.

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by rmcgowan (143.127.xx.xx) on Fri 12 Aug 2005 at 16:24
I figured there had to be an 'automated' setup, somewhere, but I never thought to look for '*ether*' (curses ;)

FYI, regarding woody and dhcp-client, it is installed by default, but since I chose static setup originally, it's not part of any rc script, that I can find.

And, accessing the router and using static IP does work, in any case, as I found out. It happens that one of the major problems I was having was a malfunctioning router, which I've replaced. Things are looking up.

Now, if I could just figure out why the DNS lookup isn't working...

Bob

[ Parent ]

Re: Question: How to move Debian network from static IP to DHCP
Posted by rmcgowan (67.161.xx.xx) on Sat 13 Aug 2005 at 06:11
So, of course, the issue really wasn't DNS...sigh.

I had the default gateway misconfigured, it has to be the IP of the router and I'd set it to the modem address. Silly me!

Thanks for all the input and help, I'm back up and running and soon to upgrade to sarge. Now that I can do it over the network.

Bob

[ Parent ]