ipv6如何设置开机自启动
-
- 帖子: 24
- 注册时间: 2009-04-17 20:21
- AngelMAX
- 帖子: 2228
- 注册时间: 2009-02-25 18:18
-
- 帖子: 24
- 注册时间: 2009-04-17 20:21
Re: ipv6如何设置开机自启动
sudo suAngelMAX 写了:你在哪里设置的,话说IPv6是默认开启的,一般都是问怎么关的,今天来个问怎么开的
/sbin/ip tunnel add sit1 mode sit ttl 128 remote 10.1.251.2 local 10.1.72.xx
/sbin/ifconfig sit1 up
/sbin/ifconfig sit1 add 2001:da8:6004:1004:0:5efe:10.1.72.xx
/sbin/route -A inet6 add 2000::/3 gw fe80::5efe:10.1.251.2 sit1
这是我的代码,每次开机都要自己重新配置!
大学被慢慢拆下来,拼凑在心里,然后物是人非.
-
- 帖子: 16
- 注册时间: 2009-03-31 19:26
Re: ipv6如何设置开机自启动
我也不知道,不过我是把它存在txt当中,开机时双击,在终端中运行,我试过添加到启动程序中,但是没有成功。
-
- 帖子: 101
- 注册时间: 2006-06-24 20:03
Re: ipv6如何设置开机自启动
代码: 全选
#!/bin/sh
#
# $Id: linux.sh,v 1.19 2007/12/07 19:23:10 cnepveu Exp $
#
# This source code copyright (c) Hexago Inc. 2002-2006.
#
# LICENSE NOTICE: You may use and modify this source code only if you
# have executed a valid license agreement with Hexago Inc. granting
# you the right to do so, the said license agreement governing such
# use and modifications. Copyright or other intellectual property
# notices are not to be removed from the source code.
#
# Note: IPV6 support and tun Support must be enabled before calling this script.
#
LANGUAGE=C
if [ -z $TSP_VERBOSE ]; then
TSP_VERBOSE=0
fi
KillProcess()
{
if [ ! -z $TSP_VERBOSE ]; then
if [ $TSP_VERBOSE -ge 2 ]; then
echo killing $*
fi
fi
PID=`ps axww | grep $1 | grep -v grep | awk '{ print $1;}'`
echo $PID
if [ ! -z $PID ]; then
kill $PID
fi
}
Display()
{
if [ -z $TSP_VERBOSE ]; then
return;
fi
if [ $TSP_VERBOSE -lt $1 ]; then
return;
fi
shift
echo "$*"
}
Exec()
{
if [ ! -z $TSP_VERBOSE ]; then
if [ $TSP_VERBOSE -ge 2 ]; then
echo $*
fi
fi
$* # Execute command
if [ $? -ne 0 ]; then
echo "Error while executing $1"
echo " Command: $*"
exit 1
fi
}
ExecNoCheck()
{
if [ ! -z $TSP_VERBOSE ]; then
if [ $TSP_VERBOSE -ge 2 ]; then
echo $*
fi
fi
$* # Execute command
}
# Program localization
Display 1 "--- Start of configuration script. ---"
Display 1 "Script: " `basename $0`
ifconfig=/sbin/ifconfig
route=/sbin/route
ipconfig=/sbin/ip
rtadvd=/usr/sbin/radvd
rtadvd_pid=/var/run/radvd/radvd.pid
sysctl=/sbin/sysctl
rtadvdconfigfilename=gw6c-rtadvd.conf
rtadvdconfigfile=$TSP_HOME_DIR/$rtadvdconfigfilename
if [ -z $TSP_HOME_DIR ]; then
echo "TSP_HOME_DIR variable not specified!;"
exit 1
fi
if [ ! -d $TSP_HOME_DIR ]; then
echo "Error : directory $TSP_HOME_DIR does not exist"
exit 1
fi
#
if [ -z $TSP_HOST_TYPE ]; then
echo Error: TSP_HOST_TYPE not defined.
exit 1
fi
#############################################################################
# Tunnel destruction script.
#
# Is invoked by the Gateway6 Client on shutdown when it receives the
# SIGHUP signal. Use "kill -HUP <gw6c pid>".
#
if [ X"${TSP_OPERATION}" = X"TSP_TUNNEL_TEARDOWN" ]; then
Display 1 Tunnel tear down starting...
# Router deconfiguration.
if [ X"${TSP_HOST_TYPE}" = X"router" ]; then
# Kill router advertisement daemon
KillProcess $rtadvdconfigfile
# Remove prefix routing on TSP_HOME_INTERFACE
ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN
# Remove Blackhole.
if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN dev lo
fi
# Remove address from TSP HOME INTERFACE
ExecNoCheck $ifconfig $TSP_HOME_INTERFACE inet6 del $TSP_PREFIX::1/64
fi
# Delete default IPv6 route(s).
ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete default route
ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null # delete gw route
# Destroy tunnel interface
if [ -x $ipconfig ]; then
# Delete tunnel via ipconfig
ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
else
# Check if interface exists and remove it
$ifconfig $TSP_TUNNEL_INTERFACE >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
Delete interface IPv6 configuration.
PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
if [ ! -z $OLDADDR ]; then
ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE inet6 del $OLDADDR
fi
# Bring interface down
ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE down
fi
fi
Display 1 Tunnel tear down completed.
exit 0
fi
#############################################################################
# Tunnel creation script.
#
if [ X"${TSP_HOST_TYPE}" = X"host" ] || [ X"${TSP_HOST_TYPE}" = X"router" ]; then
# Set tunnel IPv6 configuration
Display 1 "$TSP_TUNNEL_INTERFACE setup"
if [ X"${TSP_TUNNEL_MODE}" = X"v6v4" ]; then
Display 1 "Setting up link to $TSP_SERVER_ADDRESS_IPV4"
if [ -x $ipconfig ]; then
ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
ExecNoCheck sleep 1
Exec $ipconfig tunnel add $TSP_TUNNEL_INTERFACE mode sit ttl 64 remote $TSP_SERVER_ADDRESS_IPV4
else
Exec $ifconfig $TSP_TUNNEL_INTERFACE tunnel ::$TSP_SERVER_ADDRESS_IPV4
fi
fi
Exec $ifconfig $TSP_TUNNEL_INTERFACE up
# Clean-up old interface IPv6 configuration.
PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
if [ ! -z $OLDADDR ]; then
Display 1 "Removing old IPv6 address $OLDADDR"
Exec $ifconfig $TSP_TUNNEL_INTERFACE inet6 del $OLDADDR
fi
Display 1 "This host is: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN"
Exec $ifconfig $TSP_TUNNEL_INTERFACE add $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN
Exec $ifconfig $TSP_TUNNEL_INTERFACE mtu 1280
#
# Default route
Display 1 "Adding default route"
ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete old default route
ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null # delete old gw route
Exec $route -A inet6 add ::/0 dev $TSP_TUNNEL_INTERFACE
Exec $route -A inet6 add 2000::/3 dev $TSP_TUNNEL_INTERFACE
fi
# Router configuration if required
if [ X"${TSP_HOST_TYPE}" = X"router" ]; then
Display 1 "Router configuration"
# Tell kernel to forward IPv6 traffic.
Exec $sysctl -w net.ipv6.conf.all.forwarding=1
# Blackholing on interface lo, if prefixlen is not 64.
if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
# Sometimes this route does not show when using 'netstat -rn6'.
ExecNoCheck $route -A inet6 add $TSP_PREFIX::/$TSP_PREFIXLEN dev lo 2>/dev/null
fi
# Add prefix::1 on advertising interface. Clean up before.
OLDADDR=`$ifconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
if [ ! -z $OLDADDR ]; then
Display 1 "Removing old IPv6 address $OLDADDR"
Exec $ifconfig $TSP_HOME_INTERFACE inet6 del $OLDADDR
fi
Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
# Stop radvd daemon if it was running. Twice.
/etc/init.d/radvd stop
if [ -f $rtadvdconfigfile ]; then
KillProcess $rtadvdconfigfile
fi
# Create new radvd configuration file.
cat > "$rtadvdconfigfile" <<EOF
##### rtadvd.conf made by Gateway6 Client ####
interface $TSP_HOME_INTERFACE
{
AdvSendAdvert on;
prefix $TSP_PREFIX::/64
{
AdvOnLink on;
AdvAutonomous on;
};
};
EOF
# Start the radvd daemon.
Display 1 "Starting radvd: $rtadvd -u radvd -C $rtadvdconfigfile"
Exec $rtadvd -u radvd -p $rtadvd_pid -C $rtadvdconfigfile
fi
Display 1 "--- End of configuration script. ---"
exit 0
#---------------------------------------------------------------------
-
- 帖子: 56
- 注册时间: 2007-07-05 12:51
Re: ipv6如何设置开机自启动
把/etc/rc.local中第一句: #!/bin/shljmaing 写了:我配置好了IPV6,但是每次开机都要重新配置才能用,有什么方法可以设置开机自启动阿~谢谢各位大虾了~
改成这样:#!/bin/bash
当然把系统初始的那些行都删除也行
然后在该文件末尾追加你要自动启动的脚本或命令
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: ipv6如何设置开机自启动
不明白。
sudo -s 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
这才叫开关ipv6吧。
你改这文件吧。
● g ipv6 /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 0
sudo -s 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
这才叫开关ipv6吧。
你改这文件吧。
● g ipv6 /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 0
● 鸣学
-
- 帖子: 7
- 注册时间: 2009-10-30 9:15
Re: ipv6如何设置开机自启动
嘿嘿 看这ip,楼主,我们应该是校友吧ljmaing 写了: sudo su
/sbin/ip tunnel add sit1 mode sit ttl 128 remote 10.1.251.2 local 10.1.72.xx
/sbin/ifconfig sit1 up
/sbin/ifconfig sit1 add 2001:da8:6004:1004:0:5efe:10.1.72.xx
/sbin/route -A inet6 add 2000::/3 gw fe80::5efe:10.1.251.2 sit1
这是我的代码,每次开机都要自己重新配置!