dresden-weekly / ansible-network-interfaces

Ansible roles to manage Ubuntu network interface configuration
MIT License
86 stars 62 forks source link

Can not add virtual interfaces #63

Open dominikkukacka opened 7 years ago

dominikkukacka commented 7 years ago

I tried to add a virtual interface to eth1:

- device: eth1:0
        description: eth1:0 - mydomain.com
        auto: true
        family: inet
        method: static
        address: 1.2.3.4
        netmask: 255.255.255.248
        gateway: 1.2.3.1
        allow:
          - hotplug

which resulted in this error:

dresden-weekly.ansible-network-interfaces : network restart interface command
...
"stderr": "ifdown: interface eth1:0 not configured\nRTNETLINK answers: File exists", 
"stdout": "Failed to bring up eth1:0.",
...

The interface file is written but the restart failes. And yes the interface is already there and up. But should this not work anyway? (It does for eth0/eth1)

arBmind commented 7 years ago

This reminds me of the old days, when we used virtual interfaces like that. Today, we just add more IP addresses to a single interface.

What system does still support this old behavior?

dominikkukacka commented 7 years ago

This is actually on an Ubuntu 16.04 installation. How do I add multiple IP addresses with the role?

Am 25.09.2017 19:45 schrieb "Andreas Reischuck" notifications@github.com:

This reminds me of the old days, when we used virtual interfaces like that. Today, we just add more IP addresses to a single interface.

What system does still support this old behavior?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dresden-weekly/ansible-network-interfaces/issues/63#issuecomment-331958762, or mute the thread https://github.com/notifications/unsubscribe-auth/AAO2d1wNcoQZ8S9WQMDtKG1Rk8YSmXG6ks5sl-a8gaJpZM4Pid8f .

arBmind commented 7 years ago

Just add them to the routes on up and remove them on down

- device: eth1
  # …
  # add additional IPs
  up:
    - "route add -net 1.2.3.4 netmask 255.255.255.248 gw 1.2.3.1 eth1"
  down:
    - "route delete -net 1.2.3.4 netmask 255.255.255.248 gw 1.2.3.1 eth1"
arBmind commented 7 years ago

I guess the main issue here is that we generate an illegal filename. Maybe someone can fix that.