您的位置:首页 > 运维架构 > Linux

各种linux系统配置多IP方法整理

2011-07-19 10:53 645 查看
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:

edit /etc/network/interfaces and add below

auto eth0:0
iface eth0:0 inet static
address 10.10.10.3
netmask 255.255.255.0

auto eth0:1
iface eth0:1 inet static
address 10.10.10.4
netmask 255.255.255.0

修改 Debian Linux server 主IP
----------------------------------------------

vi /etc/hostname
vi /etc/hosts

vi /etc/network/interfaces

and edit the entries below.

auto eth0
iface eth0 inet static
address 67.159.5.28
netmask 255.255.255.0
network 67.159.5.0
BROADCAST 67.159.5.255
gateway 67.159.5.1

then reboot with 'shutdown -r now' or /etc/init.d/networking restart
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: