Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all properties (broadcase, netmask etc) for interfaces with multiple bindings #34

Open
bendikro opened this issue Aug 9, 2018 · 4 comments

Comments

@bendikro
Copy link

bendikro commented Aug 9, 2018

With a physical interface enp11s0, and a virtual interface created with ifconfig enp11s0:0 192.168.0.4,
the output from ip addr show looks something like:

2: enp11s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 40:8d:5c:54:d1:91 brd ff:ff:ff:ff:ff:ff
    inet 172.16.0.196/22 brd 172.16.3.255 scope global dynamic noprefixroute enp11s0
       valid_lft 495075sec preferred_lft 495075sec
    inet 192.168.0.4/24 brd 192.168.0.255 scope global enp11s0:0
       valid_lft forever preferred_lft forever

I've removed inet6 output lines as well as localhost

Trying to parse this gives:

Traceback (most recent call last):
  File "/home/bro/programmer/pystuff/python-ifcfg/src/ifcfg/__init__.py", line 57, in get_parser
    return Parser(ifconfig=ifconfig)
  File "/home/bro/programmer/pystuff/python-ifcfg/src/ifcfg/parser.py", line 30, in __init__
    self.parse(self.ifconfig_data)
  File "/home/bro/programmer/pystuff/python-ifcfg/src/ifcfg/parser.py", line 92, in parse
    self._interfaces[cur][k]
RuntimeError: Tried to add broadcast=192.168.0.255 multiple times to enp11s0, it was already: 172.16.3.255
@benjaoming
Copy link
Collaborator

Ah yeah, after we added support for multiple IP addresses per interface, we didn't do anything about the remaining interface properties, that are also per IP binding.

@benjaoming
Copy link
Collaborator

I think this needs to be in a major release change, since basically we need to adapt the whole API to handle multiple bindings.

@benjaoming benjaoming changed the title Parsing ip output fails with virtual interface based on existing interface Support all properties (broadcase, netmask etc) for interfaces with multiple bindings Aug 10, 2018
jamalex added a commit to jamalex/kolibri that referenced this issue Sep 3, 2019
@jamalex
Copy link

jamalex commented Jun 10, 2020

I haven't been able to replicate this. When I ran sudo ifconfig wlp0s20f3:0 192.168.0.4 to create an alias, it ended up showing the alias and the primary interface separately in the output of ifcfg.interfaces(). Has this been resolved, or are additional steps needed to replicate?

...
  'wlp0s20f3': {'inet': '6.5.75.97',
  'inet4': ['6.5.75.97'],
  'ether': '0c:dd:24:37:a0:b8',
  'inet6': ['fe80::87a2:717e:18f:b687'],
  'netmask': '255.255.255.0',
  'device': 'wlp0s20f3',
  'flags': '4163<UP,BROADCAST,RUNNING,MULTICAST> ',
  'mtu': '1500',
  'broadcast': '6.5.75.255'},
 'wlp0s20f3:0': {'inet': '192.168.0.4',
  'inet4': ['192.168.0.4'],
  'ether': '0c:dd:24:37:a0:b8',
  'inet6': [],
  'netmask': '255.255.255.0',
  'device': 'wlp0s20f3:0',
  'flags': '4163<UP,BROADCAST,RUNNING,MULTICAST> ',
  'mtu': '1500',
  'broadcast': '192.168.0.255'}
...

@benjaoming
Copy link
Collaborator

@jamalex try on a system without net-tools (the package containing ifconfig). It's on default Unix-based systems for the past ~5 years that ifconfig hasn't been a standard utility.

Red Hat has made a nice cheat sheet for the new commands: https://access.redhat.com/sites/default/files/attachments/rh_ip_command_cheatsheet_1214_jcs_print.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants