IPv6: Enable IPv6 address for router

This commit is contained in:
Sheng Yang 2013-01-24 20:09:37 -08:00
parent bd4bc025d1
commit 6169c1d724
3 changed files with 54 additions and 7 deletions

View File

@ -229,6 +229,23 @@ setup_interface() {
fi
}
setup_interface_ipv6() {
sysctl net.ipv6.conf.all.disable_ipv6=0
sysctl net.ipv6.conf.all.accept_ra=1
local intfnum=$1
local ipv6="$2"
local prelen="$3"
local intf=eth${intfnum}
echo "iface $intf inet6 static" >> /etc/network/interfaces
echo " address $ipv6 " >> /etc/network/interfaces
echo " netmask $prelen" >> /etc/network/interfaces
echo " accept_ra 1" >> /etc/network/interfaces
ifdown $intf
ifup $intf
}
enable_fwding() {
local enabled=$1
log_it "cloud: enable_fwding = $1"
@ -303,7 +320,14 @@ disable_hvc() {
setup_common() {
init_interfaces $1 $2 $3
setup_interface "0" $ETH0_IP $ETH0_MASK $GW
if [ -n "$ETH0_IP" ]
then
setup_interface "0" $ETH0_IP $ETH0_MASK $GW
fi
if [ -n "$ETH0_IP6" ]
then
setup_interface_ipv6 "0" $ETH0_IP6 $ETH0_IP6_PRELEN
fi
setup_interface "1" $ETH1_IP $ETH1_MASK $GW
if [ -n "$ETH2_IP" ]
then
@ -903,6 +927,9 @@ for i in $CMDLINE
gateway)
GW=$VALUE
;;
ip6gateway)
IP6GW=$VALUE
;;
eth0mask)
ETH0_MASK=$VALUE
;;
@ -912,6 +939,12 @@ for i in $CMDLINE
eth2mask)
ETH2_MASK=$VALUE
;;
eth0ip6)
ETH0_IP6=$VALUE
;;
eth0ip6prelen)
ETH0_IP6_PRELEN=$VALUE
;;
internaldns1)
internalNS1=$VALUE
;;

View File

@ -42,8 +42,8 @@ net.ipv4.tcp_max_tw_buckets=1000000
net.core.somaxconn=1000000
# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.all.forwarding = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.all.autoconf = 0

View File

@ -1886,11 +1886,25 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
String defaultDns2 = null;
for (NicProfile nic : profile.getNics()) {
int deviceId = nic.getDeviceId();
buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address());
buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask());
boolean ipv4 = false, ipv6 = false;
if (nic.getIp4Address() != null) {
ipv4 = true;
buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address());
buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask());
}
if (nic.getIp6Address() != null) {
ipv6 = true;
buf.append(" eth").append(deviceId).append("ip6=").append(nic.getIp6Address());
buf.append(" eth").append(deviceId).append("ip6prelen=").append(NetUtils.getIp6CidrSize(nic.getIp6Cidr()));
}
if (nic.isDefaultNic()) {
buf.append(" gateway=").append(nic.getGateway());
if (ipv4) {
buf.append(" gateway=").append(nic.getGateway());
}
if (ipv6) {
buf.append(" ip6gateway=").append(nic.getIp6Gateway());
}
defaultDns1 = nic.getDns1();
defaultDns2 = nic.getDns2();
}