Page 1 of 1

[SOLVED] Auto-Up Virtualhosts?

Posted: Mon Nov 26, 2012 3:59 pm
by derrend
I'm sorry for posting this into the forum because I know it's plastered all over the internet but I'm just not able to grasp it for some reason soplease someone spell it out for me:-

I host a folder on a virtualhost 192.168.0.101
How can i make this virtualhot run at startup?

I edited the /etc/network/interfaces and added
iface eth0:1 inet static
address 192.168.0.101

and when i run 'ifup eth0:1' it works fine but how do i get the computer to do this at boot?

i put the command into a script in '/root/virtualup.sh'
and edited root crontab with '@reboot /root/virtualup.sh' the script ran fine when i tested it but this didn't happen at startup
so I changed it to '@reboot ifup eth0:1' but this didn't work either.

then i put 'ifup eth0:1' into '/etc/rc.local' but that didn't work.

Please note the '' around the commands are for illustration and not part of the command. im using mint 14 nadia :)

**I've now also tried putting 'eth0:1' in the auto line at the top of the 'interfaces' file.
and also put the line 'dhclient eth0:1' in 'rc.local' but still no luck.

Just tried 'sudo /etc/init.d/networking restart' and 'sudo service network-manager restart'.
eth0:1 showed up but the desktop interface went funny so i rebooted the computer which put it back to normal but still no eth0:1 at startup.

could network manager be the problem?

ok final update and then off to bed,
i added 'echo it worked >> /path/to/home/success.txt' below the command 'ifconfig eth0:1 192.168.0.101'.
The text file showed up in my home folder but the host was not cofigured, why could this be??

Re: Auto-Up Virtualhosts?

Posted: Tue Nov 27, 2012 2:18 pm
by derrend
*BUMP, I have a sneeky feeling my question isn't getting traffic now its slipped to page two. Surely someone out there can tell me why ifup commands dont work at boot??

Re: Auto-Up Virtualhosts?

Posted: Tue Nov 27, 2012 2:26 pm
by DrHu
Some network cards (nics) detect on power changes: IBM used to be like that: so I would use both ifdown and ifup to get a status reset to the card
--see if that sequence gets the nic active..
http://www.computerhope.com/unix/ifup.htm

But since it is a virtualhost and would be using the local (real host) devices, specifically networking, then..
http://www.webnms.com/simulator/help/si ... al_ip.html
http://www.boutell.com/lsm/lsmbyid.cgi/001134
  • linuxconfg tool referenced in the link below..
--check the names (aliases..) being used for that device on the virtualhost..

Re: Auto-Up Virtualhosts?

Posted: Tue Nov 27, 2012 8:01 pm
by derrend
Thanks for the advice but im still having no luck,
I configured the eth0:1 interface in /etc/network/interfaces and then in the rc.local file placed the command 'ifdown -a' 'ifup -a' and 'echo this script ran fine >> /home/folder/file'.
I tested 'ifdown -a' and 'ifup -a' manually which brought up the interface fine and when the computer reboots the output from echo shows up in my home folder which means the two commands above it ran fine because of the -e option after #!/bin/bash doesn't it?

I cant figure out why the interface isn't showing if the commands are running? Am i being overridden somehow perhaps?

Thanks in advance :)

Re: Auto-Up Virtualhosts?

Posted: Thu Nov 29, 2012 9:03 am
by derrend
*Bump - C'mon fellow linux enthusiasts im waiting 24 hours betwen bumps and i think this is my last one, surely someone out there knows why commands relating to ifconfig and network interfaces aren't having an effect from the rc.local file? It worked in mint 13 im sure of it.

Re: Auto-Up Virtualhosts?

Posted: Thu Nov 29, 2012 5:05 pm
by Gord
I dunno, this /etc/network/interfaces file works for me in Mint 14 Cinnamon:

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	address 192.168.1.14
	netmask 255.255.255.0
	gateway 192.168.1.1
	dns-nameservers 192.168.1.1

auto eth0:1
iface eth0:1 inet static
	address 192.168.1.15
	netmask 255.255.255.0
When I boot it just works, I don't need to do ifup or mess around with rc.local .

However, the network indicator in the status bar says "no connection" and when I click on it it says "Wired unmanaged" so the although the interface _is_ working (i can ping 1.14 and 1.15 from another box) the network manager doesn't recognize the connection. I'm very new to this Mint business so I don't really know why that might be. If somebody else here could explain the "proper" (i.e., managed) way to do it I'd be interested to learn.

Re: Auto-Up Virtualhosts?

Posted: Fri Nov 30, 2012 5:32 am
by derrend
Gord wrote:I dunno, this /etc/network/interfaces file works for me in Mint 14 Cinnamon.
Have you by any chance uninstalled network-manager?

Re: Auto-Up Virtualhosts?

Posted: Fri Nov 30, 2012 6:06 am
by Gord
derrend wrote:
Gord wrote:I dunno, this /etc/network/interfaces file works for me in Mint 14 Cinnamon.
Have you by any chance uninstalled network-manager?
Nope,

Code: Select all

gord@CinnaMintVM01 ~ $ aptitude search "?name(network-manager$)"
i   network-manager   - network management framework (daemon and userspace tools)
'i' = installed

Re: Auto-Up Virtualhosts?

Posted: Fri Nov 30, 2012 2:12 pm
by derrend
No exaduration, ive been dealing with this for more than 7 hours today, all ive done is change config settings, add scripts and reboot but it is simply impossible to get the eth0:1 virtual ip to run at boot.

I disabled network-manager and set up the interfaces manually but even that didnt work. I placed commands in the rc.local such as 'sleep 3m; ifconfig eth0:1 192.168.0.100' or told it to sleep and then run a script containing the commanad but it never shows up. If you run the ifup eth0:1 command the shell reports that the interface is 'already configured' but it doesnt show in the ifconfig output and you cant ping it.

I'm saying BUG and giving up. Thanks for the suggestions fellas, hopefully I'll come across the answer at some point in the future.

Re: Auto-Up Virtualhosts?

Posted: Fri Nov 30, 2012 2:40 pm
by Gord
Bummer. FWIW, I think I just found the "managed" way to do it. In Mint 14 Cinnamon, I removed everything from the 'interfaces' file except for the 'lo' (loopback) adapter, then...

Menu > Preferences > Network

...clicked the "Options..." button for the "Wired" connection, then on the "IPv4 Settings" tab selected "Method: Manual", entered both IP addresses and specified the DNS server (settings the same as my old 'interfaces' file, above).

After I rebooted both IP addresses (1.14 and 1.15) responded to pings, even if I was not logged in. After I logged in the status bar icon said that I was connected, and clicking the icon produced the little dialog with "Wired" and the on/off switch (instead of "unmanaged").

Re: Auto-Up Virtualhosts?

Posted: Fri Nov 30, 2012 5:33 pm
by derrend
Congratulation Gord you've finally solved it! I am a bit disappointed that this method doesn't show in the ifconfig output so I'm always going to have to ping it or go to the address, and that as a linux user I ultimately failed at the command line today.

I did learn something though, i thought my dns server address would have been the same as my gateway from reading your settings above buy luckily on the wired setting page before selecting 'options' they were displayed right there on the screen for me so i just copied and pasted them (there were two) and now it seems to be working fine :D

Well it isn't broke any more so I can finally stop fixing it. Thanks very much for the help :)

Re: [SOLVED] Auto-Up Virtualhosts?

Posted: Fri Nov 30, 2012 6:11 pm
by Gord
Hey, you're welcome! Glad to hear you got it working.

True, ifconfig only shows the primary IP address for eth0, but

Code: Select all

ip addr show eth0
shows both of them.

Cheers!

Re: Auto-Up Virtualhosts?

Posted: Fri Nov 30, 2012 6:46 pm
by derrend
Gord wrote:I'm very new to this Mint business
Well your learning pace is phenomenal. Quite right regarding the ip output, so this is what satisfaction feels like 8)

Thanks again :)