===2009.04.06 update===

這次應該是補足最後缺少的部份

自己亦從頭至尾一步步的實作,確定是可行的

對於NAT ( Ipmasq + DHCP )找了好一陣子資料 資料之亂 讓紅都不知該怎麼下手才好

經過一整天的亂測後,得到了些心得

使用 aptitude 安裝幾個重要套件

dhcp3-server

dhcp3-client

dhcp3-common

ipmasq(執行NAT的重要套件)

iptable

以下為紅的網路環境

eth0:connect ADSL

eth1:connect Internal network (將網段定在 192.168.0.0 整個網段,NIC ip address : 192.168.0.1)

=================以下即是細部設定===================

eth0的部份:

先設定啟動 ADSL

#pppoeconf

進行ADSL 的連線設定,設定完成後,會自動將網路參數寫入 /etc/network/interfaces 中

eth0 會從中華電信的 dhcp server 取得 ip

eth0 + eth1 設定:

從 auto eth1 開始,一直到最後一行之前,皆為 eth1 的環境設定

以下為 /etc/network/interfaces 的設定

#========================= start ====================================

# The loopback network interface
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
pre-up iptables-restore < /etc/iptables.up.rules

#adsl 設定
auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
provider dsl-provider
#auto eth0

auto eth1
iface eth1 inet static
address 192.168.0.2
netmask 255.255.0.0
network 192.168.0.0
option getway 192.168.0.1
broadcast 192.168.0.255
up iptables -t nat -A POSTROUTING -o $IFACE -j MASQUERADE

auto eth0

#========================= end ====================================

.

==========================DHCP configuration==========================

接下來設定 DHCP server,設定檔: /etc/dhcp3/dhcpd.conf

ddns-update-style none;

option domain-name "example.com.tw";   #這邊填入自己的 DNS

option domain-name-servers 168.95.1.1;  #填入預設的 DNS server,目前寫的是Hinet 的 DHS server

default-lease-time 600;

max-lease-time 720000;

log-facility local7;

subnet 192.168.0.0 netmask 255.255.0.0 {

range 192.168.0.0 192.168.0.200;

#ip會被分配的範圍在  192.168.0.10 ~ 192.168.0.200 之間

option routers 192.168.0.2;

#Internal area 對外的流通口

}

接下來,設定啟動 DHCP server服務的為 eth1 網路卡

在 /etc/default/dhcp3-server 入進行設定

INTERFACES="eth1"

============================DHCP configuration end===========================

以上設定之後,即是設定 NAT 的部份,以下參考 Debian無痛起步法 的資料進行設定

NAT

載入相關 kernel module

1.在 /etc/modules 中加入兩項:

  network.dns.disableIPv6
  modprobe ip_tables

2. 更改相關設定檔 /etc/sysctl.conf
#
# /etc/sysctl.conf – Configuration file for setting system variables
# See sysctl.conf (5) for information.
#原資料不改,並加入下行的設定即可
net.ipv4.ip_forward=1

3. 執行相關指令

# iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.0.0/24 -j MASQUERADE

最後,重新啟動網路或許就可以了

#/etc/init.d/networking  restart

相關文章:

2009.01.13 石門水庫紅楓行
2009.01.13 石門水庫紅楓行

[Engagement] 2011.09.04 湰貿 & 容泇
[Engagement] 2011.09.04 湰貿 & 容泇

一起看夜景的幸福
一起看夜景的幸福

YAMAHA Nouvo
YAMAHA Nouvo

[Wedding]裕廣Eddy & 靜怡Sara《迎取》
[Wedding]裕廣Eddy & 靜怡Sara《迎取》

[Wedding]Alvin@Linda《迎取》
[Wedding]Alvin@Linda《迎取》

Tags: