[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Interface configuration - inet6 issues



On Fri, Nov 4, 2011 at 7:59 AM, Ivan Shmakov <ivan@gray.siamics.net> wrote:
>>>>>> Axton  <axton.grams@gmail.com> writes:
>
>        (Please also consider joining the news:comp.os.linux.networking
>        and news:alt.os.linux.debian Usenet newsgroups.  In particular,
>        these are available via the free http://Aioe.org/ service, as
>        well as through http://groups.google.com/.)
>
>  > To add to this, the following results in a /etc/network/run/ifstate
>  > that does not show eth1:
>
>        There's a generic reason of ifstate not being updated after an
>        ifup(8) invocation due to a failed pre-up or post-up command.
>        Thus, I'd try to debug this problem by running ifup(8) with
>        --verbose, like:
>
> # ifup -v eth1
>
>        Such a command would likely to point out the failed command.
>
>        Please note that it may be necessary to manually deconfigure the
>        now-misconfigured interface before invoking ifup(8) (as in:
>        # ip addr del.)
>
>  > root@ntp01:/# cat /etc/network/interfaces
>  > auto lo
>  > iface lo inet loopback
>
>  > auto eth1
>
>  > iface eth1 inet static
>  > address 10.0.4.240
>  > netmask 255.255.252.0
>  > broadcast 10.0.7.255
>
>        There's little point in specifying a broadcast address
>        coinciding with the one that'd be the default for this
>        configuration.
>
>  > gateway 10.0.4.1
>
>  > iface eth1 inet6 static
>  > address 2001:740:7063:10::240
>  > netmask 64
>  > gateway 2001:740:7063:10::10
>  > pre-up echo 0 > /proc/sys/net/ipv6/conf/eth1/autoconf
>  > pre-up echo 0 > /proc/sys/net/ipv6/conf/eth1/accept_ra
>
>        Why not to use # sysctl -w here instead?  Also, using explicit
>        interface names in these commands may lead to hard to debug
>        issues when fragments are moved or copied between different
>        iface stanzas, especially if the interface names look similar.
>
>        Thus:
>
>    pre-up sysctl -w net.ipv6.conf."$IFACE".accept_ra=0
>
>  > root@ntp01:/# cat /etc/network/run/ifstate
>  > lo=lo
>
>  > The interfaces are configured as follows with the above
>  > configuration:
>
>        Then it's my guess that the interface wasn't correctly
>        deconfigured before invoking ifup(8).  (It might've been a
>        failed pre-up command, but then the interface wouldn't have been
>        assigned the addresses.)
>
> […]
>
> --
> FSF associate member #7257

Thanks for the reply.  I was able to get this all working.  The issue,
and what I failed to mention in my original post, is that this machine
is an OpenVZ container.  In order to manipulate the routes in the
container it requires the following capabilities:

vzctl set CTID --capability net_admin:on --save

ip resulted in errors without this capability.

I appreciate the feedback on using the $IFACE variable and sysctl.  I
was not aware of the IFACE variable and will incorporate it into the
interfaces file.  With the changes, I am able to ifup and ifdown any
interface and the state of the interfaces are properly reflected in
ifstate.

This is the final interfaces file:

root@ntp01:/# cat /etc/network/interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo eth1 eth2 eth3 eth4

iface lo inet loopback

iface eth1 inet static
        address 10.0.4.240
        netmask 255.255.252.0
        broadcast 10.0.7.255
        post-up ip route add table 100 to 10.0.4.0/22 dev eth1
        post-up ip route add table 100 to default via 10.0.4.1 dev eth1
        post-up ip rule add from 10.0.4.0/22 table 100 priority 100
        post-up ip route flush cache
        pre-down ip route del table 100 to 10.0.4.0/22 dev eth1
        pre-down ip rule del from 10.0.4.0/22 table 100 priority 100
        pre-down ip route flush cache

iface eth1 inet6 static
        address 2001:xxxx:xxxx:10::240
        netmask 64
        pre-up echo 0 > /proc/sys/net/ipv6/conf/eth1/autoconf
        pre-up echo 0 > /proc/sys/net/ipv6/conf/eth1/accept_ra
        post-up ip -6 route add table 100 to 2001:xxxx:xxxx:10::/64 dev eth1
        post-up ip -6 route add table 100 to default via
2001:xxxx:xxxx:10::10 dev eth1
        post-up ip -6 rule add from 2001:xxxx:xxxx:10::/64 table 100
priority 100
        post-up ip -6 route flush cache
        pre-down ip -6 rule del from 2001:xxxx:xxxx:10::/64 table 100
priority 100
        pre-down ip -6 route flush cache

iface eth2 inet static
        address 10.0.0.240
        netmask 255.255.252.0
        broadcast 10.0.3.255
        post-up ip route add table 200 to 10.0.0.0/22 dev eth2
        post-up ip route add table 200 to default via 10.0.0.1 dev eth2
        post-up ip rule add from 10.0.0.0/22 table 200 priority 200
        post-up ip route flush cache
        pre-down ip rule del from 10.0.0.0/22 table 200 priority 200
        pre-down ip route flush cache

iface eth2 inet6 static
        address 2001:xxxx:xxxx:20::240
        netmask 64
        pre-up echo 0 > /proc/sys/net/ipv6/conf/eth2/autoconf
        pre-up echo 0 > /proc/sys/net/ipv6/conf/eth2/accept_ra
        post-up ip -6 route add table 200 to 2001:xxxx:xxxx:20::/64 dev eth2
        post-up ip -6 route add table 200 to default via
2001:xxxx:xxxx:20::10 dev eth2
        post-up ip -6 rule add from 2001:xxxx:xxxx:20::/64 table 200
priority 200
        post-up ip -6 route flush cache
        pre-down ip -6 rule del from 2001:xxxx:xxxx:20::/64 table 200
priority 200
        pre-down ip -6 route flush cache

iface eth3 inet static
        address 10.0.16.240
        netmask 255.255.252.0
        broadcast 10.0.19.255
        post-up ip route add table 300 to 10.0.16.0/22 dev eth3
        post-up ip route add table 300 to default via 10.0.16.1 dev eth3
        post-up ip rule add from 10.0.16.0/22 table 300 priority 300
        post-up ip route flush cache
        pre-down ip rule del from 10.0.16.0/22 table 300 priority 300
        pre-down ip route flush cache

iface eth3 inet6 static
        address 2001:xxxx:xxxx:30::240
        netmask 64
        pre-up echo 0 > /proc/sys/net/ipv6/conf/eth3/autoconf
        pre-up echo 0 > /proc/sys/net/ipv6/conf/eth3/accept_ra
        post-up ip -6 route add table 300 to 2001:xxxx:xxxx:30::/64 dev eth3
        post-up ip -6 route add table 300 to default via
2001:xxxx:xxxx:30::10 dev eth3
        post-up ip -6 rule add from 2001:xxxx:xxxx:30::/64 table 300
priority 300
        post-up ip -6 route flush cache
        pre-down ip -6 rule del from 2001:xxxx:xxxx:30::/64 table 300
priority 300
        pre-down ip -6 route flush cache

iface eth4 inet static
        address 10.0.20.240
        netmask 255.255.252.0
        broadcast 10.0.23.255
        gateway 10.0.20.1
        post-up ip route add table 400 to 10.0.20.0/22 dev eth4
        post-up ip route add table 400 to default via 10.0.20.1 dev eth4
        post-up ip rule add from 10.0.20.0/22 table 400 priority 400
        post-up ip route flush cache
        pre-down ip route del table 400 to 10.0.20.0/22 dev eth4
        pre-down ip route del table 400 to default via 10.0.20.1 dev eth4
        pre-down ip rule del from 10.0.20.0/22 table 400 priority 400
        pre-down ip route flush cache

iface eth4 inet6 static
        address 2001:xxxx:xxxx:40::240
        netmask 64
        gateway 2001:xxxx:xxxx:40::10
        pre-up echo 0 > /proc/sys/net/ipv6/conf/eth4/autoconf
        pre-up echo 0 > /proc/sys/net/ipv6/conf/eth4/accept_ra
        post-up ip -6 route add table 400 to 2001:xxxx:xxxx:40::/64 dev eth4
        post-up ip -6 route add table 400 to default via
2001:xxxx:xxxx:40::10 dev eth4
        post-up ip -6 rule add from 2001:xxxx:xxxx:40::/64 table 400
priority 400
        post-up ip -6 route add default via 2001:xxxx:xxxx:40::10 metric 0
        post-up ip -6 route flush cache
        pre-down ip -6 rule del from 2001:xxxx:xxxx:40::/64 table 400
priority 400
        pre-down ip -6 route flush cache

Thanks,
Axton Grams


Reply to: