今天配了个代理上网的服务器,刚开始dns没配好,总是没法用,以为是squid的问题,后来想起以前配过dns服务器 但是服务没启,查看named,果然没启,dig外域也查不到相应的ip,重新配了一下网络后,重启squid,一切都ok! 参考资料: 平台:RedHat8.0 各组件均为Linux 自带,双网卡eth0为出口地址,eth1为连接内网地址,网络连接正常。 实现步骤: 一。做IP地址翻译,让局域网内机器能够连入互联网。 #加载模块 modprobe ip_tables modprobe iptable_nat modprobe iptable_filter modprobe ip_conntrack_ftp modprobe ip_nat_ftp #启用IP转发 echo 1 >; /proc/sys/net/ipv4/ip_forward #ip翻译(伪装) iptables -t nat -A POSTROUTING -s 172.28.0.0/16 -o eth0 -j SNAT --to x.x.x.x 注:172.28.0.0/16为内网地址,x.x.x.x为这台机器的外部接口地址。 客户端只需将自己的网关设置为这些命令就实现了让内网机器上网的目的!如果想用代理服务器提供HTTP的缓存功能接 着做: 二。代理服务器 #修改配置文件----squid.conf cd /etc/squid cp squid.conf.defauld squid.conf #切记!这点重要,因为二者文件有所不同!!! 行数 修改 48 http_port 80 405 cache_mem 80 MB #大小自己改 1466 http_access allow all 1650 httpd_accel_host virtual httpd_accel_port 80 httpd_accel_with_proxy on httpd_accel_uses_host_header on 最后一步运行squid: cd /etc/init.d ./squid start #以上是最简单的设置,至于怎么优化squid请参考其他资料。 这样,客户端实际上是通过代理方式浏览网页(其他服务则不通过代理服务!)。 这样做的最大神奇之处在于: 1.客户断完全感觉不到代理服务器的存在,IE不用做任何设置! 2.你可以随时启动/关闭squid,客户端完全不受影响!(够神奇吧?!) 三.补充 以下两句最好写进 /etc/rc.d/rc.local,因为这两条记录重起机器后就失效了。 echo 1 >; /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -s 172.28.0.0/16 -o eth0 -j SNAT --to x.x.x.x 阅读全文(8) / 评论(1) / 给sharper留言 / 扔小纸条 收藏: QQ书签 del.icio.us / 订阅: Google 抓虾 |
service.sh--shell初学 sharper @ 2006-09-12 17:49 这个shell实现在linux系统下运行级别3运行与级别5相同的服务: for i in `chkconfig --list | grep 3:on` do chkconfig --level 3 $i off done for j in `chkconfig --list | grep 5:on` do chkconfig --level 3 $j on done |