Re: update /etc/hosts after ifup-ppp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martin Marques wrote:
> Is there an easy way to update /etc/hosts after my XDSL connection comes
> up? I want to have the name I have with ez-ipupdate and the IP address
> that is assigned to my computer also in /etc/hosts.
> 
If you want this to happen every time you bring up the PPP
connection, you could create a /etc/ppp/ip-up.local script to edit
/etc/hosts. I don't remember the order that things are passed to the
script, but one of them is the IP address. A quick, cheap, and dirty
way would be to add the hostname/IP address to the end of the  file
when using something like: (replacing <your hostname> with yours.)

#!/bin/bash
#
# Script to add <your hostname> to /etc/hosts.
#
echo <your host name> $4 >> /etc/hosts

You would then need a /etc/ppp/ip-down.local to remove it again.

#!/bin/bash
#
# Script to remove <your hostname> from /etc/hosts.
#
sed -i -e "/<your hostname>/d" /etc/hosts

A somewhat better /etc/ppp/ip-up.local script would be:

#!/bin/bash
#
# Script to add <your hostname> to /etc/hosts.
#
sed -i -e "/<your hostname>/d" /etc/hosts
echo <your host name> $4 >> /etc/hosts

Now, these scripts have not been tested, and I may have the
parameter number wrong. I am still working on my first cup of
coffee. You may want to run "man pppd" and scroll way down to the
section on scripts.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux