Difference between revisions of "Disable venet interface"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(added category)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
If you have configure [[veth]] correctly and want to get rid of [[venet]] interface modify ''/etc/init.d/vz'' following this step:
+
If you have configured [[veth]] correctly and want to get rid of [[venet]] interface modify ''/etc/init.d/vz'' following this step:
 +
 
 +
'''Note: In Debian systems (Ubuntu and more) for disable venet interface it's enough with the next second step'''(Comment line ''VZDEV=venet0'' (~ line 53).).'''
 +
'''Don't forget edit (in Debian example) /etc/network/interface file in (/var/lib/vz/private/$VEID/ and remove venet configuration in that file'''
 +
 
  
 
1. /etc/init.d/vz stop before going further.
 
1. /etc/init.d/vz stop before going further.
Line 63: Line 67:
  
 
The start_net function should look like this:
 
The start_net function should look like this:
<code>start_net()
+
<source lang="bash">
 +
start_net()
 
{
 
{
 
         local mod
 
         local mod
Line 106: Line 111:
 
         # 2009-10-29 Michael Plourde
 
         # 2009-10-29 Michael Plourde
 
         ###################################
 
         ###################################
}</code>
+
}</source>
  
 
5. Modify the stop_net function (~ line 351) to look like this:
 
5. Modify the stop_net function (~ line 351) to look like this:
<code>stop_net()
+
 
 +
<source lang="bash">
 +
stop_net()
 
{
 
{
 
         local mod
 
         local mod
Line 133: Line 140:
 
                 /sbin/modprobe -r ${mod} > /dev/null 2>&1
 
                 /sbin/modprobe -r ${mod} > /dev/null 2>&1
 
         done
 
         done
}</code>
+
}</source>
  
 
6. That's all. You can now start your VEs:''/etc/init.d/vz start''
 
6. That's all. You can now start your VEs:''/etc/init.d/vz start''
 +
 +
[[Category:HOWTO]]

Latest revision as of 06:31, 7 June 2015

If you have configured veth correctly and want to get rid of venet interface modify /etc/init.d/vz following this step:

Note: In Debian systems (Ubuntu and more) for disable venet interface it's enough with the next second step(Comment line VZDEV=venet0 (~ line 53).). Don't forget edit (in Debian example) /etc/network/interface file in (/var/lib/vz/private/$VEID/ and remove venet configuration in that file


1. /etc/init.d/vz stop before going further.

2. Comment line VZDEV=venet0 (~ line 53).

3. Replace line NET_MODULES="${VNET_MODULES} ${VETH_MODULES}" (~ line 67) with this block:

       ####################################
       # Patch for disable venet interface
       # Block 1
       # 2009-10-29 Michael Plourde
       ###################################
       NET_MODULES="${VETH_MODULES}"
       if [ -n "${VZDEV}" ]
       then
               NET_MODULES="${NET_MODULES} ${VNET_MODULES}"
       fi
       ####################################
       #  Patch for disable venet interface
       #  End Block 1
       #  2009-10-29 Michael Plourde
       ###################################

4. In the start_net() function (~ line 306) find those lines:

               __echo "Bringing up interface $VZDEV: "
               ip link set $VZDEV up
               print_result
               ip addr add 0.0.0.0/0 dev $VZDEV
               __echo "Configuring interface $VZDEV: "
               sysctl -q -w net.ipv4.conf.$VZDEV.send_redirects=0
               print_result
               if [ "${IPV6}" = "yes" ]; then
                       __echo "Configuring ipv6 $VZDEV: "
                       # Fix me: ip addres should be generated
                       ip -6 addr add fe80::1/128 dev $VZDEV
                       print_result
               fi

and add these block before:

       ####################################
       # Patch for disable venet interface
       # Block 2
       # 2009-10-29 Michael Plourde
       ###################################
       if [ -n "$VZDEV" ]
       then

and this one after:

       fi
       ####################################
       # Patch for disable venet interface
       # End Block 2
       # 2009-10-29 Michael Plourde
       ###################################

The start_net function should look like this:

start_net()
{
        local mod

        # load all kernel modules needed for VE networking
        for mod in ${NET_MODULES}; do
                modprobe ${mod} 2>/dev/null
        done

        if ip addr list | grep -q "venet0:.*UP" 2>/dev/null; then
                return 0
        fi

        get_veinfo
        if [ -z "$VEINFO" ]; then
                return 0
        fi
        ####################################
        # Patch for disable venet interface
        # Block 2
        # 2009-10-29 Michael Plourde
        ###################################
        if [ -n "$VZDEV" ]
        then
                __echo "Bringing up interface $VZDEV: "
                ip link set $VZDEV up
                print_result
                ip addr add 0.0.0.0/0 dev $VZDEV
                __echo "Configuring interface $VZDEV: "
                sysctl -q -w net.ipv4.conf.$VZDEV.send_redirects=0
                print_result
                if [ "${IPV6}" = "yes" ]; then
                        __echo "Configuring ipv6 $VZDEV: "
                        # Fix me: ip addres should be generated
                        ip -6 addr add fe80::1/128 dev $VZDEV
                        print_result
                fi
        fi
        ####################################
        # Patch for disable venet interface
        # End Block 2
        # 2009-10-29 Michael Plourde
        ###################################
}

5. Modify the stop_net function (~ line 351) to look like this:

stop_net()
{
        local mod
        ####################################
        # Patch for disable venet interface
        # Block 3
        # 2009-10-29 Michael Plourde
        ###################################
        if [ -n "$VZDEV" ]
        then
                if ip addr list | grep -q "venet0:.*UP" 2>/dev/null; then
                        __echo "Bringing down interface $VZDEV: "
                        ip link set $VZDEV down
                        print_result
                fi
        fi
        ####################################
        # Patch for disable venet interface
        # End Block 3
        # 2009-10-29 Michael Plourde
        ###################################
        for mod in ${NET_MODULES}; do
                /sbin/modprobe -r ${mod} > /dev/null 2>&1
        done
}

6. That's all. You can now start your VEs:/etc/init.d/vz start