為了架一台PHP and MySQL
Server,而且能從外面連進來。所以要先架好NAT。之前在B2D上架NAT有過成功的經驗,不過前一陣子為了測試osTube,已經把它重灌成Ubuntu
Server了。
安裝步驟如下:
1.先準備兩張網卡,一個對內使用虛擬IP,另一個則對外使用真實IP。
2.設定 interfaces
(1)編輯 /etc/network/interfaces
auto eth0 #對內
iface eth0 inet
static
address 192.168.1.1 #虛擬IP (自訂的)
netmask
255.255.255.0
auto eth1 #對外
iface eth1 inet static
address
xx.xx.xx.xx #真實IP (我家申請的固定IP)
netmask
255.255.255.0
gateway xx.xx.xx.xx #預設的gateway
(2)設定好之後,要重新啟動 networking
# /etc/init.d/networking restart
3.安裝 dhcp
# apt-get install dhcp3-server
4.編輯 dhcpd.conf (要先備份)
# cd /etc/dhcp3
# cp dhcpd.conf dhcpd.conf.bak
把 dhcpd.conf 全部的內容刪除,改成底下的文字。
# DHCP configuration generated by
Firestarter
ddns-update-style interim;
ignore
client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
option
routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option
domain-name-servers 61.64.127.1; #so-net的DNS位址
option ip-forwarding off;
range
dynamic-bootp 192.168.1.21 192.168.1.50; #自動分配IP的範圍
default-lease-time 21600;
max-lease-time
43200;
}
5.編輯 /etc/default/dhcp3-server
INTERFACES="eth0" #對內網路
6.重新啟動 dhcp
# /etc/init.d/dhcp3-server restart
7.安裝Firestarter
點選左上角「應用程式」->「添加/刪除」
點選「顯示」->「所有可安裝應用程式」
搜尋 ->「Firestarter」-> 套用
8.至「應用程式」->「網際網路」打開「Firestarter」
(1)會先跑出防火牆精靈->下一頁
選擇對外網路「eth1」->下一頁
選擇對內網路「eth0」->下一頁
存檔->離開
(2)點選「Preferences」->「NetWork
Settings」
Internet connected network device ->「eth1」
Local network connected
device ->「eth0」
中間兩個Enable都打勾,底下選擇「Keep existing DHCP configuration」
告一段落,測試成功!
沒有留言:
張貼留言