各種linux系統配置多IP方法整理__linux

來源:互聯網
上載者:User
CentOS下添加IP的方法

一、添加單個IP的方法:
# cd /etc/sysconfig/network-scripts
# cp ifcfg-eth0 ifcfg-eth0:0
# nano ifcfg-eth0:0 複製代碼
使用cp命令複製一個eth0的檔案,新的檔案名稱為eth0:0 ,然後用nano編輯此檔案。不習慣用nano的可以用vi等命令。開啟檔案後編輯:

DEVICE=eth0:0      #此處添加:0,保持和檔案名稱一致,添加多個IP依次遞增
ONBOOT=yes                      #是否開機啟用
BOOTPROTO=static              #靜態IP,如果需要DHCP擷取請輸入dhcp
IPADDR=192.168.1.2            #此處修改為要添加的IP
NETMASK=255.255.255.0      #子網路遮罩根據你的實際情況作修改 複製代碼

檔案編輯完之後,運行:
/etc/init.d/network reload 複製代碼

用 ifconfig看新的IP是否已經加上。

二、大量新增IP:

在/etc/sysconfig/network-scripts下建立一個range檔案,也可以用vi等編輯
nano /etc/sysconfig/network-scripts/ifcfg-eth0-range0 複製代碼 DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR_START=192.168.2.2     #起始IP
IPADDR_END=192.168.2.254         #結束IP
CLONENUM_START=1        #表示這段IP網卡號從eth0:1開始
NETMASK=255.255.255.0 複製代碼
無類域間路由(CIDR)的子網路遮罩設定參考: http://www.taohost.net/tools/subnet.htm

/29 (5 usable) NETMASK = 255.255.255.248
/28 (13 usable) NETMASK = 255.255.255.240
/27 (29 usable) NETMASK = 255.255.255.224
/26 (61 usable) NETMASK = 255.255.255.192
/25 (125 usable) NETMASK = 255.255.255.128
/24 (253 usable) NETMASK = 255.255.255.0

三、為一塊新網卡配置IP地址的方法:

如果是為第二塊網卡配IP,在/etc/sysconfig/network-scripts目錄下編輯一個ifcfg-eth1的檔案:

DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.18
NETMASK=255.255.255.0
GATEWAY=192.168.0.1 複製代碼

修改一下IPADDR,NETMASK和GATEWAY的參數。

運行:

/etc/init.d/network reload

用ifconfig看新的IP是否已經加上。


Linux FreeBSD伺服器添加IP的方法

往FreeBSD添加IP的方法:

vi /etc/rc.conf

First line is the main ip address + subnet mask
Second line and thereafter use the 'alias' in the config line and netmask of
255.255.255.255 and proper broadcast ip.

ALso, may not be fxp0, might be sis0, rltk0, etc..
ifconfig_fxp0="inet 10.10.10.34 netmask 255.255.255.248"
ifconfig_fxp0_alias0="inet 10.10.10.35 netmask 255.255.255.255"
ifconfig_fxp0_alias1="inet 10.10.10.36 netmask 255.255.255.255"
ifconfig_fxp0_alias2="inet 10.10.10.37 netmask 255.255.255.255"

etc..

Also you can run /stand/sysconfig
Choose Configure, Networking, Interfaces, then nic card ( fxp0, rltk, dlink,
rl0, vne, etc...)


Linux Debian 伺服器添加IP的方法。

Debian 伺服器添加IP的方法。

To add secondary ips in debian do:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.