因为院里的IP是固定的,所以要配置rc.conf来指定IP.没想到无论怎么修改都不能上网.rc.conf的IP配置文件如下:
lo="lo 127.0.0.1"
eth0="eth0 192.168.0.202 netmask 255.255.255.0 broadcast 192.168.0.255"
#eth0="dhcp"
INTERFACES=(lo eth0)
#
# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
# - prefix an entry in ROUTES with a ! to disable it
#
#gateway="192.168.0.254"
gateway="default gw 192.168.0.254"
ROUTES=(!gateway)
另外修改了/etc/resolv来添加了我们这里网通的DNS
应该没错吧?但是ping DNS和baidu外网都不通.ping DNS的时候提示unreach able,ping百度的时候就提示找不到主机.有些奇怪.
本来打算看看有没有图形界面下的网络配置工具,但是我用的系统太简单了,除了个小巧的xfce,别的什么也没有,不能比gnome下的复杂系统配置工具.
命令下有个netcfg,看起来就是network configure了.在/etc/network-profiles下有个模板的配置文件.打开看了:
#
# Network Profile
#
DESCRIPTION="Default Network Profile"
# Network Settings
INTERFACE=eth0
HOSTNAME=localhost
# Interface Settings (use IFOPTS="dhcp" for DHCP)
IFOPTS="192.168.0.202 netmask 255.255.255.0 broadcast 192.168.0.255"
GATEWAY=192.168.0.254
# DNS Settings (optional)
DOMAIN=localdomain
DNS1=202.102.128.68
DNS2=202.102.134.68
# Wireless Settings (optional)
#ESSID=default
#KEY=
#IWOPTS="mode managed essid $ESSID channel 6 key restricted $KEY"
#WIFI_INTERFACE=wlan0 # use this if you have a special wireless interface
# that is linked to the real $INTERFACE
#WIFI_WAIT=5 # seconds to wait for the wireless card to
# associate before bringing the interface up
#USEWPA="yes" # start wpa_supplicant with the profile
#WPAOPTS="" # use "" for normal operation or specify additional
# options (eg, "-D ipw")
# see /etc/wpa_supplicant.conf for configuration
#AUTOWPA="yes" # automatically configure WPA
#PASSKEY="" # wpa passkey/phrase. for use with AUTOWPA
看来就是这个了,可以用netcfg来加载自己的配置文件,只要你的network是通的.另外配置文件好像只能放到/etc/network-profile中来,无法指定位置.
sudo netcfg interfaces //我的配置文件名称
ping下外网,通了.
另外的是,当重启电脑后还是会无法通网络.可以写个脚本,加入后台进程.
touch /etc/rc.d/interfaces
脚本文件如下:
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
start)
stat_busy "Starting Network-profle Connection"
/usr/bin/netcfg interfaces &>/dev/null
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon interfaces
stat_done
fi
;;
stop)
stat_busy "Stopping Network-profile Connection"
/usr/bin/netcfg --stopall &>/dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon interfaces
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
ok