[TLUG] Re: [TLUG] 虛擬主機&動態IP

origo tlug@linux.org.tw
Sat, 3 Jan 2015 09:50:35 +0800


你可以:
1>    確定你的是否有 route 的功能
        cd /usr/src/linux/     大概在這個中可能有加版本碼
        make         make xconfig            兩者會讓你看或選 kernel 的模組,
        如果我記的沒有錯的話,  一般的預設都會巳經有  route  的功能了.
2>    /etc/rc.d/init.d/network    這個檔案中( 可能是別的檔案可用   grep -inH
IPFORWARD /etc/rc.d/init.d/* ) IPFORWARD 應
        原來是  NO ,改成   YES
3>    使用  route ,ifconfig,ipchains 等來設定

        1>     >> ifconfig ethX 10.110.X.X/16 broadcast 10.110.255.255
                    X 如你所要, 設定你所要的內部及外部 ip
        2>    >> route                 file://會列出來你的 route   table
10.110.0.0          *               255.255.0.0            U     0      0
0 eth0
192.168.0.0        *               255.255.0.0             U     0      0
0 eth1
127.0.0.0           *               255.0.0.0                 U     0      0
0 lo
default             10.110.X.X 0.0.0.0                 UG    1      0
0 eth0

route add -net 10.110.0.0/16 eth0        指定外部 subnet
route add -net 192.168.0.0/16    eth1    指定內部 subnet
route add default gw 10.110.X.X        指定預設 gateway   ,  即上一層的
route

如此之後即可以正常但因為可能沒有 RIP  所以會有些問題且 192.168.0.0/16
為 vistual ip ,所以要再加上( IP 偽裝)(NAT+FIREWALL), 所以要加上下列指令:


ipchains -P input DENY
ipchains -P forward DENY
ipchains -P output DENY            file://將所有 policy deny

ipchains -A forward -s 0.0.0.0/0 -d 0.0.0.0/0 -j MASQ
            //   所有內部網路和外部網路做 masq
ipchains -S forward -s 192.168.0.0/16  -d 10.110.0.0/0 -j MASQ
            // 192.168.0.0/16 網段僅可以 masq 連到 10.110.0.0/16

要清除所加的設定
ipchains -X
ipchains -F

開機要執行:

/etc/rc.d/rc.local ......很多檔案都可以( 僅指此例)加入上?指令

ipchains-save        存 policy
ipchains-restore    載入 policy
用導向 (redirect) 來存即可

以上每一個指令都有很多功能對網路也要有些了解,
你可以用 man command 來查相信在這個過程中你會
得到許多的.



有關 DHCP 份 </etc/dhcpd.conf>    DHCP SERVER
#
# Configuration file for DHCP server.
# Please see /usr/doc/dhcpd-1.0pl2 for examples,
#  and view the manpage dhcpd.conf(5).
#
option domain-name "aaa.com.tw
main-name-servers 172.17.0.10, 168.95.1.1;
option routers 172.29.0.254;
# 最大持有此 ip 時間
max-lease-time 4800;
# 預設釋時間?也就是 dhcp 20 mins lease 一次
default-lease-time 1200;

subnet 172.29.0.0 netmask 255.255.0.0 {
   range 172.29.0.215 172.29.0.220;
}



這以前我曾貼過,再拿出獻醜一下中間 IP    的地方你可以自己改一下.
(VISTUAL IP & DHCP)

</etc/httpd/conf/httpd.conf>  Web Vistual HOST
......
<VirtualHost 10.1.2.254>
DocumentRoot /root/DOC
ServerName a.b.c
</VirtualHost>


</etc/named.conf>  DNS
...
zone "a.b.c" {
        type master;
        file "/var/named/a.b.c.hosts";
        };

zone "254.2.1.10.in-addr.arpa" {
        type slave;
        masters {
                xx.xx.xx.xx;  <-- YOUR IP of DNS
                };
        };

dns 需指出 WEB VISTUAL HOST (ex. http://a.b.c)
請自己查閱  DNS HOW TO


以上應可以滿足你所要的如有不足請再賜教
有些地方並不詳解,請見諒因為蠻多的.



----- Original Message -----
From: "Jack" <Jack@mail.1021.net>
To: "Tlug (E-mail)" <tlug@linux.org.tw>
Sent: Saturday, July 29, 2000 9:55 AM
Subject: [TLUG] 虛擬主機&動態IP


> 虛擬主機ㄉ做法是否要使用動態IP呢???
> To Unsubscribe: send mail to majordomo@linux.org.tw
> with "unsubscribe tlug" in the body of the message


To Unsubscribe: send mail to majordomo@linux.org.tw
with "unsubscribe tlug" in the body of the message