Solaris 10 X86安装备忘


1. 系统环境


HW:

    CPU AMD Athlon 2000+

    MEM 512M

    DISK 120G

    NIC 主板集成的VIA网卡


SW:

    OS Solaris 10 x86 GA 版

    App vpn3000 client 分别来自两个开源项目:  

        - Virtual tunnel from http://vtun.sourceforge.net/

        - VPNC from http://www.unix-ag.uni-kl.de/~massar/vpnc/



2. Solaris 10 X86的安装


关于Solaris的安装已有很多文章,这里不再赘述,只给出要点


2.1 关于硬盘分区


对于IDE硬盘,需要安装在单独的主分区上

另外,为和同一机器上的其他OS(winxp,linux)交换数据的便利,建议硬盘上至少再winxp留一个FAT32的逻辑驱动器

Solaris 10的新分区类型是Solaris2,其主分区号不再和Linux的swap冲突,所以不用担心会对Linux产生影响


2.2 关于硬件驱动


Solaris 10 X86对X86硬件的支持已经大大增强,安装过程中我的机器上只有网卡没有被检测出来。

对于不能正确识别的硬件,需要根据硬件的类型到SUN官方网站的HCL上去寻找是否有相关的Driver。

幸运的是VIA主板集成的网卡已经有第3方开发的driver,可以在HCL里找到并下载:

http://www.sun.com/bigadmin/hcl/



2.3 关于Xwindow


建议选择Xorg作为默认的Xserver,并且选择JDS作为默认桌面


2.4 关于FAT32的mount


安装完毕后,在/etc/vfstab增加一行自动mount winxp下FAT32逻辑驱动器的设置


/dev/dsk/c0d0p0:c       -       /winxp  pcfs    2       yes     -



3. 环境设置及应用软件安装


可以将root的默认shell改成bash


# vi /etc/passwd


root:x:0:0:Super-User:/:/usr/bin/bash



Solaris已经自带了一些开源软件,例如mozilla,gcc

如果需要使用,最好将 /usr/sfw/bin加到环境变量PATH里。


这是我的/etc/profile增加的设置:


PATH=$PATH:/usr/sfw/bin:/opt/csw/bin:/usr/ccs/bin:$PATH;

export PATH


EDITOR=/opt/sfw/bin/vim

export EDITOR


PS1="/h:/w#"

export PS1



另外,还有以下途径可以获得各种开源社区软件


1. Solaris的Companion CD 


​ ​


按照安装好所有软件后,设置bash的工作环境:


cat /.bashrc


TERM=dtterm

export TERM


alias ls='/usr/local/bin/ls --color'

alias vi='/opt/sfw/bin/vim'


PS1="/h:/w#"

export PS1


这样,带颜色的ls和vim的语法高亮,Firefox,thounderbird,msn,qq,office,媒体播放就全都具备了。


4. ADSL的设置


4.1 Solaris DNS客户端设置


#cp /etc/nsswitch.dns /etc/nsswitch.conf


这是我的/etc/resolv.conf配置文件内容:


nameserver 202.106.46.151


4.2 ISP的配置文件


#cat /etc/ppp/peers/dialconf


sppptun

plugin pppoe.so

connect "/usr/lib/inet/pppoec rh0"  #我的网卡接口是rh0

persist

user "*adslname"          # 网通的account name总是*号开头的用户名,假定我的是*adslname

noauth                  # do not authenticate the ISP's identity (client)

noipdefault             # assume no IP address; get it from ISP

defaultroute            # install default route; ISP is Internet gateway

updetach                # log errors and CONNECT string to invoker

noccp

novj

noaccomp

nopcomp


4.3 用户验证文件

 

#cat /etc/ppp/chap-secrets


"*adslname"       *       "111111"



注意: "*adslname",*,"111111"之间使用了[TAB]而不是空格,这里假定口令是111111

如果你的isp需要相应设定 /etc/ppp/chat- secrets,内容格式相似


4.4 创建拨号Shell文件


#cat /opt/adsl


sppptun plumb pppoed rh0

sppptun plumb pppoe rh0

sppptun query

/usr/bin/pppd call dialconf

echo "Link Successfully..."


4.5 拨号测试


#/opt/adsl


rh0:pppoed

rh0:pppoe

rh0:pppoed

rh0:pppoe

Serial connection established.

Using interface sppp0

Connect: sppp0 <--> /dev/sppptun

Remote message: Welcome to use Quidway ROUTER, Huawei Tech.^M^J #呵呵,原来是华为的路由器

local  IP address 221.216.249.95

remote IP address 61.51.112.1

Link Successfully...



#ifconfig -a

lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

rh0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.80.1 netmask ffffff00 broadcast 192.168.80.255

        ether 0:c:6e:8b:d2:94

sppp0:flags=10010008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4,FIXEDMTU> mtu 1492 index 3



       inet 221.216.249.95 --> 61.51.112.1 netmask ffffff00




红色部分就是adsl建立的接口


#ping 216.239.53.9

216.239.53.9 is alive


#ping www.sina.com.cn      

www.sina.com.cn is alive


4.6 断开adsl


#pkill pppd


5. VPN3000的设置


编译过程略


5.1 VPN网关参数的配置


#cat default.conf


Interface name tun0

IPSec gateway 211.103.22.21 #这是VPN网关的地址

IPSec ID vpn3000            #这里是你的vpn group id

IPSec secret vpn3000        #这里是你的vpn group password  

Xauth username loginname    #这里是你的loginname

IKE DH Group dh2

Perfect Forward Secrecy nopfs


5.2 连接脚本的设置


#cat vpnc-connect


#!/usr/bin/ksh

#* VPNGATEWAY             -- vpn gateway address (always present)

#* TUNDEV                 -- tunnel device (always present)

#* INTERNAL_IP4_ADDRESS   -- address (always present)

#* INTERNAL_IP4_NETMASK   -- netmask (often unset)

#* INTERNAL_IP4_DNS       -- list of dns serverss

#* INTERNAL_IP4_NBNS      -- list of wins servers

#* CISCO_DEF_DOMAIN       -- default domain name

#* CISCO_BANNER           -- banner from server


defr=/var/run/vpnc/defaultroute

vpngateway=/var/run/vpnc/vpngateway

pid=/var/run/vpnc/pid


export LD_LIBRARY_PATH="`dirname $0`":$LD_LIBRARY_PATH


if [ -z "$VPNGATEWAY" ]; then

    if [ -x "`which vpnc`" ]; then

        VPNC="`which vpnc`"

    elif [ -x /usr/local/sbin/vpnc ]; then

        VPNC=/usr/sbin/vpnc

    elif [ -x /usr/sbin/vpnc ]; then

        VPNC=/usr/sbin/vpnc

    elif [ -x `dirname $0`/vpnc ]; then

        VPNC="`dirname $0`"/vpnc

        echo $VPNC

    else

        echo No vpnc daemon found, aborting...

        exit 1

    fi

   

    for i in "$gateway" "$defr" "$pid"; do

        mkdir -p "`dirname $i`"

    done

   

    PID="`cat "$pid" 2> /dev/null`"

   

    if [ "$PID" ]; then

        if kill -0 "$PID" > /dev/null 2>&1; then

            echo "vpnc found running (pid: $PID, pidfile: $pid)"

            exit 1

        fi

    fi

   

    exec "$VPNC" --udp --pid-file "$pid" --script "$0" "$@" || exit 1  #注意--udp指定了VPN的工作方式是udp

fi



ifconfig $TUNDEV inet $INTERNAL_IP4_ADDRESS /

    destination $INTERNAL_IP4_ADDRESS /

    netmask 255.255.255.255 mtu 1412 up


current_gateway=`netstat -rn | grep ^default| awk '{ print $2 }'`

echo $current_gateway > "$defr"

echo "$VPNGATEWAY" > "$vpngateway"


route add $VPNGATEWAY $current_gateway

route delete default $current_gateway

route add default $INTERNAL_IP4_ADDRESS -interface


# Takes care of DNS

if [ -f "/etc/resolv.conf" ]; then

    mv /etc/resolv.conf /etc/resolv.conf.saved-by-vpnc

fi


echo "# vpnc generated file" > /etc/resolv.conf

echo "search $CISCO_DEF_DOMAIN" >> /etc/resolv.conf

echo "$INTERNAL_IP4_DNS" /

 | awk '{for (i=1;i<=NF;i++)

    printf("nameserver %s/n", $i) }' >> /etc/resolv.conf

   

exit 0


5.2 连接测试


./vpnc-connect default.conf



# ifconfig -a


lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

rh0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.80.1 netmask ffffff00 broadcast 192.168.80.255

        ether 0:c:6e:8b:d2:94

sppp0: flags=10010008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4,FIXEDMTU> mtu 1492 index 3

        inet 221.216.249.95 --> 61.51.112.1 netmask ffffff00

tun0:flags=10010008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4,FIXEDMTU> mtu 1412 index 4



       inet 10.13.22.19 --> 10.13.22.19 netmask ffffffff




红色部分就是vpn建立的接口


5.3 断开连接


./vpnc-disconnect