Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ifconfig changes not saved after reboot

Status
Not open for further replies.

pcarver

Technical User
Aug 23, 2001
36
US
Howdy.

I'm setting up Apache and wanted to use IP-based virtual hosting. Great. I used ifconfig to:

ifconfig eth0:0 x.x.x.x

Then when I do just ifconfig, it shows everything just fine and I can use my new web site using x.x.x.x. But, when I reboot, the eth0:0 interface is gone. I've tried this several times and can't figure out why ifconfig doesn't save any changes. Do I need to do something else? Maybe in netcfg?

Thanks for any help!

/paul
 
Well, I meant 'shutdown'. Seems pretty strange. Also, I've read a few things about possibly having to add a 'route' as well. Hum...

/paul
 
Paul,

assuming you have a route set already, try a route flush to clear any detritus and then route add to add your correct route back in. HTH.
 
ifconfig only works while your system is up. depending on your distro you need to edit find the startup files that run ifconfig at boot. you should start by looking in your /etc/init.d directory for any startup scripts that that configure your interface
(e.g. grep ifconfig /etc/init.d/*) then edit this script to include your new interface at boot. If your using redhat look in /etc/sysconfig/network-scripts. im not familure with any other distro.
 
Most people who do aliases use an rcscript
to readd these virtual interfaces-
I use SuSE so , all I would have to do
is write in rc.config:

virt_int=yes

V_I1="eth0:0 192.168.1.23 up"
V_I2:="eth0:1 192.134.56.78 up"

Then add a little code to the rcnetwork->
script:

if [ "$virt_int" = yes ]
then
for x in $V_I1, etc..
do
/sbin/ifconfig $x
done
fi

With RH you may need to write your own and include it.
 
Hi,

If it's redhat they store the interface info in files like /etc/sysconfig/network-scripts/ifcfg-eth0. These are read during network initialisation so you need to edit them directly (or indirectly with netcfg or linuxconf) to make changes last across a reboot. Example :

DEVICE=eth0
IPADDR=208.164.186.1
NETMASK=255.255.255.0
NETWORK=208.164.186.0
BROADCAST=208.164.186.255
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

However, I don't believe this setup allows for Interface aliasing. Simplest in redhat is just to add your 'ifconfig' commands to /etc/rc.d/rc.local which is the last script run in the boot-up process. Alternatively you could do the full sysv init thing and add something to your '/etc/rc.d/init.d/network' script along the lines suggested by marsd.

Regards
 
I just tested it and you can apply this to virtual interfaces. Simply do this.

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0

Then edit ifcfg-eth0:0 as needed. Make sure to have ONBOOT=yes in this file.

Then as root run:
service network restart

ifconfig should show the virtual interface and is shoult be there after reboot.

Of course this only applies to Red Hat
 
Insert the line containing ifconfig command,
eq:
ifconfig eth0:0 123.123.123.123 netmask 255.255.255.0
into your system's init script(ussually /etc/rc.d/rc.local).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top