Re: [expert] /etc/hosts and dns - THANK YOU
On Sun, 2003-11-16 at 09:07, Anne Wilson wrote: > On Sunday 16 Nov 2003 1:46 am, Greg Meyer wrote: > > > Thanks again for pointing me in the right direction, For > > posterity's sake here is what I have done. > > Greg, I would say that should *definitely* be on the TWiki - would you > oblige? > > Anne Greg, When you get it up let me know. For 9.1 (due to some differences in that it doesn't do profiles as well.) I've another system I use for the 4 locations my laptop goes regularly. Basically I have 4 ifcfg's in a holding directory and just switch one for the other and restart pcmcia. (all wireless connections with different WEP keys.) I'll post a "neutered version of mine along with yours so that they are on the same page. James Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] /etc/hosts and dns - THANK YOU
On Sunday 16 Nov 2003 1:46 am, Greg Meyer wrote: > Thanks again for pointing me in the right direction, For > posterity's sake here is what I have done. Greg, I would say that should *definitely* be on the TWiki - would you oblige? Anne -- Registered Linux User No.293302 Have you visited http://twiki.mdklinuxfaq.org yet? Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] /etc/hosts and dns - THANK YOU
On Monday 10 November 2003 02:10 pm, Richard Urwin wrote: > On Monday 10 Nov 2003 2:18 am, Greg Meyer wrote: > > I have a laptop that connects to my office e-mail server as an IMAP > > client. Sometimes I am outside the firewall, and in this case, I can > > connect to the server using the server's fqdn. When I am inside the > > firewall, I can connect to the server by making an entry in my /etc/hosts > > file for it that aliases it's private ip to it's netbios name (it is an > > Exchange 5.5 server). In order to connect, I simply change the > > servername in kmail depending on where I am. > > > > So now my question, is there any way to set up my hosts/resolv.conf/tmdns > > to look for the server in the local network first and if it cannot find > > it to look it up in the DNS so that I don't have to constantly change the > > setup in kmail? > > > > Since the local addressing scheme in place at my company is quite unique > > I would even be open to doing something like having a script called in > > rc.local check to see what the network ip block of the local network is > > and writing out a hosts file that would have an entry for the server if I > > am on the right network, although I have no idea how to actually > > implement that. > > You mean something like: > > cp /etc/hosts.base /etc/hosts > if (/sbin/ifconfig eth0 | grep 192.168.7>/dev/null) > then cat /etc/hosts.extra >> /etc/hosts > fi > > (test it first, of course) Thanks again for pointing me in the right direction, For posterity's sake here is what I have done. I took this challenge as an opportunity to get more familiar with shell scripting. Despite the fact that there are probably many improvements that can be made to make it more universal, it works for my needs. I post it here for future reference for anyone looking for a similar solution. #!/bin/bash #This is the network startup script that is handy for a laptop #computer that has to move between different networks. We are booting with a #base modules.conf and hosts file and appending it based upon the network #profile we want to maintain. The reason modules.conf is involved is that on #some network we want the wireless interface to be eth0 and on others we want #it to be eth1. By using the aliases in modules.conf, we can load the #interfaces in any order we like. #Define variables #Set the profile PROFILE=$1 #You must be root to run this script, so we test and then exit if #whoami does not return root if test `whoami` != root ; then echo "You must be the system administrator to run this script" echo "Please become root user and try again" exit fi #Test and make sure a profile was specified if test "$PROFILE" = "" ; then echo "You must specify a valid network profile" echo "Syntax: network.sh " exit fi #Give some feedback to the user echo "Setting parameters for $PROFILE networking profile" #Set up hosts and modules.conf #The related hosts.$PROFILE files should contain the addresses on the local #net that need to be resolved by name. The related modules.conf.$PROFILE #files should contain the proper aliases for the order we want the network #interfaces to load. cp /etc/hosts.base /etc/hosts cat /etc/hosts.$PROFILE >> /etc/hosts echo "Creating hosts file... done." #The copying of modules.conf.base must be done as part of the initscripts so #that a basic modules.conf file is available at boot that does not contain #any network aliases. This is so the other hardware modules can be loaded #but no network interfaces are brought up by before we know what profile we #want to run under. Perhaps this can always be done at shutdown, but is #probably better as part of rc.sysinit. cp /etc/modules.conf.base /etc/modules.conf cat /etc/modules.conf.$PROFILE >> /etc/modules.conf echo "Creating module aliases... done." #If we get this far we can bring up the interfaces echo "Bringing up the network interfaces" ifup eth0.$PROFILE ifup eth1.$PROFILE echo "done" echo "Profile $PROFILE loaded" -- /g "Outside of a dog, a man's best friend is a book, inside a dog it's too dark to read" -Groucho Marx Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] /etc/hosts and dns
On Monday 10 November 2003 02:10 pm, Richard Urwin wrote: > > Since the local addressing scheme in place at my company is quite unique > > I would even be open to doing something like having a script called in > > rc.local check to see what the network ip block of the local network is > > and writing out a hosts file that would have an entry for the server if I > > am on the right network, although I have no idea how to actually > > implement that. > > You mean something like: > > cp /etc/hosts.base /etc/hosts > if (/sbin/ifconfig eth0 | grep 192.168.7>/dev/null) > then cat /etc/hosts.extra >> /etc/hosts > fi > > (test it first, of course) > HTH Thank you for that. I would make a terrible programmer. It seems so obvious now after seeing your simple script. -- /g "Outside of a dog, a man's best friend is a book, inside a dog it's too dark to read" -Groucho Marx Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] /etc/hosts and dns
> I have a laptop that connects to my office e-mail server as an IMAP > client. Sometimes I am outside the firewall, and in this case, I can > connect to the server using the server's fqdn. When I am inside the > firewall, I can connect to the server by making an entry in my /etc/hosts > file for it that aliases it's private ip to it's netbios name (it is an > Exchange 5.5 server). In order to connect, I simply change the servername > in kmail depending on where I am. > > So now my question, is there any way to set up my hosts/resolv.conf/tmdns > to look for the server in the local network first and if it cannot find > it to look it up in the DNS so that I don't have to constantly change the > setup in kmail? > > Since the local addressing scheme in place at my company is quite unique > I would even be open to doing something like having a script called in > rc.local check to see what the network ip block of the local network is > and writing out a hosts file that would have an entry for the server if I > am on the right network, although I have no idea how to actually implement > that. There are a couple ways to do this. IMHO, there's an easy way and a correct way and it's not clear which is which :) The quick way would be to write a script based on the IP address that you receive. You could either parse ifconfig or do something when your dhcp client returns. You could also put in a specific configuration for your MAC address inside the DHCP server itself. However, these all have inherent disadvantages. The way I'd do it is to set up a DNS view for the internal and external networks. Machines on the inside would receive the private non-routable address when querying the nameserver for mail.domainname.com. External machines would receive the public IP address. For example in the named.conf: view "internal" { // This should match our internal networks. match-clients { localnets; }; recursion yes; zone "domainname.com" { type master; file "pz/db.internal"; }; } view "external" { match-clients { any; }; recursion no; zone "domainname.com" { type master; file "pz/db.domainname.com"; }; } -- The Digital Hermit Unix and Linux Solutions http://www.digitalhermit.com [EMAIL PROTECTED] Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] /etc/hosts and dns
On Monday 10 Nov 2003 2:18 am, Greg Meyer wrote: > I have a laptop that connects to my office e-mail server as an IMAP client. > Sometimes I am outside the firewall, and in this case, I can connect to the > server using the server's fqdn. When I am inside the firewall, I can > connect to the server by making an entry in my /etc/hosts file for it that > aliases it's private ip to it's netbios name (it is an Exchange 5.5 > server). In order to connect, I simply change the servername in kmail > depending on where I am. > > So now my question, is there any way to set up my hosts/resolv.conf/tmdns > to look for the server in the local network first and if it cannot find it > to look it up in the DNS so that I don't have to constantly change the > setup in kmail? > > Since the local addressing scheme in place at my company is quite unique I > would even be open to doing something like having a script called in > rc.local check to see what the network ip block of the local network is and > writing out a hosts file that would have an entry for the server if I am on > the right network, although I have no idea how to actually implement that. You mean something like: cp /etc/hosts.base /etc/hosts if (/sbin/ifconfig eth0 | grep 192.168.7>/dev/null) then cat /etc/hosts.extra >> /etc/hosts fi (test it first, of course) HTH -- Richard Urwin Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] /etc/hosts and dns
On Sunday 09 November 2003 11:26 pm, Ronald J. Hall wrote: > On Sunday 09 November 2003 09:18 pm, Greg Meyer wrote: > > So now my question, is there any way to set up my hosts/resolv.conf/tmdns > > to look for the server in the local network first and if it cannot find > > it to look it up in the DNS so that I don't have to constantly change the > > setup in kmail? > > I don't think its the exact solution you're looking for, but until you do > find what you want, couldn't you setup 2 different profiles in Kmail - 1 > for each? > > Just a random thought. :-) I had not thought of that myself, and it may be a solution. My first thought is that I will have two IMAP folder trees, but that seems like only a minor issue. -- /g "Outside of a dog, a man's best friend is a book, inside a dog it's too dark to read" -Groucho Marx Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] /etc/hosts and dns
On Sunday 09 November 2003 09:18 pm, Greg Meyer wrote: > So now my question, is there any way to set up my hosts/resolv.conf/tmdns > to look for the server in the local network first and if it cannot find it > to look it up in the DNS so that I don't have to constantly change the > setup in kmail? I don't think its the exact solution you're looking for, but until you do find what you want, couldn't you setup 2 different profiles in Kmail - 1 for each? Just a random thought. :-) -- /\ Dark>Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com