Easiest way to switch from/to DHCP?

Posted by: loren

Easiest way to switch from/to DHCP? - 01/02/2002 15:55

Okay, the scenario:
I use my empeg at home and at work. At home, it has a static assigned internal IP. At work, it has to use DHCP.
Problem:
I have to hook up a USB or serial cable every time i wanna switch it from one to the other, since if i'm at work, and the last place i used it was at home, i can't access it via ethernet because it's still on it's at home assigned IP and the oppisite for work. Got it?

I KNOW i could just change it before i leave home to DHCP or visa versa, and I KNOW i could just use USB at home or at work. The former will never happen as i'm running out the door in the morning, and the later won't work because i want it to be network accessible in both places.

SO, is there some way to switch from Assigned IP to DHCP on the player, on the fly? I'm fairly certain there isn't, and i know this has come up before. Could this be written into HiJack?! That would rock. Any other ideas that i'm too stupid to see?

Thanks.

Posted by: tfabris

Re: Easiest way to switch from/to DHCP? - 01/02/2002 16:23

I used to be in this situation, and my workaround was to add another fixed IP address to the box as described in the FAQ here.

What OS are you on at work?
Posted by: loren

Re: Easiest way to switch from/to DHCP? - 01/02/2002 16:29

Win2k... which is why i posted the question... should have mentioned i read that in the FAQ... no workie. =] I'd want others at work to have access to it without having to add another protocol to their machines. I'm on Win2k at home too.

This seems like a good candidate for a Hijack menu... Mark??? (does he read this forum?)
Posted by: tfabris

Re: Easiest way to switch from/to DHCP? - 01/02/2002 16:34

How I got it working under Win2K:

Someone sent me a link to a command-line utility to add a fixed IP address to the network properties. The only problem is that it's a command-line utility that needs to stay running while you're connected to the player. So you need to have a minimized DOS window as long as this IP has been added.

However, if you make an icon to launch it whenever you need it, or you put it in your startup group, or perhaps even turn it into a service with SRVANY or FireDaemon, then it could be almost transparent.

If you want it, I've got it...
Posted by: loren

Re: Easiest way to switch from/to DHCP? - 01/02/2002 16:37

Hrm... sounds cool.. but the place i want it to be available to everyone on the network is here at work... and i don't want to have to have everyone run that utility just to get to the player. Send it my way though... I can at least use it on my own machine. Thanks!
Posted by: tfabris

Re: Easiest way to switch from/to DHCP? - 01/02/2002 16:38

Heh, I just looked at the doohickey I used to make the connection happen. It's rather tricky, and it requires a bit of customization. It's not plug-and-play. In fact, it's a rather rube-goldberg solution, which is why I didn't put it in the FAQ.

But it did work. If you want it, contact me personally and I'll work with you on getting it set up.
Posted by: wfaulk

Re: Easiest way to switch from/to DHCP? - 01/02/2002 16:40

There's bound to be a freeware DHCP server for Windows out there somewhere. Get it and have it serve that same static IP address to the empeg every time you hook it up.

Edit: Perhaps this one?
Posted by: tfabris

Re: Easiest way to switch from/to DHCP? - 01/02/2002 16:45

Quick question, to anyone reading this thread.

Is there an easy way to have the Windows NT command prompt spit back JUST the computer's current IP address?

For instance, I know I can use a variable called %windir% to insert the Windows directory into a batch file without having to do any processing on the output. Is there a corresponding system variable for the IP address?

I know I can use IPCONFIG and it'll spit out a formatted table of a bunch of information, but I would have to parse through that table of data in order to retrieve just the IP address for use in a batch file.

In fact, that's what my rube-goldberg solution did, it dug the computer's current IP address out of a spit-out text file and used a third-party program to do the parsing work. Then I was able to feed the computer's current IP to the IPADD.EXE program (it was one of the program's necessary parameters).

The reason I don't want to just give that straight to Loren is that the "digger" program I used is licensed and I can't give it away.
Posted by: bonzi

Re: Easiest way to switch from/to DHCP? - 01/02/2002 17:49

Hm, a very inelegant solution: have two versions of config.ini (differing in networking details), development SW, 'Quit' option on player, and a piece of script in /etc/profile that will ask (using picker or something equivalent) which version to copy over the current file.
Posted by: tfabris

Re: Easiest way to switch from/to DHCP? - 01/02/2002 17:52

Interesting. If your only reason for using the Quit menu is to toggle DHCP on and off, that's not inelegant, that's actually quite elegant.

The only ugly part is that you'd have to replace the script each time you upgraded the player.
Posted by: hybrid8

Re: Easiest way to switch from/to DHCP? - 01/02/2002 20:35

You saved me the trouble of posting a similar thread tonight. Actually, I had gotten about half way writing my initial post in the pogramming section when I decided to just put it off for another day.

I'd like an easy toggle or something semi-automated as well. I have a possible advantage, in that I'd like a fixed IP at home, but don't need it to be a specific number (not with my current setup anyway).

For me, a simple solution would be a small app that would find out what the empeg's assigned IP is, and toss it into my HOSTS file along with an alias.

That would give me a "constant" to reference the machine at home.

Anyone want to make that small app? The only negative is that the app would still need to be manually launched - unless it was active on the system all the time (not something I consider ideal). And this avoids having to set up a DHCP server on this machine. (But I'll look at the one linked to see what kind of impact it may have)

Bruno
Posted by: mcomb

Re: Easiest way to switch from/to DHCP? - 01/02/2002 20:53

Can't you just assign a second IP to the empeg? Let it get the first one via DHCP and then do something like...

ifconfig eth0 add 192.168.102.3 192.168.102.254 up

from init or another script? I haven't actually tried this on an empeg, but that would give you two IPs on a normal linux box IIRC. That gives you an eth0 and an eth0:1 so you are technically on both networks at the same time.

-Mike
Posted by: hybrid8

Re: Easiest way to switch from/to DHCP? - 01/02/2002 22:04

That DHCP server you linked to is actually shareware and is 19 Euro plus any charges you might have to add for the developer to negotiate your payment. He really should do a better job of writing up the order text if he wants to collect any money.

Anyway, I'm sleepy and I can't get it to do anything right now. A small error pops up saying port 67 is in use already and that's about it (I'm running 2K). I haven't tried simply ignoring it and entering the empeg's mac into a static assignment yet though. (I'm too sleepy to memorize the mac as it scrolls in the about menu and also too sleepy to think about how to find out what it is using a different method.

Anyway, at some time tomorrow I can provide/accept further details if anyone wants to help out. Getting this to work should do the trick. Looks like this server software also has the ability to run as a service and looks like it may have a small footprint.

Bruno
Posted by: mlord

Re: Easiest way to switch from/to DHCP? - 01/02/2002 22:18

If your at-Work DHCP server is reasonably responsive, then you could cobble up a moderately dumb shell script to do what you want, basically to hang around for say 30 seconds waiting for DHCP to configure eth0, and then to add a static IP if DHCP doesn't do the job by then. This script would run on the empeg.

Of course this is complicated somewhat, in that the tools needed to do the job are not present, not even on a developer image..

Perhaps I'll be forced into fixing it with Hijack the next time I have the unit someplace that lacks DHCP.. This could be a useful feature I suppose, even for me..

-ml
Posted by: loren

Re: Easiest way to switch from/to DHCP? - 01/02/2002 22:21

No ifconfig on the empeg. Good idea though.
Posted by: loren

Re: Easiest way to switch from/to DHCP? - 01/02/2002 22:23



That would rock. It's definitely useful when you go from network to network regularly. Thanks for considering it for Hijack... It'd be much appreciated.
Posted by: mlord

Re: Easiest way to switch from/to DHCP? - 02/02/2002 07:12

How about this for an idea (Hijack):

In config.ini, we add a couple of special "comment" statements, to allow hijack to modify config.ini as it is read by the player. This would use two keywords, @HOME and @WORK, that Hijack will choose between based on a menu selection. Best shown by example:

[Network]
Gateway=10.0.0.1
Netmask=255.0.0.0
IPAddress=10.0.0.26
;@HOME DHCP=0
;@WORK DHCP=1
DHCP=0

The keywords can be used anywhere in config.ini, and Hijack will simply choose one line or the other at run time, and feed that to the player (and to emplode), while preserving the original "commented" keyword lines.

So in the above file, the "DHCP=0" line does not actually exist.. it was inserted by Hijack when the file was read, and will be deleted when the file is written again.

This also would give us the capability of having Hijack "hijack" other config.ini settings in the future, and to do things like automatically enabling "notify=1" to obtain player status on ALL empegs (with "supress_notify=1" as the default in such cases).

Anyway, don't try it yet.. it does not exist. Just probing for input. Whatever we do has to be simple, to keep the code size down (CPU overhead doesn't really matter here, but code size DOES matter).

Cheers

Posted by: Nosferatu

Re: Easiest way to switch from/to DHCP? - 02/02/2002 07:54

Great Idea !!!!


Enjoy the Candle Light ...
Posted by: mlord

Re: Easiest way to switch from/to DHCP? - 02/02/2002 08:13

>Enjoy the Candle Light ...

Yes, we will.. that oughta be fuel enough for a few more revisions of Hijack! Thanks!

-ml
Posted by: tfabris

Re: Easiest way to switch from/to DHCP? - 02/02/2002 08:32

Mark, that's fantastic. Brilliant.

From the looks of it, you could extend this "home/work" behavior farther than just those lines in the config.ini. Not sure what else you could use it for yet, but I'm sure someone else could think of something.
Posted by: tfabris

Re: Easiest way to switch from/to DHCP? - 02/02/2002 08:35

For me, a simple solution would be a small app that would find out what the empeg's assigned IP is, and toss it into my HOSTS file along with an alias.

Now, THIS I like. Great idea.

I would like to see this implemented, totally independent of Mark's immediate solution to Loren's problem. I'm going to start a separate thread under Programming just for this topic.
Posted by: wfaulk

Re: Easiest way to switch from/to DHCP? - 02/02/2002 08:57

Aargh. That's the only free-looking one I could find. I tell you what -- amateur Windows developers are some money-grubbing little bastards.
Posted by: mlord

Re: Easiest way to switch from/to DHCP? - 02/02/2002 10:42

Well, I'm sure folks would also want to use this with Hijack options like this:

[hijack]
;@WORK kftpd_control_port=0 ;; disable ftp access at work
;@WORK khttpd_port=0 ;; disable http access at work

Or even these "future" options:

;@WORK khttpd_files=0 ;; no file access except for streaming
;@WORK khttpd_dirs=0 ;; disable directory indexing
;@WORK khttpd_playlists=0 ;; disable playlist/m3u accesses
;@WORK site_rw=0 ;; disallow SITE/http RW command
;@WORK site_commands=0 ;; disallow all SITE/http commands
;@WORK kftpd_password=n0H4ck3Rz ;; require a password for ftp access

-ml
Posted by: hybrid8

Re: Easiest way to switch from/to DHCP? - 02/02/2002 10:45

Make it so.

Bruno
Posted by: mtempsch

Re: Easiest way to switch from/to DHCP? - 02/02/2002 11:57

Seconded!

Fabulous idea

Posted by: loren

Re: Easiest way to switch from/to DHCP? - 02/02/2002 12:40

*APPLAUSE!!!*
Posted by: pgrzelak

Re: Easiest way to switch from/to DHCP? - 02/02/2002 13:12

Greetings!

THANK YOU! How did you know I wanted password protection on the "site" commands???
Posted by: adavidw

Re: Easiest way to switch from/to DHCP? - 02/02/2002 14:39

Why limit these types of things to just locations? How about having keywords that modify config.ini based on AC or DC power as well? (unless that's already implemented some other way in Hijack that I haven't seen)

-Aaron
Posted by: Terminator

Re: Easiest way to switch from/to DHCP? - 02/02/2002 18:13

Does kftpd already require a password? I would really appreciate it if there was some way to do that. I'm paranoid about running a ftp service on my empeg. :-)

Sean
Posted by: hybrid8

Re: Easiest way to switch from/to DHCP? - 02/02/2002 18:19

You'll need version 168 of hijack. Keep checking the programming section for the latest news.

Bruno
Posted by: mlord

Re: Easiest way to switch from/to DHCP? - 02/02/2002 21:37

kftpd has NEVER required a password.

As of Hijack v168, you can now turn on password checking, by specifying a plain text password in the config.ini file, as in:

[hijack]
kftpd_password=c00ld00d5

Of course, anyone with a web browser can just look at the config.ini file to extract the password, so this is not very secure. To prevent the web-browser side-step, add this line after the password line:

khttpd_files=0

This is much better, but not 100% secure.. it's possible (with a lot of poking around) to bypass this "security", but much easier for somebody would be to just install emplode and mess around using that.

I suppose I ought to add another option to disable Emplode access.. but somebody would probably bugger their player completely if I did that.. requiring a serial download of a non-hijack kernel to regain access. Hmmmm.. that might not be too bad, though..

Cheers

-ml
Posted by: drakino

Re: Easiest way to switch from/to DHCP? - 03/02/2002 10:04

What about just letting the player grab a uPnP address at home? That way you can leave DHCP on at work and home, and should find some sort of workaround for issues in the house.

Question for the empeg guys, does the uPnP code in the empeg try the same IP every time based on an algorithm, or is is mostly random?
Posted by: Fogduck

Re: Similar Situation, Inverse Problem? - 03/02/2002 17:39

(hopefully there are still eyes on this thread)

I am using @Home (well, formerly @Home) for my broadband connection, and my empeg is unable to lease an IP from them, despite every additional machine having a nice 24.65.*.* address. Also, I don't particularly want my empeg visible from the outside world, so this isn't an issue for me.

I was able to connect to my empeg by turning off DHCP usage on my Win2K box (after recording what all the vital IP addresses were) so that I could add a second internal IP to my Ethernet adapter. No problem -- my PC exists on 24.65.*.* and 192.168.1.* at the same time. I set the empeg to a fixed 192.169.1.* address and I use it on that address both at home and at work.

The problem is, my IP expires with @Home every 24 hours, so if I don't hit the DHCP server up after 24 hours, I lose my connection -- so even though I've scraped all the important IPs off the DHCP and manually entered them, they're useless after 24 hours (even though they have never changed.)

Sadly, when I re-enable DHCP on my Win2K box, it discards the extra 192.168.1.* address I gave it, making the empeg inaccessible.

So, does anyone know of a way to use DHCP on an adapter WITH a fixed internal IP?

A few ppl have suggested just putting a second NIC in my machine for my internal subnet, but thats ridiculous.
Posted by: loren

Re: Similar Situation, Inverse Problem? - 03/02/2002 18:35

I wouldn't say that's rediculous... you can get a cheapy NIC card for 10-15 bucks. Can't answer your other questions... haven't tried it myself.
Posted by: hybrid8

Re: Similar Situation, Inverse Problem? - 03/02/2002 18:39

Or he could always give up his cable connection and go to a modem. Then there's no problem running a fixed IP on the one NIC.

Bruno
Posted by: ClownBurner

Re: Similar Situation, Inverse Problem? - 03/02/2002 18:42

One simple way would be to write a Windows script that 'faked' a DHCP renew every 12 hours. I'm not much of a Windows programmer but I'd think it wouldn't be too difficult.

That way, you could stay static and still fool the ISP into thinking you were DHCP. An additional refinement would be to plug the addresses it got back into the registry so if there was a change your static settings would update with it.
Posted by: Fogduck

Re: Similar Situation, Inverse Problem? - 03/02/2002 18:51

> Or he could always give up his cable connection and
> go to a modem. Then there's no problem running a fixed
> IP on the one NIC.

...maybe when I retire to my munitions cabin in Montana.

ClownBurner: That would be exactly what I'd need, if I can't mix and match DHCP and fixed IPs on one adapter.

Loren: Maybe not ridiculous then, but dumb. I'll check my local parts bins for a cheapo PCI NIC. Damn tho, right when I thought I had economized on my IRQ assignments...
Posted by: jimhogan

Re: Similar Situation, Inverse Problem? - 03/02/2002 18:52

and my empeg is unable to lease an IP from them, despite every additional machine having a nice 24.65.*.* address.

Interesting, I thought !@Home was a 1-lease-per-customer proposition (I wouldn't know, as I'm with a local DSL outfit...)

...putting a second NIC in my machine for my internal subnet, but thats ridiculous.

Like the man said, not ridiculous at all, but I'd say that a more comforting, more durable, and more trouble-free option (albeit more expensive - say $75 for a 1-port model) would be a cheap hardware router/NAT like a Linksys.
Posted by: bonzi

Re: Similar Situation, Inverse Problem? - 04/02/2002 01:46

Go with Jim's solution (dedicated router with firewall and NAT) - you don't *want* your machines to have direct global address leases. Then all your stuff will live on 192.168.*.*, and router will selectively direct port 80 or any other incoming traffic you want to the machine you specify, you will see the world from internal network, and you will be reasonably well protected.

Otherwise, the only other lege artis solution *is* to have two NICs in your machine, but also to run a firewall there.
Posted by: Taym

Re: Similar Situation, Inverse Problem? - 04/02/2002 03:40

On Windows2k/Xp you can use the

ipconfig /renew

command

to do what was suggested in this thread.

Posted by: Fogduck

Re: Similar Situation, Inverse Problem? - 04/02/2002 03:43

> On Windows2k/Xp you can use the
> ipconfig /renew
> command
> to do what was suggested in this thread.

Thanks, Taym, but its not that simple, and now that Networking 101 is concluded...

IPCONFIG /RENEW only works for adapters with DHCP enabled. The problem is that I have to DISABLE DHCP and manually enter <what DHCP came up with> to be able to manually ADD an extra internal IP.

So, no, its not as simple as that.
Posted by: Fogduck

Re: Similar Situation, Inverse Problem? - 04/02/2002 03:54

> NAT) - you don't *want* your machines to have direct
> global address leases. Then all your stuff will live on
> 192.168.*.*, and router will selectively direct port 80 or
> any other incoming traffic you want to the machine you
> specify, you will see the world from internal network, and
> you will be reasonably well protected.

Yes, I've been putting that off and just running firewalls on all the machines here (not that many) -- but I'll keep looking for a solution (as described) including just adding a second NIC.

The machines here have all been safe and unmolested with global IPs for over two years now, so I might live vicariously a little longer.

Thanks.

Posted by: BartDG

Re: Similar Situation, Inverse Problem? - 04/02/2002 04:20

I've had very good experiences with my UsRobotics 8000 Router. My Empeg just clicks into it and it works beautifully. It's not that expensive too : +/- $100
If you even want cheaper : the SMC 7004ABR router is the exact same product and can possibly be found for $20 less or so.
Posted by: Taym

Re: Similar Situation, Inverse Problem? - 04/02/2002 06:35

Sorry, I just misunderstood what your problem is. Yes, ipconfig /renew only works with dhcp. However, ipconfig /registerdns also renews the lease of a static ip address. I did not understand what exactly is you problem, but maybe that can help.
Posted by: wfaulk

Re: Similar Situation, Inverse Problem? - 04/02/2002 10:19

You could get a real operating system.

Seriously, though, if you want to use a router, I'd suggest that you get one of the above linked OSes (I'd prefer one of the BSDs for this purpose) and slap it on a cheap (I'm talking Pentium 166-class) box with two NICs and use it as your firewall instead of one of those black-box DSL/Cable routers. The feature set will be about a million times greater, and you'll have another computer to play with. Then again, there's something to be said for brainless networking.
Posted by: loren

Re: Similar Situation, Inverse Problem? - 04/02/2002 10:41

like THIS!

(that info's outdated, i need to update it. Now there's an 8 port switch and a few other computers...)
Posted by: tfabris

Re: Similar Situation, Inverse Problem? - 04/02/2002 12:05

My dyslexic friend, I highly recommend you grab an integrated firewall/nat router and stick that in-between your broadband connection and the rest of your network. It will solve all of your problems and make you more secure to boot.

We use the Linksys BEFSR11 here, and it's been great. They are surprisingly inexpensive.
Posted by: Fogduck

Re: Similar Situation, Inverse Problem? - 04/02/2002 14:22

Thanks guys.

wfaulk: I have a 64MB P233 sitting here pretending to run Win2K (badly) that is acting as a file share, print server, burn unit, and Trillian client (for when my normal workstation is full-screen [read: games] and not conveniently dropped to desktop). I've always wanted to have it perform the same duties under Linux and KDE but figured I'd probably go insane on getting at least one of those features going. But hey, what else is this great empeg/Linux support community good for?

I *could* add another dedicated Linux-based router, but we've already got a cooling issue up in our loft. We don't heat it in winter now that my fiancee moved all her equipment up here too...

Loren: Thats awesome. I've got a wall that I could splatter a workstation on, maybe throw some Lego and a Habitrail system on and around it too. I could make it water-cooled and silent too. I wonder if there's a market for neo-post-modern-functional-overclocked-watercooled-Hamster-inhabited-wall-mounted-workstations. iMac meet WALLpc.

Tony: The writing does seem to be on the wall for finally getting a router. My dumb hubs are filled to capacity as it is. I'd learn more by scraping a Linux solution together, but I don't know what that'd do for the S/N ratio here. I might make it ot (old hand) sooner!

So many decisions. This BBS ups my confidence level for taking the fun/harder route however. Thanks guys.
Posted by: mlord

Re: Easiest way to switch from/to DHCP? - 04/02/2002 14:55

For those who missed the other thread, this feature has now been implemented, along with AC/DC tags as well.
Posted by: jimhogan

Re: Similar Situation, Inverse Problem? - 04/02/2002 16:15

We use the Linksys BEFSR11 here, and it's been great. They are surprisingly inexpensive.

I had a 3-interface ipchains box running well on a P200 for a while and it was swell, but it took a while to get it the way I wanted it. The motherboard smoked, though, and I was tight for time so I grabbed a Linksys 4-port. Since then I have set up 4 of them for friends with broadband connections. Inexpensive, no moving parts, easy to set up. For my friends, anything more complex or time-consuming would have been an obstacle and I figure they're getting 90+ percent of the benefit with 10 percent of the effort.

I'm rebuilding a box to run Gibraltar/Debian (easy: just a CD/floppy drive) firewall, but I'll probably keep the Linksys on-line for outbound . With latest firmware it now even handles IPSec for work VPN. Pretty darn good bang for the buck.