[mythtv-users] howto: Setting up a fixed hostname on rh9 box using dhcp

Gerald Schepens schepens at shaw.ca
Sun May 2 06:33:21 EDT 2004


My ISP has a bad habit of changing my hostname every few days.  When 
this happens, there go all my myth settings, including my capture card.  
Very annoying. 

In order to stop this from happening, I cooked up the following 
workaround, which others more knowledgeable than me may find objections 
with, and your mileage may vary.  Basically, I set up a dummy network 
interface, configured it with an RFC1918 address, added a route from 
that address to my ethernet device and fixed my hostname to a name I 
aliased to the dummy address in my /etc/hosts.  Then I went into the 
myth database and changed hostname settings to my new name.

Step by step: 

1) Pick an RFC1918 address, say 192.168.1.1. 
2) pick a permanent hostname for yourself, say mymachine.
3) Edit /etc/hosts, and add a line that assigns the name you chose to 
the address you chose.

    192.168.1.1 mymachine.myispdomain.com mymachine

4) Edit /etc/rc.local and add the following lines.

modprobe dummy
ifconfig dummy0 192.168.1.1
route add 192.168.1.1 eth0
hostname mymachine

This loads the module for the dummy network device, assigns it an IP 
address, routes the packets that go to it to the ethernet card, and 
overrides the currently set hostname to the one you chose.

5) Open up mysql.  This is done by the following:
mysql -u <your mysql user name> -p mythconverg

You'll have to enter the password for the user you chose, but then you 
get a prompt at which you can query.

6) Do the following query to map the mythtv settings over to your new 
hostname.  I'm going to assume here that your prior hostname was OLDHOST.

update settings set hostname = "mymachine" where hostname = "OLDHOST";

You might also take the opportunity to get rid of settings from other 
host names your machine has had.  You can do this by doing the following:

select distinct hostname from settings;

You'll have some NULL records, some mymachine records, but you can do a 
'delete from settings where hostname = "old nonexistent hostname";' for 
all the other hostnames you've had in the past.

7) Do the following query to move your capture card over to the new host 
name.

update capturecard set hostname = "mymachine" where hostname = "OLDHOST";

Again, you might want to delete other records pertaining to cards on 
nonexistent hostnames, using the same sort of procedure from step 6.

When you're done, type "quit" to get out of mysql.

8) You can reboot, or you can manually type the rc.local lines and do a 
"service mythbackend restart".

Hopefully this is useful to someone else -- I can't have been the only 
person that kept having their myth settings wiped out by a 
dhcp-initiated hostname change.




More information about the mythtv-users mailing list