<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title>meisw's blog</title>
		<link>http://meisw.wdlinux.cn//</link>
		<description>工作,学习,生活,这里将会有一些记录.     备用域名:http://meisw.wdlinux.cn</description>
		<copyright>Copyright (C) 2004 Security Angel Team [S4T] All Rights Reserved.</copyright>
		<generator>SaBlog-X Version 1.6 Build 20080806</generator>
		<lastBuildDate>Fri, 05 Jun 2026 08:01:36 +0000</lastBuildDate>
		<ttl>30</ttl>
		<item>
			<guid>http://meisw.wdlinux.cn//show-132-1.html</guid>
			<title>FreeBSD做Gateway(转)</title>
			<author>admin</author>
			<description><![CDATA[<p><font color="#0000ff">开始:&nbsp;&nbsp;<br />
1、使用双网卡。一块连接外,一块连接内网.连接外网的网卡标识rl1,连接内网的为rl0<br />
(因为我2块网卡都是REALTEK8139的,所以网卡标识为rl,1和0是两块网卡的区别号)<br />
<br />
2、在/etc/rc.conf中加上：&nbsp;&nbsp;<br />
ifconfig_rl1=&quot;inet 218.92.251.108 netmask 255.225.225.0&quot;　 <br />
##（对外网卡的设置，很显然，218.92.251.108为静态IP地址。255.255.255.0子网掩码。不懂？我颠~）&nbsp;&nbsp;<br />
ifconfig_rl0=&quot;inet 192.168.0.1 netmask 255.255.255.0&quot;　<br />
##（对内网卡IP地址以及子网掩码的设置）&nbsp;&nbsp;<br />
##以上加进rc.conf是为了再每次开机的时候配置好两块网卡的IP地址等。<br />
firewall_enable=&quot;NO&quot;&nbsp; &nbsp;#取消防火墙<br />
gateway_enable=&quot;YES&quot;&nbsp; &nbsp; ##启用网关功能，很显然，很重要。<br />
named_enable=&quot;YES&quot;&nbsp; &nbsp;&nbsp; &nbsp;##启用DNS名字服务，这样可以让内网通过设置主机做DNS<br />
natd_enable=&quot;YES&quot;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;##启用nat功能，很显然，特重要<br />
natd_interface=&quot;rl1&quot;&nbsp; &nbsp;&nbsp; &nbsp; ##设置NAT转发的网卡标识号，rl1为对外连接网卡。相当于###WIN2000里的连接共享设置的那块网卡连接。<br />
<br />
3，设置/etc/ipnat.conf<br />
map rl1 192.168.0.0/24 -&gt;; 218.92.251.108/32 portmap tcp/udp 10000:65000<br />
map rl1 192.168.0.0/24 -&gt;; 218.92.251.108/32<br />
##以上是设置允许共享连接的内网IP范围，很显然，24精确到最后一位！也就是说###192.168.0.*的子机都可以通过这台主机上网。<br />
<br />
4，设定开机自动执行ipnat。<br />
#cd /usr/local/etc/rc.d<br />
#vi runipnat.sh&nbsp;&nbsp;<br />
##加入以下内容：&nbsp;&nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#!/bin/sh&nbsp;&nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/sbin/ipnat -f /etc/ipnat.conf<br />
#chmod 755 runipnat.sh&nbsp; &nbsp;##权限设为可执行。&nbsp;&nbsp;<br />
<br />
5、设置内核，至关重要！<br />
因为ipfw和ipfilter不能共存，所以如果要使用ipfilter,必须将内核中有关ipfw的部份注释掉<br />
#cd /usr/src/sys/i386/conf&nbsp; &nbsp; ##/usr/src/sys/i386/conf是内核文件所在目录<br />
#cp GENERIC DWOLF&nbsp; &nbsp;&nbsp; &nbsp;##备份内核文件GENERIC<br />
<br />
#grep -i IPFIREWALL DWOLF ##查找:IPFIREWALL,如果找到，就加&quot;#&quot;注释掉：<br />
#vi&nbsp; &nbsp;DWOLF&nbsp; &nbsp;##vi编辑，也可以用ee编辑器&nbsp; &nbsp;<br />
&nbsp; &nbsp; #options IPFIREWALL&nbsp;&nbsp;<br />
&nbsp; &nbsp; #options IPDIVERT&nbsp;&nbsp;<br />
##再加入：<br />
&nbsp; &nbsp; options IPFILTER&nbsp;&nbsp;<br />
&nbsp; &nbsp; options IPFILTER_LOG&nbsp;&nbsp;<br />
##保存！<br />
#config DWOLF&nbsp; &nbsp; ##检查有没有错误<br />
#cd /usr/src&nbsp;&nbsp;<br />
#make kernel KERNCONF=DWOLF&nbsp; &nbsp; ##编译内核&nbsp;&nbsp;<br />
#reboot&nbsp;&nbsp;<br />
<br />
##重起以后打dmesg查看启动信息，我看到有一条<br />
IP Filter: v3.4.31 initialized.&nbsp; &nbsp;Default = pass all, Logging = enabled&nbsp;&nbsp;<br />
#ipnat -l&nbsp; &nbsp; ## 显示ipnat的设定状况<br />
map rl1 192.168.0.0/24 -&gt;; 218.92.251.108/32 portmap tcp/udp 10000:65000<br />
map rl1 192.168.0.0/24 -&gt;; 218.92.251.108/32<br />
呵呵，搞定！<br />
<br />
试试内网机器能不能上网，（测试，可省略）<br />
PING 192.168.0.1&nbsp; &nbsp; 成功连接主机，OK！<br />
PING mdxy.3322.org&nbsp; &nbsp;解析到IP地址，DNS OK！<br />
PING 218.92.251.122&nbsp; &nbsp;PING通外网主机，OK！（注意，因为8月中旬全国ISO升级，禁止ICMP数据包，路由器外的IP一般都不给PING，你可以找一个自己可以PING通的外网IP，或者省略这一步，无所谓）<br />
==附录几个常用的IPNAT命令<br />
ipnat -l 　会列出目前ipnat的设定及状况&nbsp;&nbsp;<br />
ipnat -C　清除ipnat的设定&nbsp;&nbsp;<br />
ipfstat　监测数据的流量</font></p>]]></description>
			<link>http://meisw.wdlinux.cn//show-132-1.html</link>
			<category domain="http://meisw.wdlinux.cn//category-9-1.html">其它unix</category>
			<pubDate>2008-06-11 16:16</pubDate>
		</item>
		<item>
			<guid>http://meisw.wdlinux.cn//show-22-1.html</guid>
			<title>freebsd内核编译需知</title>
			<author>admin</author>
			<description><![CDATA[<p>要编译内核，必须要有source，而要安装source，就要用到cvsup.即使你开始没装cvup也没关系，只要配置好网络，然后用</p>
<p>#pkg_add -r cvsup</p>
<p>就可以安装了，上面参数 -r 就是从网络安装cvsup的意思.</p>
<p>另外：<br />
cvs和cvsup不可等同视之.cvs是用来保持源码同步用的，比如enlinght，而cvsup则是用来更新系统.希望我说得没错.</p>
<p><br />
用pkg_add -r cvsup-without-gui先安装cvsup，然后用cvsup更新ports树和src。具体可以读手册的章节：<a href="http://cnsnap.cn.freebsd.org/doc/zh_CN.GB2312/books/handbook/ports-using.html">http://cnsnap.cn.freebsd.org/doc/zh_CN.GB2312/books/handbook/ports-using.html</a></p>]]></description>
			<link>http://meisw.wdlinux.cn//show-22-1.html</link>
			<category domain="http://meisw.wdlinux.cn//category-9-1.html">其它unix</category>
			<pubDate>2007-07-16 13:12</pubDate>
		</item>
		<item>
			<guid>http://meisw.wdlinux.cn//show-20-1.html</guid>
			<title>freebsd设置网卡速率</title>
			<author>admin</author>
			<description><![CDATA[<p>freebsd设置网卡速率<br />
ifconfig bge0 media 10BaseT/UTP mediaopt full-duplex</p>]]></description>
			<link>http://meisw.wdlinux.cn//show-20-1.html</link>
			<category domain="http://meisw.wdlinux.cn//category-9-1.html">其它unix</category>
			<pubDate>2007-07-16 13:07</pubDate>
		</item>
	</channel>
</rss>
