關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • Redhat 快速加入多個 IP

    Posted on September 18th, 2006 Sam Tang No comments

    一般的情況下如果要在 Redhat 系統上加入 IP,可以在 /etc/sysconfig/network-scripts/ 下建立類似 ifcfg-eth0:x 檔案,例如:

    DEVICE=eth0:0
    ONBOOT=yes
    BOOTPROTO=static
    IPADDR=192.168.1.100
    NETMASK=255.255.255.0
    NETWORK=192.168.1.1
    BROADCAST=192.168.0.255
    TYPE=Ethernet

    如果加入一兩個 IP 別名的話用這個方法沒有問題,但如果要加入大量 IP,例如 100 個的話,這個方法就會十分麻煩。另一個方法可以將一個連線的 IP range 加入到系統內,方法如下:

    1. 建立 /etc/sysconfig/network-scripts/ifcfg-eth0-range0
    2. 加入以下內容在 ifcfg-eth0-range0 裡面:

    IPADDR_START=192.168.1.100
    IPADDR_END=192.168.1.200
    CLONENUM_START=0

    以上內容會加入由 IPADDR_START(192.168.1.100) 至 IPADDR_END (192.168.1.200) 這個 IP range,而 CLONENUM_START 的數值就是定義給第一個 IP 別名的網絡卡,以上例子是對應 eth0:0。

    要注意的是盡量不要遠端做這個動作,因為改錯了也可以馬上修正。

    如果要加入多個 IP range 的話,只要順序建立 ifcfg-eth0-range1, ifcfg-eth0-range1 …… 修改後重新啟動網絡便完成了:

    service network restart


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word