LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 03-09-2008, 07:34 PM   #1
pridefc
Member
 
Registered: Nov 2005
Distribution: redhat, debian, ubuntu
Posts: 47

Rep: Reputation: 15
Adding virtual interface for IP based virtual host


Hello
I'm planning to setup an IP based virtual host in apache.
current system IP: 192.168.1.5

Add ip of 192.168.1.10 by adding a virtual
ifconfig eth0 add 192.168.1.10

Add a second ip 192.168.1.20
ifconfig eth0:1 add 192.168.1.20

Is this correct? And would the virtual interfaces remain intact
after a reboot? If not, how would I go about making them permanent?

Thanks.
 
Old 03-09-2008, 07:36 PM   #2
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208

Rep: Reputation: 35
Quote:
Originally Posted by pridefc View Post
Hello
I'm planning to setup an IP based virtual host in apache.
current system IP: 192.168.1.5

Add ip of 192.168.1.10 by adding a virtual
ifconfig eth0 add 192.168.1.10

Add a second ip 192.168.1.20
ifconfig eth0:1 add 192.168.1.20

Is this correct? And would the virtual interfaces remain intact
after a reboot? If not, how would I go about making them permanent?

Thanks.
ifconfig ethX:1 <ip> netmask <netmask>

I don't know how to tell you to make them persistent because i don't know which distro you are using.
 
Old 03-09-2008, 07:37 PM   #3
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Is this on a Red Hat or CentOS type system? To make them permanent, just create the ifcfg-eth0:1 and other ones according to the device you created and put these files in /etc/sysconfig/network-scripts
 
Old 03-09-2008, 07:40 PM   #4
pridefc
Member
 
Registered: Nov 2005
Distribution: redhat, debian, ubuntu
Posts: 47

Original Poster
Rep: Reputation: 15
Sorry, it's Ubuntu 7.10.

And should I be doing eth0:1 for the first virtual interface and eth0:2 for the second instead of eth0 and eth0:1?

Do I need to add the virtual IPs to /etc/hosts file?

Thanks.
 
Old 03-09-2008, 07:45 PM   #5
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Quote:
Originally Posted by pridefc View Post
Sorry, it's Ubuntu 7.10.

And should I be doing eth0:1 for the first virtual interface and eth0:2 for the second instead of eth0 and eth0:1?

Do I need to add the virtual IPs to /etc/hosts file?

Thanks.
eth0:1, eth0:2, eth0:3... see the pattern. And if you had a connection of eth1, you could do eth1:0, eth1:1, eth1:2...

If this is just a local test and you do want to have some type of name resolution, then yes, add them to /etc/hosts if you have no other DNS setup on your network.

And sorry, not Ubuntu user, not sure what files to stick the configurations in to survive a reboot and I'm too lazy to go searching cause I'm not a personal search engine, I'm sure if you tried searching yourself, you'd find the answer rather quickly.
 
Old 03-10-2008, 04:22 PM   #6
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208

Rep: Reputation: 35
You will have to put them in /etc/network/interfaces
 
Old 03-16-2008, 04:52 PM   #7
pridefc
Member
 
Registered: Nov 2005
Distribution: redhat, debian, ubuntu
Posts: 47

Original Poster
Rep: Reputation: 15
Would this work?

iface eth0:1 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

iface eth0:2 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

iface eth0:3 inet static
address 192.168.1.20
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set apache virtual hosts Host-Based Security? hocheetiong Linux - Newbie 2 01-17-2014 05:20 AM
configuring secured name based virtual host bzlaskar Linux - Security 4 04-19-2007 06:05 AM
Adding virtual host bestofmed Linux - Networking 2 09-28-2005 05:01 PM
How to configure the virtual host based name? gz_xmg Linux - Networking 0 12-28-2004 02:12 AM
Name Based Virtual Host problem helios007 Linux - Networking 6 12-21-2003 04:41 PM


All times are GMT -5. The time now is 03:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration