LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1879|回复: 14

新装的slackware上不了网

[复制链接]
发表于 2007-2-2 01:52:36 | 显示全部楼层 |阅读模式
系统装好后,发现上不了网,用ping ping了一下本机的IP就通,但ping其他ip、网关等,都显示:“Destination Host Unreachable”。 用SSH服务也是这样,即到本机ip行,其他ip都不行。IP地址、掩码、网关、DNS在安装过程中是确认填写正确的。
        在安装过程中,到安装modem那步时,即:


选了/dev/ttys4,即PCI接口。而我的网线接在主板自带的网卡接口上。不知这是否有影响?

    另外,在到配置系统服务的那一步时,即:
http://www.linuxsir.cn/bbs/attac ... 33&d=1069842831

我把rc.pcmcia、rc.sendmail两个服务去掉了,其他默认的留下,这是否有影响?
发表于 2007-2-2 08:50:33 | 显示全部楼层
你用的adsl还是modem拨号上网?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-2-2 10:30:21 | 显示全部楼层
Post by d4rkl0rd
你用的adsl还是modem拨号上网?


我用的是ADSL,几台电脑连接到一个交换机,然后交换机连到ADSL Modem。系统是Slackware 11.0。之前我在自己台机器安装是没有这种问题的,但现在在另一台机器上(同一个局域网)就有这种问题。差别是我台机是IDE硬盘,独立网卡;现在这台机是sata硬盘,集成网卡。
回复 支持 反对

使用道具 举报

发表于 2007-2-2 11:11:20 | 显示全部楼层
IP地址,网关这些看看设置对了么
回复 支持 反对

使用道具 举报

发表于 2007-2-2 13:49:11 | 显示全部楼层
用dhcpd
回复 支持 反对

使用道具 举报

发表于 2007-2-2 14:20:45 | 显示全部楼层
试试把交换机的IP地址用route命令添加到路由表中
回复 支持 反对

使用道具 举报

发表于 2007-2-3 12:47:51 | 显示全部楼层
对, 把路由的地址或者dns的地址加到/etc/resolv.conf文件中
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-2-3 19:17:55 | 显示全部楼层
Post by windrose
试试把交换机的IP地址用route命令添加到路由表中

Post by euler
对, 把路由的地址或者dns的地址加到/etc/resolv.conf文件中


试过了,还是不行!
我在开机的过程,仔细的留意过启动过的东西,发现以下的一些信息:
在slackware启动过程,有以下字样:

  1. eth0: link down
复制代码


后面还有:


  1. cardmgr[134]: no pcmcia driver in /proc/devices
  2. /etc/rc.d/rc.inet1: line 1: eth_up: command not found
  3. /etc/rc.d/rc.inet1: line 2: eth_up: command not found
  4. /etc/rc.d/rc.inet1: line 256: eth_up: command not found
  5. Scanning all LUNs for additional hardware: /sbin/rescan-scsi-bus-l
复制代码


进去系统后,我编辑了:/etc/rc.d/rc.inet1文件,去掉了所有“eth_up”,上面代码中的:

  1. /etc/rc.d/rc.inet1: line 1: eth_up: command not found
  2. /etc/rc.d/rc.inet1: line 2: eth_up: command not found
  3. /etc/rc.d/rc.inet1: line 256: eth_up: command not found
复制代码

就再没有出现了,但是还是不行,ping不通网关、非本机IP的问题依然存在。
注:编辑/etc/rc.d/rc.inet1文件时,发现在
  1. #! /bin/sh
复制代码

语句前出现了4个"eth_up"命令,即如下:

  1. [indent]eth_up
  2. eth_up
  3. eth_up
  4. eth_up[/indent]
  5. #! /bin/sh
复制代码
回复 支持 反对

使用道具 举报

发表于 2007-2-3 19:59:56 | 显示全部楼层
ifconfig  先看下网卡能认出来么

然后贴你的IP地址、掩码、网关、DNS出来看看

猫开了路由功能后,比如说猫的IP地址为192.168.1.1,你本机的网关设成192.168.1.1,IP地址192.168.1.100等等。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-2-8 01:33:42 | 显示全部楼层
Post by xiaokang
ifconfig  先看下网卡能认出来么

然后贴你的IP地址、掩码、网关、DNS出来看看

猫开了路由功能后,比如说猫的IP地址为192.168.1.1,你本机的网关设成192.168.1.1,IP地址192.168.1.100等等。。。


Sorry,这几天一直没有空上linuxsir转。下面贴出那台机器的信息:

  1. [color="Red"]#ifconfig eth0[/color]
  2. eth0      Link encap:Ethernet  HWaddr 00:0A:EB:82:5F:58  
  3.           inet addr:192.168.1.15  Bcast:192.168.1.255  Mask:255.255.255.0
  4.           UP BROADCAST MULTICAST  MTU:1500  Metric:1
  5.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  6.           TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
  7.           collisions:0 txqueuelen:1000
  8.           RX bytes:0 (0.0 b)  TX bytes:720 (720.0 b)
  9.           Interrupt:10 Base address:0xd000


  10. [color="red"]#route -FC[/color]
  11. Kernel IP routing table
  12. Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
  13. localnet        *               255.255.255.0   U     0      0        0 eth0
  14. loopback        *               255.0.0.0       U     0      0        0 lo
  15. default         192.168.1.1     0.0.0.0         UG    1      0        0 eth0
  16. Kernel IP routing cache
  17. Source          Destination     Gateway         Flags Metric Ref    Use Iface
  18. slackware.gavin 202.96.134.133  192.168.1.1           0      0        0 eth0
  19. slackware.gavin 202.96.134.133  192.168.1.1           0      0        0 eth0
  20. slackware.gavin slackware.gavin slackware.gavin l     0      0        1 lo

  21. [color="red"]#route -n[/color]
  22. Kernel IP routing table
  23. Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
  24. 192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
  25. 127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
  26. 0.0.0.0         192.168.1.1     0.0.0.0         UG    1      0        0 eth0

复制代码


另外,文件夹\etc\rc.d下关于internet的文件内容如下:

  1. [color="red"]# vi rc.inet1[/color]
  2. #! /bin/sh
  3. # /etc/rc.d/rc.inet1
  4. # This script is used to bring up the various network interfaces.
  5. #
  6. # @(#)/etc/rc.d/rc.inet1 10.2  Sun Jul 24 12:45:56 PDT 2005  (pjv)

  7. ############################
  8. # READ NETWORK CONFIG FILE #
  9. ############################

  10. # Get the configuration information from /etc/rc.d/rc.inet1.conf:
  11. . /etc/rc.d/rc.inet1.conf

  12. ###########
  13. # LOGGING #
  14. ###########

  15. # If possible, log events in /var/log/messages:
  16. if [ -f /var/run/syslogd.pid -a -x /usr/bin/logger ]; then
  17.   LOGGER=/usr/bin/logger
  18. else # output to stdout/stderr:
  19.   LOGGER=/bin/cat
  20. fi

  21. ############################
  22. # DETERMINE INTERFACE LIST #
  23. ############################

  24. # Compose a list of interfaces from /etc/rc.d/rc.inet1.conf (with a maximum
  25. # of 6 interfaces, but you can easily enlarge the interface limit
  26. # - send me a picture of such a box :-).
  27. # If a value for IFNAME[n] is not set, we assume it is an eth'n' interface.
  28. # This way, the new script is compatible with older rc.inet1.conf files.
  29. # The IFNAME array will be used to determine which interfaces to bring up/down.
  30. MAXNICS=6
  31. i=0
  32. while [ $i -lt $MAXNICS ];
  33. do
  34.   IFNAME[$i]=${IFNAME[$i]:=eth${i}}
  35.   i=$(($i+1))
  36. done
  37. if [ "$DEBUG_ETH_UP" = "yes" ]; then
  38.   echo "/etc/rc.d/rc.inet1:  List of interfaces: '${IFNAME[@]}'" | $LOGGER
  39. fi

  40. ######################
  41. # LOOPBACK FUNCTIONS #
  42. ######################

  43. # Function to bring up the loopback interface.  If loopback is
  44. # already up, do nothing.
  45. lo_up() {
  46.   if grep lo: /proc/net/dev 1> /dev/null ; then
  47.     if ! /sbin/ifconfig | grep "^lo" 1> /dev/null ; then
  48.       echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig lo 127.0.0.1" | $LOGGER
  49.       /sbin/ifconfig lo 127.0.0.1
  50.       echo "/etc/rc.d/rc.inet1:  /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo" | $LOGGER
  51.       /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
  52.     fi
  53.   fi
  54. }

  55. # Function to take down the loopback interface:
  56. lo_down() {
  57.   if grep lo: /proc/net/dev 1> /dev/null ; then
  58.     echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig lo down" | $LOGGER
  59.     /sbin/ifconfig lo down
  60.   fi
  61. }

  62. #######################
  63. # INTERFACE FUNCTIONS #
  64. #######################

  65. # Function to bring up a network interface.  If the interface is
  66. # already up or does not yet exist (perhaps because the kernel driver
  67. # is not loaded yet), do nothing.
  68. if_up() {
  69.   # Determine position 'i' of this interface in the IFNAME array:
  70.   i=0
  71.   while [ $i -lt $MAXNICS ]; do
  72.     [ "${IFNAME[$i]}" = "${1}" ] && break
  73.     i=$(($i+1))
  74.   done
  75.   # If the interface isn't in the kernel yet (but there's an alias for it in
  76.   # modules.conf), then it should be loaded first:
  77.   if ! grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then # no interface yet
  78.     if /sbin/modprobe -c | grep -w "alias ${1}" | grep -vw "alias ${1} off" > /dev/null ; then
  79.       echo "/etc/rc.d/rc.inet1:  /sbin/modprobe ${1}" | $LOGGER
  80.       /sbin/modprobe ${1}
  81.     fi
  82.   fi
  83.   if grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then # interface exists
  84.     if ! /sbin/ifconfig | grep -w "${1}" 1>/dev/null ||       ! /sbin/ifconfig ${1} | grep "inet addr" 1> /dev/null ; then # interface not up or not configured
  85.       if [ ! "${HWADDR[$i]}" = "" ]; then # Set hardware address _before_ the interface goes up:
  86.         echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig ${1} hw ether ${HWADDR[$i]}" | $LOGGER
  87.         /sbin/ifconfig ${1} hw ether ${HWADDR[$i]}
  88.       fi
  89.       if [ ! "${MTU[$i]}" = "" ]; then # Set MTU to something else than 1500
  90.         echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig ${1} mtu ${MTU[$i]}" | $LOGGER
  91.         /sbin/ifconfig ${1} mtu ${MTU[$i]}
  92.       fi
  93.       if [ -x /etc/rc.d/rc.wireless ]; then
  94.         . /etc/rc.d/rc.wireless ${1} start # Initialize any wireless parameters
  95.       fi
  96.       if [ "${USE_DHCP[$i]}" = "yes" ]; then # use DHCP to bring interface up
  97.         [ ${DHCP_HOSTNAME[$i]} ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
  98.         [ "${DHCP_KEEPRESOLV[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -R"
  99.         [ "${DHCP_KEEPNTP[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -N"
  100.         [ "${DHCP_KEEPGW[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -G"
  101.         [ ${DHCP_IPADDR[$i]} ] && DHCP_OPTIONS="$DHCP_OPTIONS -s ${DHCP_IPADDR[$i]}"
  102.         echo "/etc/rc.d/rc.inet1:  /sbin/dhcpcd -d -t ${DHCP_TIMEOUT[$i]:-60} ${DHCP_OPTIONS} ${1}" | $LOGGER
  103.         /sbin/dhcpcd -d -t ${DHCP_TIMEOUT[$i]:-60} ${DHCP_OPTIONS} ${1}
  104.       else # bring up interface using a static IP address
  105.         if [ ! "${IPADDR[$i]}" = "" ]; then # skip unconfigured interfaces
  106.           # Determine broadcast address from the IP address and netmask:
  107.           BROADCAST[$i]=`/bin/ipmask ${NETMASK[$i]} ${IPADDR[$i]}|cut -f1 -d' '`
  108.           # Set up the network card:
  109.           echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig ${1} ${IPADDR[$i]} broadcast ${BROADCAST[$i]} netmask ${NETMASK[$i]}" | $LOGGER
  110.           /sbin/ifconfig ${1} ${IPADDR[$i]} broadcast ${BROADCAST[$i]} netmask ${NETMASK[$i]}
  111.         else
  112.           if [ "$DEBUG_ETH_UP" = "yes" ]; then
  113.             echo "/etc/rc.d/rc.inet1:  ${1} interface is not configured in /etc/rc.d/rc.inet1.conf" | $LOGGER
  114.           fi
  115.         fi
  116.       fi
  117.     else
  118.       if [ "$DEBUG_ETH_UP" = "yes" ]; then
  119.         echo "/etc/rc.d/rc.inet1:  ${1} is already up, skipping" | $LOGGER
  120.       fi
  121.     fi
  122.   else
  123.     if [ "$DEBUG_ETH_UP" = "yes" ]; then
  124.       echo "/etc/rc.d/rc.inet1:  ${1} interface does not exist (yet)" | $LOGGER
  125.     fi
  126.   fi
  127. }

  128. # Function to take down a network interface:
  129. if_down() {
  130.   # Determine position 'i' of this interface in the IFNAME array:
  131.   i=0
  132.   while [ $i -lt $MAXNICS ]; do
  133.     [ "${IFNAME[$i]}" = "${1}" ] && break
  134.     i=$(($i+1))
  135.   done
  136.   if grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then
  137.     if [ "${USE_DHCP[$i]}" = "yes" ]; then
  138.       echo "/etc/rc.d/rc.inet1:  /sbin/dhcpcd -k -d ${1}" | $LOGGER
  139.       /sbin/dhcpcd -k -d ${1} 2> /dev/null || /sbin/ifconfig ${1} down
  140.       sleep 1
  141.     else
  142.       echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig ${1} down" | $LOGGER
  143.       /sbin/ifconfig ${1} down
  144.     fi
  145.     if [ -x /etc/rc.d/rc.wireless ]; then
  146.       . /etc/rc.d/rc.wireless ${1} stop # Kill wireless daemons if any.
  147.     fi
  148.   fi
  149. }

  150. #####################
  151. # GATEWAY FUNCTIONS #
  152. #####################

  153. # Function to bring up the gateway if there is not yet a default route:
  154. gateway_up() {
  155.   if ! /sbin/route -n | grep "^0.0.0.0" 1> /dev/null ; then
  156.     if [ ! "$GATEWAY" = "" ]; then
  157.       echo "/etc/rc.d/rc.inet1:  /sbin/route add default gw ${GATEWAY} metric 1" | $LOGGER
  158.       /sbin/route add default gw ${GATEWAY} metric 1 2>&1 | $LOGGER
  159.     fi
  160.   fi
  161. }

  162. # Function to take down an existing default gateway:
  163. gateway_down() {
  164.   if /sbin/route -n | grep "^0.0.0.0" 1> /dev/null ; then
  165.     echo "/etc/rc.d/rc.inet1:  /sbin/route del default" | $LOGGER
  166.     /sbin/route del default
  167.   fi
  168. }

  169. # Function to start the network:
  170. start() {
  171.   lo_up
  172.   for i in ${IFNAME[@]} ; do
  173.     if_up $i
  174.   done
  175.   gateway_up
  176. }

  177. # Function to stop the network:
  178. stop() {
  179.   gateway_down
  180.   for i in ${IFNAME[@]} ; do
  181.     if_down $i
  182.   done
  183.   lo_down
  184. }


  185. ############
  186. ### MAIN ###
  187. ############

  188. case "$1" in
  189. 'start') # "start" brings up all configured interfaces:
  190.   start
  191.   ;;
  192. 'stop') # "stop" takes down all configured interfaces:
  193.   stop
  194.   ;;
  195. 'restart') # "restart" restarts the network:
  196.   stop
  197.   start
  198.   ;;
  199. *_start) # Example: "eth1_start" will start the specified interface 'eth1'
  200.   INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
  201.   if_up $INTERFACE
  202.   gateway_up
  203.   ;;
  204. *_stop) # Example: "eth0_stop" will stop the specified interface 'eth0'
  205.   INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
  206.   if_down $INTERFACE
  207.   ;;
  208. *_restart) # Example: "wlan0_restart" will take 'wlan0' down and up again
  209.   INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
  210.   if_down $INTERFACE
  211.   sleep 1
  212.   if_up $INTERFACE
  213.   gateway_up
  214.   ;;
  215. 'up') # "up" does the same thing as "start"
  216.   start
  217.   ;;
  218. 'down') # "down" does the same thing as "stop"
  219.   stop
  220.   ;;
  221. *_up) # "*_up" does the same thing as "*_start"
  222.   INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
  223.   if_up $INTERFACE
  224.   gateway_up
  225.   ;;
  226. *_down) # "*_down" does the same thing as "*_stop"
  227.   INTERFACE=`echo $1 | /bin/cut -d '_' -f 1`
  228.   if_down $INTERFACE
  229.   ;;
  230. *) # The default is to bring up all configured interfaces:
  231.   lo_up
  232.   for i in ${IFNAME[@]} ; do
  233.     if_up $i
  234.   done
  235. #        eth_up 0
  236.   gateway_up
  237. esac

  238. # End of /etc/rc.d/rc.inet1
复制代码


  1. [color="red"]#vi rc.inet1.conf[/color]
  2. # /etc/rc.d/rc.inet1.conf
  3. #
  4. # This file contains the configuration settings for network interfaces.
  5. # If USE_DHCP[interface] is set to "yes", this overrides any other settings.
  6. # If you don't have an interface, leave the settings null ("").

  7. # You can configure network interfaces other than eth0,eth1... by setting
  8. # IFNAME[interface] to the interface's name. If IFNAME[interface] is unset
  9. # or empty, it is assumed you're configuring eth<interface>.

  10. # Several other parameters are available, the end of this file contains a
  11. # comprehensive set of examples.

  12. # =============================================================================

  13. # Config information for eth0:
  14. IPADDR[0]="192.168.1.15"
  15. NETMASK[0]="255.255.255.0"
  16. DHCP_HOSTNAME[0]=""

  17. # Config information for eth1:
  18. IPADDR[1]=""
  19. NETMASK[1]=""
  20. USE_DHCP[1]=""
  21. DHCP_HOSTNAME[1]=""

  22. # Config information for eth2:
  23. IPADDR[2]=""
  24. NETMASK[2]=""
  25. USE_DHCP[2]=""
  26. DHCP_HOSTNAME[2]=""

  27. # Config information for eth3:
  28. IPADDR[3]=""
  29. NETMASK[3]=""
  30. USE_DHCP[3]=""
  31. DHCP_HOSTNAME[3]=""

  32. # Default gateway IP address:
  33. GATEWAY="192.168.1.1"

  34. # Change this to "yes" for debugging output to stdout.  Unfortunately,
  35. # /sbin/hotplug seems to disable stdout so you'll only see debugging output
  36. # when rc.inet1 is called directly.
  37. DEBUG_ETH_UP="no"

  38. ## Example config information for wlan0.  Uncomment the lines you need and fill
  39. ## in your info.  (You may not need all of these for your wireless network)
  40. #IFNAME[4]="wlan0"
  41. #IPADDR[4]=""
  42. #NETMASK[4]=""
  43. #USE_DHCP[4]="yes"
  44. #DHCP_HOSTNAME[4]="icculus-wireless"
  45. #DHCP_KEEPRESOLV[4]="yes"
  46. #DHCP_KEEPNTP[4]="yes"
  47. #DHCP_KEEPGW[4]="yes"
  48. #DHCP_IPADDR[4]=""
  49. #WLAN_ESSID[4]=BARRIER05
  50. #WLAN_MODE[4]=Managed
  51. ##WLAN_RATE[4]="54M auto"
  52. ##WLAN_CHANNEL[4]="auto"
  53. ##WLAN_KEY[4]="D5AD1F04ACF048EC2D0B1C80C7"
  54. ##WLAN_IWPRIV[4]="AuthMode=WPAPSK EncrypType=TKIP WPAPSK=7B1ABEEB5D197741923ED26727569C365E31212096A0EAFAD563B268BAD01CAF TxRate=0"
  55. #WLAN_WPA[4]="wpa_supplicant"
  56. #WLAN_WPADRIVER[4]="ndiswrapper"

  57. ## Some examples of additional network parameters that you can use.
  58. ## Config information for wlan0:
  59. #IFNAME[4]="wlan0"              # Use a different interface name nstead of
  60.                                 # the default 'eth4'
  61. #HWADDR[4]="00:01:23:45:67:89"  # Overrule the card's hardware MAC address
  62. #MTU[4]=""                      # The default MTU is 1500, but you might need
  63.                                 # 1360 when you use NAT'ed IPSec traffic.
  64. #DHCP_KEEPRESOLV[4]="yes"       # If you dont want /etc/resolv.conf overwritten
  65. #DHCP_KEEPNTP[4]="yes"          # If you don't want ntp.conf overwritten
  66. #DHCP_KEEPGW[4]="yes"           # If you don't want the DHCP server to change
  67.                                 # your default gateway
  68. #DHCP_IPADDR[4]=""              # Request a specific IP address from the DHCP
  69.                                 # server
  70. #WLAN_ESSID[4]=DARKSTAR         # Here, you can override _any_ parameter
  71.                                 # defined in rc.wireless.conf, by prepending
  72.                                 # 'WLAN_' to the parameter's name. Useful for
  73.                                 # those with multiple wireless interfaces.
  74. #WLAN_IWPRIV[4]="AuthMode=WPAPSK EncrypType=TKIP WPAPSK=thekey TxRate=0"
  75.                                 # Some drivers require a private ioctl to be
  76.                                 # set through the iwpriv command. If more than
  77.                                 # one is required, you can place them in the
  78.                                 # IWPRIV parameter (space-separated, see the
  79.                                 # example).

复制代码


  1. [color="red"]#vi rc.inet2[/color]
  2. #!/bin/sh
  3. #
  4. # rc.inet2        This shell script boots up the entire network system.
  5. #                Note, that when this script is used to also fire
  6. #                up any important remote NFS disks (like the /usr
  7. #                directory), care must be taken to actually
  8. #                have all the needed binaries online _now_ ...
  9. #
  10. #               Uncomment or comment out sections depending on which
  11. #               services your site requires.
  12. #
  13. # Author:        Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
  14. # Modified for Slackware by Patrick Volkerding <volkerdi@slackware.com>


  15. # At this point, we are ready to talk to The World...


  16. # Mount remote (NFS) filesystems:
  17. if cat /etc/fstab | grep -v '^#' | grep -w nfs 1> /dev/null 2> /dev/null ; then
  18.   # Start rpc.portmap, /sbin/rpc.lockd, and /sbin/rpc.statd if we find NFS
  19.   # volumes defined in /etc/fstab since these will need to be running in order
  20.   # to mount them.  If they are not running, attempting to mount an NFS
  21.   # partition will cause mount to hang, or at least result in unreliable
  22.   # operation.  Keep this in mind if you plan to mount unlisted NFS
  23.   # partitions...
  24.   # If you have uncommented NFS partitions in your /etc/fstab, rc.rpc is run
  25.   # whether it is set as executable or not.  If you don't want to run it,
  26.   # comment the NFS partitions out in /etc/fstab or erase/rename rc.rpc.
  27.   if [ -r /etc/rc.d/rc.rpc ]; then
  28.     sh /etc/rc.d/rc.rpc start
  29.   fi
  30.   echo "Mounting remote (NFS) file systems:  /sbin/mount -a -t nfs"
  31.   /sbin/mount -a -t nfs          # This may be our /usr runtime!
  32.   # Show the mounted volumes:
  33.   /sbin/mount -v -t nfs
  34. fi

  35. # If /etc/rc.d/rc.rpc is executable, run it to load rpc.portmap, rpc.lockd,
  36. # and rpc.statd.  This might be needed to mount NFS partitions that are not
  37. # listed in /etc/fstab.  Starting this twice won't hurt as the script will
  38. # check if things are already running before trying to start them.
  39. if [ -x /etc/rc.d/rc.rpc ]; then
  40.   sh /etc/rc.d/rc.rpc start
  41. fi

  42. # Mount remote (SMB) filesystems:
  43. if cat /etc/fstab | grep -v '^#' | grep -w smbfs 1> /dev/null 2> /dev/null ; then
  44.   echo "Mounting remote (SMB) file systems:  /sbin/mount -a -t smbfs"
  45.   /sbin/mount -a -t smbfs
  46.   # Show the mounted volumes:
  47.   /sbin/mount -v -t smbfs
  48. fi

  49. # Start the system logger if it is not already running (maybe because /usr
  50. # is on a network partition).
  51. if [ -x /etc/rc.d/rc.syslog -a -d /var/log -a ! -r /var/run/syslogd.pid ]; then
  52.   . /etc/rc.d/rc.syslog start
  53. fi

  54. # If there is a firewall script, run it before enabling packet forwarding.
  55. # See the HOWTOs on http://www.netfilter.org/ for documentation on
  56. # setting up a firewall or NAT on Linux.  In some cases this might need to
  57. # be moved past the section below dealing with IP packet forwarding.
  58. if [ -x /etc/rc.d/rc.firewall ]; then
  59.   /etc/rc.d/rc.firewall start
  60. fi

  61. # Turn on IPv4 packet forwarding support.
  62. if [ -x /etc/rc.d/rc.ip_forward ]; then
  63.   . /etc/rc.d/rc.ip_forward start
  64. fi

  65. # Start the inetd server:
  66. if [ -x /etc/rc.d/rc.inetd ]; then
  67.   /etc/rc.d/rc.inetd start
  68. fi

  69. # Start the OpenSSH SSH daemon:
  70. if [ -x /etc/rc.d/rc.sshd ]; then
  71.   echo "Starting OpenSSH SSH daemon:  /usr/sbin/sshd"
  72.   /etc/rc.d/rc.sshd start
  73. fi

  74. # Start the BIND name server daemon:
  75. if [ -x /etc/rc.d/rc.bind ]; then
  76.   /etc/rc.d/rc.bind start
  77. fi

  78. # Start NIS (the Network Information Service):
  79. if [ -x /etc/rc.d/rc.yp ]; then
  80.   . /etc/rc.d/rc.yp start
  81. fi

  82. # Start the NFS server.  Note that for this to work correctly, you'll
  83. # need nfsd support in the kernel (the startup script will try to load
  84. # the module for you).
  85. # You'll also need to set up some shares in /etc/exports.
  86. # Starting the NFS server:
  87. if [ -x /etc/rc.d/rc.nfsd ]; then
  88.   /etc/rc.d/rc.nfsd start
  89. fi

  90. # Stuff you won't need follows.  ;-)

  91. # # Start the network routing daemon:
  92. # if [ -x /usr/sbin/routed ]; then
  93. #   echo "Starting network routing daemon:  /usr/sbin/routed"
  94. #   /usr/sbin/routed -g -s
  95. # fi

  96. # # Start the system status server:
  97. # if [ -x /usr/sbin/rwhod ]; then
  98. #   echo "Starting system status server:  /usr/sbin/rwhod"
  99. #   /usr/sbin/rwhod
  100. # fi

  101. #  # Fire up the PC-NFS daemon(s).  This is a primarily obsolete system, and may
  102. #  # not be very secure.  It's not at all needed for normal NFS server support.
  103. #  # You probably should not run this.
  104. #  if [ -x /usr/sbin/rpc.pcnfsd ]; then
  105. #    echo "Starting PC-NFS daemons:  /usr/sbin/rpc.pcnfsd /usr/sbin/rpc.bwnfsd"
  106. #    /usr/sbin/rpc.pcnfsd /var/spool/lpd
  107. #  fi
  108. #  if [ -x /usr/sbin/rpc.bwnfsd ]; then
  109. #    /usr/sbin/rpc.bwnfsd /var/spool/lpd
  110. #  fi


复制代码


  1. [color="red"]#vi rc.inetd[/color]
  2. #!/bin/sh
  3. # Start/stop/restart inetd, the BSD Internet super-daemon.

  4. # Start inetd:
  5. inetd_start() {
  6.   if [ -x /usr/sbin/inetd ]; then
  7.     echo "Starting Internet super-server daemon:  /usr/sbin/inetd"
  8.     /usr/sbin/inetd
  9.   fi
  10. }

  11. # Stop inetd:
  12. inetd_stop() {
  13.   killall inetd
  14. }

  15. # Restart inetd:
  16. inetd_restart() {
  17.   inetd_stop
  18.   sleep 1
  19.   inetd_start
  20. }

  21. case "$1" in
  22. 'start')
  23.   inetd_start
  24.   ;;
  25. 'stop')
  26.   inetd_stop
  27.   ;;
  28. 'restart')
  29.   inetd_restart
  30.   ;;
  31. *)
  32.   echo "usage $0 start|stop|restart"
  33. esac

复制代码


  1. [color="Red"]#vi rc.ip_forward[/color]
  2. #!/bin/sh
  3. # /etc/rc.d/rc.ip_forward:  start/stop IP packet forwarding
  4. #
  5. # If you intend to run your Linux box as a router, i.e. as a
  6. # computer that forwards and redistributes network packets, you
  7. # will need to enable IP packet forwarding in your kernel.
  8. #
  9. # To activate IP packet forwarding at boot time, make this
  10. # script executable:  chmod 755 /etc/rc.d/rc.ip_forward
  11. #
  12. # To disable IP packet forwarding at boot time, make this
  13. # script non-executable:  chmod 644 /etc/rc.d/rc.ip_forward

  14. # Start IP packet forwarding:
  15. ip_forward_start() {
  16.   if [ -f /proc/sys/net/ipv4/ip_forward ]; then
  17.     echo "Activating IPv4 packet forwarding."
  18.     echo 1 > /proc/sys/net/ipv4/ip_forward
  19.   fi
  20.   # When using IPv4 packet forwarding, you will also get the
  21.   # rp_filter, which automatically rejects incoming packets if the
  22.   # routing table entry for their source address doesn't match the
  23.   # network interface they're arriving on.  This has security
  24.   # advantages because it prevents the so-called IP spoofing,
  25.   # however it can pose problems if you use asymmetric routing
  26.   # (packets from you to a host take a different path than packets
  27.   # from that host to you) or if you operate a non-routing host
  28.   # which has several IP addresses on different interfaces.  To
  29.   # turn rp_filter off, uncomment the lines below:
  30.   #if [ -r /proc/sys/net/ipv4/conf/all/rp_filter ]; then
  31.   #  echo "Disabling rp_filter."
  32.   #  echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
  33.   #fi
  34. }

  35. # Stop IP packet forwarding:
  36. ip_forward_stop() {
  37.   if [ -f /proc/sys/net/ipv4/ip_forward ]; then
  38.     echo "Disabling IPv4 packet forwarding."
  39.     echo 0 > /proc/sys/net/ipv4/ip_forward
  40.   fi
  41. }

  42. # Restart IP packet forwarding:
  43. ip_forward_restart() {
  44.   ip_forward_stop
  45.   sleep 1
  46.   ip_forward_start
  47. }

  48. case "$1" in
  49. 'start')
  50.   ip_forward_start
  51.   ;;
  52. 'stop')
  53.   ip_forward_stop
  54.   ;;
  55. 'restart')
  56.   ip_forward_restart
  57.   ;;
  58. *)
  59.   echo "usage $0 start|stop|restart"
  60. esac


复制代码


注:红色部分表示打入的命令
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表