LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   interface mapping two IPs on ubuntu 6.06 lts server (https://www.linuxquestions.org/questions/linux-networking-3/interface-mapping-two-ips-on-ubuntu-6-06-lts-server-585936/)

elgranjefe 09-19-2007 07:10 PM

interface mapping two IPs on ubuntu 6.06 lts server
 
Hello,

Im still pretty new to linux and i'm using ubuntu's server 6.06 lts dapper drake distribution to try to figure things out.

upon installing the ssl module for apache, i realized i need to setup virtual host so i can have http and https. i would prefer to have two separate IPs on eth0 rather than installing another NIC, but the manual pages interfaces(5) for the /etc/network/interfaces file is a little over my head.

"The first line of a mapping stanza consists of the word "mapping" followed by a pattern in shell glob syntax. Each mapping stanza must contain a script definition. The named script is run... See /usr/share/doc/ifupdown/examples of what the script must print."

i checked out a few of those examples, but i guess i didn't really understand what they were saying.

questions:
1) is this a bit over my head, and if so;
2) how do i do it?

thanks

Brian1 09-19-2007 08:31 PM

Not sure if Ubuntu does it but in Redhat / Fedora distros you use IP Aliasing. You make the other IP eth0:0 and the next eth0:1 and so on. But if you are using iptables for port forwarding then you need to use the IP and not eth0:0 notations. Iptables does not understand IP Aliasing.

Brian

kstan 09-19-2007 08:34 PM

Hi elgranjefe,
if you want to have more ipaddress from eth0, run following command(eth0:0 is default).

ifconfig eth0:1
ifconfig eth0:2
Regards,
Ks

elgranjefe 10-01-2007 03:07 AM

Quote:

Originally Posted by kstan (Post 2897379)
Hi elgranjefe,
if you want to have more ipaddress from eth0, run following command(eth0:0 is default).

ifconfig eth0:1
ifconfig eth0:2
Regards,
Ks

First off, sorry about the wait as i've been busy with life and configuring my ubuntu server is more of a leisure activity at this point...

anyhoo... using

Code:

ifconfig eth0:0 192.168.1.4
ifconfig eth0:1 192.168.1.3

worked fine when the server was up and running (both IPs were pingable, my ip-based virtual hosts for apache worked perfectly) but when i edited my /etc/network/interfaces to

Code:

...
auto eth0
iface eth0 inet static
    address 192.168.1.4
    netmask 255.255.255.0
    gateway 192.168.1.1

auto eth0:1
iface eth0:1 inet static
    address 192.168.1.3
    netmask 255.255.255.0
    gateway 192.168.1.1

every time i try to boot, it hangs at "configuring network interfaces" and sits there indefinitely (a few days justifies 'indefinitely') i realize that this is probably a simple syntax error on my part, but i can no longer boot to fix the problem. i downloaded knoppix to try to edit the file, but it tells me something along the lines of "read only filesystem"...

i'll take suggestions concerning the syntax of the interfaces file and/or ways to boot (with either ubuntu, knoppix, or another alternative) so that i can actually apply those suggestions.

please and thanks again,
Jeff

kstan 10-01-2007 03:28 AM

You shall not assign dynamic ip address to webserver.
Anyway, if you want to correct the thing just log in as single user,

during boot from GRUB, choose your Linux as boot OS, press 'e', at 2nd line, press 'e' again.
Go to end of the line, type 'single', then press enter and 'b'.

Now you login to single user mode, without network, without GUI and anything. Perform the correction and then type this command:-
/sbin/init 2

elgranjefe 10-01-2007 04:11 AM

It still tries to configure my network interfaces and hangs...

to clarify that I'm doing things right... please correct me if I'm wrong.

At the main GRUB menu, I highlight the OS I want (Ubuntu, kernel 2.6.15-26-sever), then press 'e'.
Next, I press 'e' again with "root (hd0,0)" selected, append 'single' to the end of the line, press enter to accept the change. Then press 'b' to boot.

elgranjefe 10-02-2007 05:42 PM

i figured out how to use the ubuntu install cd as to log in as root and edit the interfaces file! :)

the only way i could get the system to boot was with

Code:

...
# default interface
auto eth0:0
iface eth0:0 inet static
    address 192.168.1.4
    netmask 255.255.255.0
    gateway 192.168.1.1

# second IP for SSL
auto eth0:1
iface eth0:1 inet static
    address 192.168.1.3
    netmask 255.255.255.0
    gateway 192.168.1.1

the only problem is that ifconfig reports eth0:0/1 as being inactive. i used ifconfig eth0:0/1 up with no errors and i can ping each ip on the server itself, but other macines time out when trying to ping.

any suggestions...?
thanks again,
jeff

elgranjefe 10-05-2007 05:03 PM

haha

i can't believe it took me so long to realize that all i needed to do was hit 'enter' when it hangs on "configuring network interfaces" and it continues to boot successfully.

so i configured the interfaces file as follows
Code:

auto lo
iface lo inet loopback

# default interface
auto eth0
iface eth0 inet static
    address 192.168.1.4
    netmask 255.255.255.0
    gateway 192.168.1.1

# second IP for SSL
auto eth0:0
iface eth0:0 inet static
    address 192.168.1.3
    netmask 255.255.255.0
    gateway 192.168.1.1

both eth0 and eth0:0 work how i intended, and i don't have any problems except the fact that its annoying having to be on-site and physically press enter on each reboot.

does anyone know how to remedy that?

elgranjefe 11-12-2007 05:24 PM

just in case anyone does read this, i finally and completely eliminated the problem by only having eth0 boot at startup.

to automatically setup my virtual interfaces, i created a php-cli script (i didn't want to take the time to learn bash programming) that configures virtual interfaces based on settings in the config file. thenm i created a cron job to run the php script at startup.

may not be the most professional approach, but its gets the job done for me :)

javaroast 11-12-2007 08:09 PM

Another option is to skip the virtual interfaces and just add a second IP to the adapter directly using ip addr add xxx.xxx.xxx.xxx/xx dev /eth0. ifconfig has been deprecated in kernels after 2.4 in favor of iproute2. I believe the startup issue that you are seeing is that in linux the virtual interfaces are not a true interface, but simply an alias.


All times are GMT -5. The time now is 01:29 PM.