LinuxSir.cn,穿越时空的Linuxsir!

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

为什么我总遇上这种奇怪的事情——etc下的设置文件貌似都失灵了?

[复制链接]
发表于 2007-8-7 17:13:51 | 显示全部楼层 |阅读模式
我今天装好了gentoo后,启动系统,成功,然后先后发现了三件事情

首先,我没法上网,虽然我能ping到网关,网关也能ping到我(显然内网没问题),也在/etc/resolv.conf里设置好了dns,但稀奇的是就是ping不通外网,却可以ping网关(没有任何防护墙阻挡,网络是我做的我很清楚),而在安装前用系统自己net-setup设置的dns都能正常上网更新……

然后发现第二件事情,就是用ssh远程登录的时候,当输入了用户名root后,要等半天才出输入密码的框,而以前用cd启动时ssh速度飞快。

然后发现第三件事情,启动时,命令行里有个黄色的*提示

Your TIMEZONE in /etc/conf.d/clock is still set to Factory!
===============
发现问题,上网查找,第一个问题,我在屡次输入域名服务器无效后,想到一个办法,把在光盘启动时能访问网络的/etc/resolv.conf文件给拷贝到我的目录下,结果,仍然不行,现把我的resolv文件的内容贴出,请大家看有没有写错

  1. GNU nano 2.0.2            File: /etc/resolv.conf

  2. nameserver 202.103.24.68
  3. nameserver 202.103.44.150

复制代码


第二个问题,经网络搜索,发现ssh连接会反向要求解析域名,随即想到自己目前无法访问域名服务器,导致连接ssh速度缓慢,解决办法,修改/etc/ssh/sshd_config文件,禁用dns解析,结果无效……/etc/ssh/sshd_config文件内容见下

  1. GNU nano 2.0.2          File: /etc/ssh/sshd_config

  2. #       $OpenBSD: sshd_config,v 1.74 2006/07/19 13:07:10 dtucker Exp $

  3. # This is the sshd server system-wide configuration file.  See
  4. # sshd_config(5) for more information.

  5. # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

  6. # The strategy used for options in the default sshd_config shipped with
  7. # OpenSSH is to specify options with their default value where
  8. # possible, but leave them commented.  Uncommented options change a
  9. # default value.

  10. #Port 22
  11. Protocol 2
  12. #AddressFamily any
  13. #ListenAddress 0.0.0.0
  14. #ListenAddress ::

  15. # HostKey for protocol version 1
  16. #HostKey /etc/ssh/ssh_host_key
  17. # HostKeys for protocol version 2
  18. #HostKey /etc/ssh/ssh_host_rsa_key
  19. #HostKey /etc/ssh/ssh_host_dsa_key

  20. # Lifetime and size of ephemeral version 1 server key
  21. #KeyRegenerationInterval 1h
  22. #ServerKeyBits 768

  23. # Logging
  24. # obsoletes QuietMode and FascistLogging
  25. #SyslogFacility AUTH
  26. #LogLevel INFO

  27. # Authentication:

  28. #LoginGraceTime 2m
  29. #PermitRootLogin yes
  30. #StrictModes yes
  31. #MaxAuthTries 6

  32. #RSAAuthentication yes
  33. #PubkeyAuthentication yes
  34. #AuthorizedKeysFile     .ssh/authorized_keys

  35. # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
  36. #RhostsRSAAuthentication no
  37. # similar for protocol version 2
  38. #HostbasedAuthentication no
  39. # Change to yes if you don't trust ~/.ssh/known_hosts for
  40. # RhostsRSAAuthentication and HostbasedAuthentication
  41. #IgnoreUserKnownHosts no
  42. # Don't read the user's ~/.rhosts and ~/.shosts files
  43. #IgnoreRhosts yes

  44. # To disable tunneled clear text passwords, change to no here!
  45. PasswordAuthentication no
  46. #PermitEmptyPasswords no

  47. # Change to no to disable s/key passwords
  48. #ChallengeResponseAuthentication yes

  49. # Kerberos options
  50. #KerberosAuthentication no
  51. #KerberosOrLocalPasswd yes
  52. #KerberosTicketCleanup yes
  53. #KerberosGetAFSToken no

  54. # GSSAPI options
  55. #GSSAPIAuthentication no
  56. #GSSAPICleanupCredentials yes

  57. # Set this to 'yes' to enable PAM authentication, account processing,
  58. # and session processing. If this is enabled, PAM authentication will
  59. # be allowed through the ChallengeResponseAuthentication and
  60. # PasswordAuthentication.  Depending on your PAM configuration,
  61. # PAM authentication via ChallengeResponseAuthentication may bypass
  62. # the setting of "PermitRootLogin without-password".
  63. # If you just want the PAM account and session checks to run without
  64. # PAM authentication, then enable this but set PasswordAuthentication
  65. # and ChallengeResponseAuthentication to 'no'.
  66. UsePAM yes

  67. #AllowTcpForwarding yes
  68. #GatewayPorts no
  69. #X11Forwarding no
  70. #X11DisplayOffset 10
  71. #X11UseLocalhost yes
  72. #PrintMotd yes
  73. #PrintLastLog yes
  74. #TCPKeepAlive yes
  75. #UseLogin no
  76. #UsePrivilegeSeparation yes
  77. #PermitUserEnvironment no
  78. #Compression delayed
  79. #ClientAliveInterval 0
  80. #ClientAliveCountMax 3
  81. #UseDNS no
  82. #PidFile /var/run/sshd.pid
  83. #MaxStartups 10
  84. #PermitTunnel no

  85. # no default banner path
  86. #Banner /some/path

  87. # override default of no subsystems
  88. Subsystem       sftp    /usr/lib/misc/sftp-server

  89. # Example of overriding settings on a per-user basis
  90. #Match User anoncvs
  91. #       X11Forwarding no
  92. #       AllowTcpForwarding no
  93. #       ForceCommand cvs server
复制代码


第三个问题,根据在论坛上找到的答案,要修改/etc/conf.d/clock内的东西,可我修改后启动,仍然没用,仍然提示我clcok是工厂状态……

  1. GNU nano 2.0.2           File: /etc/conf.d/clock

  2. # /etc/conf.d/clock

  3. # Set CLOCK to "UTC" if your system clock is set to UTC (also known as
  4. # Greenwich Mean Time).  If your clock is set to the local time, then
  5. # set CLOCK to "local".  Note that if you dual boot with Windows, then
  6. # you should set it to "local".

  7. CLOCK="local"

  8. # Select the proper timezone.  For valid values, peek inside of the
  9. # /usr/share/zoneinfo/ directory.  For example, some common values are
  10. # "America/New_York" or "EST5EDT" or "Europe/Berlin".

  11. #TIMEZONE="Asia/Shanghai"

  12. # If you wish to pass any other arguments to hwclock during bootup,
  13. # you may do so here.

  14. CLOCK_OPTS=""

  15. # If you want to set the Hardware Clock to the current System Time
  16. # during shutdown, then say "yes" here.

  17. CLOCK_SYSTOHC="no"


  18. ### ALPHA SPECIFIC OPTIONS ###

  19. # If your alpha uses the SRM console, set this to "yes".
  20. SRM="no"

  21. # If your alpha uses the ARC console, set this to "yes".
  22. ARC="no"

复制代码


以上修改,我都是远程ssh用root用户登录进入,chroot进去后在绝对路径上修改的,我现在怀疑不是我写错了命令,而是某种原因导致etc下的命令设置系统不接受,特此请教高人,这问题我今天足足折腾了一天了,查了很多地方都找不到线索
发表于 2007-8-7 18:29:46 | 显示全部楼层
第三个问题
#TIMEZONE="Asia/Shanghai"

前面的#号要去掉才能生效。
回复 支持 反对

使用道具 举报

发表于 2007-8-7 18:48:34 | 显示全部楼层
问题1:
你是怎么获取的ip?dhcp还是指定?如果是指定的,估计是你的网关地址没设对。
/etc/conf.d/net :
config_eth0=( "192.168.0.2/24" )  #这里设ip
routes_eth0=( "default gw 192.168.0.1" )  #这里设网关


问题2:
#ListenAddress 0.0.0.0
去掉注释,改成你电脑的ip(你没有固定ip?如果没有当然要解析了。)
例:
ListenAddress 192.168.2.1
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-7 19:32:28 | 显示全部楼层
Post by zxuan
第三个问题
#TIMEZONE="Asia/Shanghai"

前面的#号要去掉才能生效。


确实如此,请问是不是所有的参数设置都是这么规定的

Post by zhou3345
问题1:
你是怎么获取的ip?dhcp还是指定?如果是指定的,估计是你的网关地址没设对。
/etc/conf.d/net :
config_eth0=( "192.168.0.2/24" )  #这里设ip
routes_eth0=( "default gw 192.168.0.1" )  #这里设网关


问题2:
#ListenAddress 0.0.0.0
去掉注释,改成你电脑的ip(你没有固定ip?如果没有当然要解析了。)
例:
ListenAddress 192.168.2.1

第一个问题我自行解决了,其实是因为我的机器比较特别的原因,我机器上是为了将来做软路由,有两块网卡,我把两块网卡都设置了IP,由于网上几乎没有文章讲到一台linx机器上有两块网卡时,如果要使用其中一块网卡上网是怎么处理的,我就想当然的把两块网卡都设置了IP并且把其中一块设置了网关(我们这里的网络是通过一个宽带路由器adsl拨号出去的,网关设置的就是路由器的IP),结果我今天下午反复测试发现这样是行不通的,必须关掉一块网卡,另外一块网卡才能联外网,否则的话,两块网卡一起启动的话,会导致以下情况,默认的eth0能连通内网和网关,但上不了外网,另外一块eth1干脆连内网都不通……非要停一块,另外一块就正常了。

我现在唯一不爽的是eth0不知道怎么搞的居然在我机器里是默认启动的,我已经把他从default启动项里删除了,boot项里也没有,他还是能自动启动,我观察了一下eth0是紧跟着lo启动的,而且貌似排在default启动的前面,但是查不到他的启动项在哪里。因为我现在是用eth1连,搞的我每次启动系统后要手动去关eth0
回复 支持 反对

使用道具 举报

发表于 2007-8-7 19:51:03 | 显示全部楼层
rc-update del net_eth0 default

设定两块网卡的IP也可以正常工作的,但你即然是ppoe拔号,就不要设定getware,DNS设与不设都无所谓的(pppoe的情况下)。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-7 20:12:37 | 显示全部楼层
Post by linuxth
rc-update del net_eth0 default

设定两块网卡的IP也可以正常工作的,但你即然是ppoe拔号,就不要设定getware,DNS设与不设都无所谓的(pppoe的情况下)。

老兄,要真“rc-update del net_eth0 default”这么简单的话我就不上来说了,你没仔细看我说的,我早就把eth0从default用你这个命令删除了,从/etc/Runlevels/default也看不到net.eth0,但是,邪门的是他就是能自动启动,我也搞不明白怎么回事,而且他貌似根本不是由default启动的,他跟着net.lo启动,它启动完了,启动命令行才滚动出default的,我观察了启动过程好多遍了

不是的,我现在还没pppoe拨号,系统还在更新,我现在是两块网卡,机器是都通过公司的宽带路由器+adsl猫上网,你知道的,这种上网方式都是要设置网关和DNS的。但我就发现这种状况下两块网卡一起启动是没法正常工作的,网上也没有任何帖子讲这种情况下的网卡应该怎么设置,总之我今天下午测试了不下20遍,确认在两块网卡都启动的情况下是没法正常工作的,非要stop一块,另外一块就正常了……

另外请教一下大家有没有好的拨号解决方案,这里的帖子我看过,貌似要实现断线自动拨号都很复杂啊……
回复 支持 反对

使用道具 举报

发表于 2007-8-7 20:41:12 | 显示全部楼层
现实PPPOE自动重拔功能
当PPPOE断线后,用以下脚本实现自动重拔。
#!/sbin/runscript

depend() {
  need net
}

start() {
ebegin "Starting ADSL"
/usr/sbin/adsl-start
eend $? "Connection Failed"
}

stop() {
ebegin "Stopping ADSL"
/usr/sbin/adsl-stop
eend $? "Failed to stop ADSL"
}


载入开机自动运行脚本。
mv adsl /etc/init.d
chmod a+x /etc/init.d/adsl
rc-update add adsl default


注:本代码不是我写的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-7 20:51:09 | 显示全部楼层
Post by linuxth
现实PPPOE自动重拔功能
当PPPOE断线后,用以下脚本实现自动重拔。


载入开机自动运行脚本。


注:本代码不是我写的。


我就是看不明白这段代码,所以不敢尝试,我不喜欢用自己都不懂的东西,出了问题很难分析,现在就在分析zhllg提供的ppp的方案,听说可以自动判断有无需求而拨号,不知道这种功能具备断线自动重播否。

PS:双网卡在机器在内网模式下上网,经过我反复试验,得出一个结论,第一,第一块被启动的卡(默认是eth0)会有阻断第二块eth1的功能的能力,如果第一块卡启动后没被停止的话你把网线插到第二块卡上,eth1将完全不能工作,但是如果你把eth0给stop,让eth1发挥作用,此时,再次启动eth0,这下就变成eth1阻断eth0的功能了,eth0将瘫痪,可能这是一种网络机制也说不定,另外,我发现,一旦你在/etc/init.d里用ln命令把一块卡和net.lo挂上了,就算你把这卡的启动项从default删除,系统仍然能检测到这块卡,这块卡会随着net.lo启动,除非删除init.d里的这块卡的连接……
回复 支持 反对

使用道具 举报

发表于 2007-8-8 08:26:51 | 显示全部楼层
你的这个问题还是因为路由的设置问题,两块网卡也只要一个路由就可以了。例如:
config_eth0=( "192.168.0.2/24" )
routes_eth0=( "default gw 192.168.0.1" )
config_eth1=( "192.168.2.1/24" )
这里eth1不要写网关。因为如果戴两块表就不知道正确时间了。

eth0或eth1的定义是由udev来做的,归 /etc/udev/rules.d/70-persistent-net.rules 文件管。自动识别之后想自己调整,去改这个文件。
回复 支持 反对

使用道具 举报

发表于 2007-8-8 10:16:14 | 显示全部楼层
肯定是你路由设的有问题,你把两块网卡都配好,用route命令看看路由表

如果你非想不使用eth0的话,好像可以config_eth0=( "none" ),具体记不清了,例子里有
回复 支持 反对

使用道具 举报

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

本版积分规则

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