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
[ Send Message | View Steve's Scratchpad | 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 | Reply to this comment ]
[ Parent | Reply to this comment ]
just add (assuming its eth0):
auto eth0
iface eth0 inet dhcp
then /etc/init.d/netowrking restart
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | 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 | Reply to this comment ]
I'm pretty sure it is, but can't work my way round the Debian websites enough to find out...
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | 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 | Reply to this comment ]
[ Parent | Reply to this comment ]
Making services easy to migrate: Virtual Addresses
(by Steve, of course)
[ Parent | Reply to this comment ]
ifdown eth0 ifup eth0After a reboot, everything should be configured as in /etc/network/interfaces without running any commands, so there may be another error.
[ Parent | Reply to this comment ]
iptables -A INPUT -i eth0 -p udp --sport 67:68 --dport 67:68 -m mac --mac-source 00:0X:XX:XX:XX:XX -j ACCEPTI 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 | Reply to this comment ]
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 | Reply to this comment ]
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 | Reply to this comment ]
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 | Reply to this comment ]
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 | Reply to this comment ]
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 | Reply to this comment ]
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 | Reply to this comment ]
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 | Reply to this comment ]