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

default network example does not work on RHEL #58

Closed
KlavsKlavsen opened this issue Sep 9, 2013 · 11 comments
Closed

default network example does not work on RHEL #58

KlavsKlavsen opened this issue Sep 9, 2013 · 11 comments

Comments

@KlavsKlavsen
Copy link

If I do:

    network_route { '10.0.0.0/8':
      ensure    => 'present',
      gateway   => '192.168.63.1',
      interface => 'eth0',
      netmask   => '8',
      network   => '10.0.0.0'
    }
    network_route { '192.168.0.0/16':
      ensure    => 'present',
      gateway   => '192.168.63.1',
      interface => 'eth0',
      netmask   => '16',
      network   => '192.168.0.0'
    }
    network_route { 'default':
      ensure    => 'present',
      gateway   => '192.168.63.50',
      interface => 'eth0',
      netmask   => '',
      network   => 'default'
    }

I get this in /etc/sysconfig/network-scripts/route-eth0:

10.0.0.0/255.0.0.0 via 192.168.63.1 dev eth0
192.168.0.0/255.255.0.0 via 192.168.63.1 dev eth0
default via 192.168.63.50 dev eth0

Which doesn't actually work :(

The only valid format for that file, that I know of, is:

GATEWAY1=192.168.63.1
ADDRESS1=192.168.0.0
NETMASK1=255.255.0.0

GATEWAY2=192.168.63.1
ADDRESS2=10.0.0.0
NETMASK2=255.0.0.0

and unlike what I'd normally expect (like what firewall module does) - the routes are NOT setup at puppet agent runtime - but one needs to reboot (or reload networking).

The resulting routes, after reboot, looks like this:

192.168.63.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
192.168.0.0     192.168.63.1    255.255.0.0     UG    0      0        0 eth0
10.0.0.0        192.168.63.1    255.0.0.0       UG    0      0        0 eth0
0.0.0.0         192.168.63.1    0.0.0.0         UG    0      0        0 eth0

As far as I can see, the conclusions seem to be:

  1. one cannot set default gw in routes-ethX (it's set in the ifcfg-ethX file)
  2. ip commands like the ones used, does not work, and should probably use the officially supported format (or may it's just done wrongly in the module example or something - and is actually supported) ?
  3. changes are not enacted on puppet run - one must reboot to update routes :(
@KlavsKlavsen
Copy link
Author

I had to, manually, remove GATEWAY setting in /etc/sysconfig/network-scripts/ifcfg-ethX - and then the default network_route works as expected.
Setting the ip for eth0 interface with network_config - didn't even remove the GATEWAY setting.

Oddly enough, the other routes now works as well:

192.168.63.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
192.168.0.0     192.168.63.1    255.255.0.0     UG    0      0        0 eth0
10.0.0.0        192.168.63.1    255.0.0.0       UG    0      0        0 eth0
0.0.0.0         192.168.63.50   0.0.0.0         UG    0      0        0 eth0

(I rebooted once more).

@adrienthebo
Copy link
Member

Thanks for reporting this!

Looking at https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-networkscripts-static-routes.html , it seems like the format for the routes should be valid; if I'm understanding you correctly then the routes did start working?

The documentation also says that you can add a default route of the format default via X.X.X.X dev interface; is the problem that GATEWAY was added to the file and then not removed later? Were you managing the interface file with the network_config type?

With respect to not applying the configuration immediately, I've left that up to users to handle. Restarting networking is something that you can't get wrong - if Puppet was restarting the network each time a route was updated it's entirely possible that the machine could get knocked offline. Since it's a bit risky, I've opted to not manage that and let end users do what best suits them. Does that make sense?

@gwarf
Copy link

gwarf commented Nov 15, 2013

Hi,
The format is not valid, when using IP commands arguments format, the netmask should be specified using CIDR notation:

10.8.0.0/24 via 172.20.8.1 dev eth1

Instead of

10.8.0.0/255.255.255.0 via 172.20.8.1 dev eth1

If not the network init script returns an error:

Bringing up interface eth1:  Error: an inet prefix is expected rather than "10.8.0.0/255.255.255.0".
Error: an inet prefix is expected rather than "10.8.1.0/255.255.255.0".

And the module is always removing the CIDR notation from the route, even when setting netmask to 24.

@gwarf
Copy link

gwarf commented Nov 19, 2013

Hi,
I managed to get this working using the changes mentionned in #58.

@confiq
Copy link

confiq commented Mar 10, 2015

I can confirm it's working well...
It's been one year and half and nobody merge this

@adrienthebo
Copy link
Member

@confiq if the pull request worked for you, could you update the pull request with tests and rebase it so that it can be merged?

@confiq
Copy link

confiq commented Mar 10, 2015

@adrienthebo: are we talking about PR #62 ?
It's not mine PR so I can't rebase it but if needed I can make new PR.
About tests, It passes all tests so I don't see a problem merging it. Unless you want to write tests for new check new CIDR notations

CC @gwarf

@adrienthebo
Copy link
Member

A new PR would be fine; I'm fine with merging code to fix this issue but the existing PR has merge conflicts. Since there is a behavior change, it does need tests before it gets merged.

@adrienthebo
Copy link
Member

And if @gwarf is willing to continue working it then superb, but if that doesn't work out I'm happy to accept PRs from other locations.

@confiq
Copy link

confiq commented Mar 12, 2015

Ok,
I've been using HEAD version and it's working fine.
I can't confirm this bug anymore.

@igalic
Copy link
Contributor

igalic commented Mar 12, 2015

okay, thank you @confiq!

@igalic igalic closed this as completed Mar 12, 2015
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

5 participants