LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   /etc/network/interfaces configuration for virtual interfaces (http://www.linuxquestions.org/questions/linux-networking-3/etc-network-interfaces-configuration-for-virtual-interfaces-840277/)

nonshatter 10-25-2010 04:39 AM

/etc/network/interfaces configuration for virtual interfaces
 
Hey,

I've just been trying to create a virtual address on the same interface.

I need one static address for the internet, and another (virtual) static IP for mysql server running on 9.0.0.10

Here is my /etc/network/interfaces configuration:
Code:

auto lo
iface lo inet loopback
auto eth0 eth0:0

iface eth0 inet static
        address 10.0.54.127
        netmask 255.255.252.0
        gateway 10.0.52.1
iface eth0:0 inet static
        address 9.0.0.10
        netmask 255.0.0.0
        gateway 10.0.52.1

eth0 seems fine, but eth0:0 doesn't come up when the networking is restarted. I get "SIOCSIFFLAGS: Cannot assign requested address" and "Failed to bring up eth0:0"

Any ideas what's wrong here?

Many thanks

prayag_pjs 10-25-2010 05:53 AM

Try this command and see if it works:

Code:

sudo ifconfig eth0:0 9.0.0.10  up

nonshatter 10-25-2010 06:02 AM

Hi thanks for the reply, Here's the response I get

Code:

# sudo ifconfig eth0:0 9.0.0.10 up
SIOCSIFADDR: File exists
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address

I can't see a problem with my interfaces configuration, and can't seem to narrow down where the issue resides. Are there any other config files that I could check?

I've also tried this:
Code:

# ip addr sh eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 100
    link/ether 00:25:90:0a:96:7c brd ff:ff:ff:ff:ff:ff
    inet 10.0.54.127/22 brd 10.0.55.255 scope global eth0
    inet 9.0.0.10/8 brd 9.255.255.255 scope global eth0
    inet6 fe80::225:90ff:fe0a:967c/64 scope link
      valid_lft forever preferred_lft forever

and the mysql address is there, but it still won't let me connect :s

prayag_pjs 10-25-2010 06:15 AM

and what about

Quote:

sudo ifconfig eth0:0 10.0.54.130 up
or

Quote:

sudo ifconfig eth0:1 10.0.54.130 up

nonshatter 10-25-2010 06:22 AM

Okay, I've solved the problem. The configuration was all okay. Why it wouldn't let me assign the address under /interfaces was because the address already existed under the kernels routing table.

MySQL was refusing the connection because /etc/mysql/my.cnf was only listening to connections from localhost.

Code:

bind-address = 127.0.0.1
was changed to listen to the virtual interface. I restarted mysql and hey presto, it works!


All times are GMT -5. The time now is 06:53 PM.