作者:suxixb, Comments Rss, 留言, Trackback

HowTo:搭建家用下载&路由服务器

其实这篇文章不能说是 HowTo ,最多只能说是我自己的安装笔记而已。该服务器主要用来下载和实现共享上网,有空还可以用它来研究iptables。整个系统没有鼠标键盘显示器,全都日常维护都是用SSH进行,所以使用了密钥的验证方式确保安全。下载方面用mldonkey实现,通过局域网内其他电脑用网页方式管理,唯一的不足是对BT下载支持不够。由于服务器基本上都是24小时运作的,所有在上面弄了个dnsmasq,实现DNS缓存和DHCP,局域网的其他机器ip都是自动获取,接上网线就能上网,十分方便。

先说说用到的软件

  • ArchLinux
  • ssh
  • iptables
  • dnsmasq
  • mldonkey

ArchLinux
选择安装包时只选择 base 组,加上 support 组中 re-pppoe,sudo,iptables等几个包,安装一个最小系统。安装完后运行

# pacman-optimize
# sync
# pacman -Syu mldonkey dnsmasq

ssh
为了安全,我这里设置了只允许用密钥验证,以下是我的 /etc/ssh/sshd_config 文件的内容

Port 22
ListenAddress 0.0.0.0
Protocol 2

KeyRegenerationInterval 1h
ServerKeyBits 768

LoginGraceTime 2m
PermitRootLogin yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
PermitEmptyPasswords no

ChallengeResponseAuthentication no
UsePAM yes
Subsystem sftp /usr/lib/ssh/sftp-server

iptables
由于服务器上只有一张网卡连接到交换机,再通过交换机连接到 ADSL Modem 上,所以需要共享服务器上的ppp0链接让局域网上的其他机器上网。

# iptables -F INPUT
# iptables -F FORWARD
# iptables -F POSTROUTING -t nat
# iptables -t nat -F
# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -j MASQUERADE
# iptables-save -c > /etc/iptables/iptables.rules

dnsmasq
这个主要是用来做 dns 缓存和 dhcp 服务,参考了 firefoxmmx 写的这篇教程《提高ADSL(pppoe)上网速度

# vi /etc/dnsmasq.conf

找到下面这一项

#resolv-file=

用下面的一条语句替换

resolv-file=/etc/resolv_dnsmasq.conf

将下面两句前的注释符号删除

interface=eth0
dhcp-range=192.168.1.10,192.168.1.20,255.255.255.0,24h

创建新的dns配置文件,把自己常用的DNS添加到/etc/resolv_dnsmasq.conf中

# cp /etc/resolv.conf /etc/resolv_dnsmasq.conf

编辑 /etc/ppp/pppoe.conf

# vi /etc/ppp/pppoe.conf

找到下列一行

PEERDNS=NO

并在该行下面添加

DNS1 = 127.0.0.1

mldonkey
这里要注意 mldonkey 默认只允许 127.0.0.1 访问,要首先设置允许其他网段访问。~/.mldonkey/downloads.ini 文件的第37行就是设置的地方。再配合《导入 amule/emule 的设置到 Mldonkey》和《让 MLDonkey 导入 amule/emule 的临时文件》两篇文章,驴子基本上能全速运行了,如果你遇到中文文件名变成下划线的问题,可以参考这篇文章《 解决 Mldonkey 中文文件变下划线问题 》。

最后启动服务
# /etc/rc.d/iptables start
# /etc/rc.d/sshd start
# /etc/rc.d/samba start
# /etc/rc.d/dnsmasq start
# /etc/rc.d/mldonkey start

或者编辑 /etc/rc.conf 文件,添加到 daemon 段中。

ok,收工,enjoy it。

标签:, , , , ,


随机文章:

延伸阅读

整个 Yo2 上的相关文章:

发布于 2008 06月 21st , 星期六 at 8:37 pm ,文章归类于 桌面应用, 系统设置, 文章标签:, , , , ,
Comments Rss, 留言, Trackback

No Comments

Be the first to comment on this entry.

Have your say

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
URIs must be fully qualified (eg: http://www.domainname.com) and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.

  1. 订阅

    • 订阅 我的 Blog
    • Feedsky 订阅数
    订阅到iGoogle或Google Reader 订阅到鲜果 订阅到抓虾 订阅到飞鸽 订阅到Bloglines 订阅到我的雅虎 订阅到NetVibes 订阅到Newsgatar 订阅到Rojo 订阅到网易有道 通过哪吒订阅到MSN,Gtalk,Skype 订阅到QQ邮箱
     

  2. 重要公告

    目前该博客(www.shareitem.org,以下简称该博客)是建立在Yo2优博网上的,由于一些众所周知的原因,本人(suxixb)决定于2008年8月1日起陆续将该博客上的所有文章转移到新网站上,地址为http://shareitem.org,并改名为ShareItem.org(简称siog),原来的订阅地址(feed.shareitem.org)将保持不变,可继续使用。在转移成功后,该博客仍然保留到到期为止(2008年11月18日),在到期后,将不能再通过www.shareitem.org来访问该博客,本人也不在该博客上进行更新和发布文章,所有的新文章将统一在新网站上发表。谢谢各位的支持。

  3. 最新评论

  4. 最新日志

  5. 阅读共享

  6. 标签

  7. 存档

  8. Logo