How to control (up/down) a virtual IP interface (eth0:1)

Hello all,

I am looking for a method to control virtual IPs (IP aliases) like an real interface with ifconfig/ip or ifup/-down.

The reason: I want to run a BIND on 2 machines with 2 separate IP addresses and on shared (service) IP address.

In other Linux distributions it goes like (i.e.)
ifconfig eth0:1 address 192.168.10.10 netmask 255.255.255.0
ifconfig eth0:1 up

That doesn’t work in SLESS 11. I can create a virtual interface and use it but I cannot take ist down or up independed from the parent interface (i.e. eth0).

I appreciate any answers !

Thanks in advance !

Udo

[QUOTE=UZumdick;4589]Hello all,

I am looking for a method to control virtual IPs (IP aliases) like an real interface with ifconfig/ip or ifup/-down.

The reason: I want to run a BIND on 2 machines with 2 separate IP addresses and on shared (service) IP address.

In other Linux distributions it goes like (i.e.)
ifconfig eth0:1 address 192.168.10.10 netmask 255.255.255.0
ifconfig eth0:1 up

That doesn’t work in SLESS 11. I can create a virtual interface and use it but I cannot take ist down or up independed from the parent interface (i.e. eth0).

I appreciate any answers !

Thanks in advance !

Udo[/QUOTE]

What does ‘ifconfig’ and/or ‘ip addr’ say?

pns1:/opt/dns # ifup eth0:1
Interface eth0:1 is not available

pns1:/opt/dns # ifdown eth0:1
eth0:1 no such interface
interface eth0:1 is not available

ifconfig eth0:1 down deletes the whole virtual interface eth0:1
therefore it can’t be activated the same way:

ifconfig eth0:1 up
pns1:/opt/dns # ifconfig eth0:1 up
SIOCSIFFLAGS: Cannot assign requested address

-Udo

[QUOTE=UZumdick;4591]pns1:/opt/dns # ifup eth0:1
Interface eth0:1 is not available

pns1:/opt/dns # ifdown eth0:1
eth0:1 no such interface
interface eth0:1 is not available

ifconfig eth0:1 down deletes the whole virtual interface eth0:1
therefore it can’t be activated the same way:

ifconfig eth0:1 up
pns1:/opt/dns # ifconfig eth0:1 up
SIOCSIFFLAGS: Cannot assign requested address

-Udo[/QUOTE]

Does not answer my question…

Sorry, but then I don’t understand your question. :frowning:

I described the way I used the commands ifconfig and ifup(-down) and gave the output of theses commands

?-)

[QUOTE=UZumdick;4594]Sorry, but then I don’t understand your question. :frowning:

I described the way I used the commands ifconfig and ifup(-down) and gave the output of theses commands

?-)[/QUOTE]

I merely asked for the output of

ifconfig

and

ip addr

Oh, ok. I am sorry :sunglasses:
Here I tried it with eth1

ifconfig:
eth0 Link encap:Ethernet HWaddr 5C:F3:FC:E5:F0:20
inet addr:192.168.19.186 Bcast:192.168.19.255 Mask:255.255.254.0
inet6 addr: 2003:4:f023:8000:5ef3:fcff:fee5:f020/64 Scope:Global
inet6 addr: fe80::5ef3:fcff:fee5:f020/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:101 errors:0 dropped:0 overruns:0 frame:0
TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7316 (7.1 Kb) TX bytes:6981 (6.8 Kb)
Interrupt:28 Memory:96000000-96012800

eth1 Link encap:Ethernet HWaddr 5C:F3:FC:E5:F0:22
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:40 Memory:98000000-98012800

eth1:1 Link encap:Ethernet HWaddr 5C:F3:FC:E5:F0:22
inet addr:192.168.1.13 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:40 Memory:98000000-98012800

eth2 Link encap:Ethernet HWaddr 5C:F3:FC:6A:7A:DC
UP BROADCAST SLAVE MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:29 Memory:92000000-92012800

eth3 Link encap:Ethernet HWaddr 5C:F3:FC:6A:7A:DC
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:16 errors:0 dropped:138 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1024 (1024.0 b) TX bytes:492 (492.0 b)
Interrupt:41 Memory:94000000-94012800

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:15854 errors:0 dropped:0 overruns:0 frame:0
TX packets:15854 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1584463 (1.5 Mb) TX bytes:1584463 (1.5 Mb)

ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
inet 127.0.0.2/8 brd 127.255.255.255 scope host secondary lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 5c:f3:fc:e5:f0:20 brd ff:ff:ff:ff:ff:ff
inet 192.168.19.186/23 brd 192.168.19.255 scope global eth0
inet6 2003:4:f023:8000:5ef3:fcff:fee5:f020/64 scope global dynamic
valid_lft 2591998sec preferred_lft 604798sec
inet6 fe80::5ef3:fcff:fee5:f020/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
link/ether 5c:f3:fc:e5:f0:22 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global eth1
inet 192.168.1.13/24 brd 192.168.1.255 scope global secondary eth1:1
4: eth2: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc mq master bond0 state DOWN qlen 1000
link/ether 5c:f3:fc:6a:7a:dc brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000
link/ether 5c:f3:fc:6a:7a:dc brd ff:ff:ff:ff:ff:ff
6: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 5e:f3:fc:dd:f0:23 brd ff:ff:ff:ff:ff:ff

What you want/should use is probably something along the lines of

ip addr add 192.168.1.13/24 dev eth1
ip addr del 192.168.1.13/24 dev eth1

Do you mean without any virtual ip configuration ?

In my config

ip addr add 192.168.1.13/24 dev eth1

does nothing - ifconfig:
[…]
eth1 Link encap:Ethernet HWaddr 5C:F3:FC:E5:F0:22
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:40 Memory:98000000-98012800

But a second invocation gives an error message:
pns1:/etc/sysconfig/network # ip addr add 192.168.1.13/24 dev eth1
RTNETLINK answers: File exists

But I can’t see the virtual interface.

ip addr del 192.168.1.13/24 dev eth1

Deletes also the whole virtual interface, like ifconfig does.

-Udo

[QUOTE=UZumdick;4598]Do you mean without any virtual ip configuration ?

In my config

ip addr add 192.168.1.13/24 dev eth1

does nothing - ifconfig:
[…]
eth1 Link encap:Ethernet HWaddr 5C:F3:FC:E5:F0:22
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:40 Memory:98000000-98012800
[/QUOTE]

Yes it does something, but you need to look at it using ‘ip addr’.

ifconfig is the old way of doing things.

Nowadays you no longer need an alias (ethx:n) for a secondary IP (what you call virtual, I guess) to work.

As I said, not using ‘ifconfig’, but you see the secondary using ‘ip addr’.

[QUOTE]

ip addr del 192.168.1.13/24 dev eth1

Deletes also the whole virtual interface, like ifconfig does.

-Udo[/QUOTE]

Well, technically you do the following, so there is no real up/down for the secondary. At least I wouldn’t know spontaneously how to up/down it (ie. remember it while attributing some state to it).

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
    inet 127.0.0.2/8 brd 127.255.255.255 scope host secondary lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:ac:00:28 brd ff:ff:ff:ff:ff:ff
    inet 192.168.98.103/24 brd 192.168.98.255 scope global eth0
# ip addr add 192.168.98.69/24 dev eth0
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
    inet 127.0.0.2/8 brd 127.255.255.255 scope host secondary lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:ac:00:28 brd ff:ff:ff:ff:ff:ff
    inet 192.168.98.103/24 brd 192.168.98.255 scope global eth0
    inet 192.168.98.69/24 scope global secondary eth0
# ip addr del 192.168.98.69/24 dev eth0
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
    inet 127.0.0.2/8 brd 127.255.255.255 scope host secondary lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:ac:00:28 brd ff:ff:ff:ff:ff:ff
    inet 192.168.98.103/24 brd 192.168.98.255 scope global eth0

You don’t see anything of the secondary interfaces in ifconfig. Anyway, why do you want/need to?

Sorry for the delay, we had some spare days here in Germany :slight_smile:

You don’t see anything of the secondary interfaces in ifconfig. Anyway, why do you want/need to?

My plan was to let BIND 9.x Nameserver bind 2 addresses: The real one and the virtual one. This should be done on two machines.
The virtual IP address should be the service IP which will be used by customers.
Only the active one of the two machines should have the virtual IP up and thsi should change in case of failure.
But BIND cannot bind an address until the interface is configured/visible. So that’s my problem.
So, if I bring down an interface with ifconfig BIND can still see the interface. If I do this with ip addr instead BIND cannot see the interface and will not use it until a complete restart (what will, unfortunately take to much time).