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

CentOS下添加IP的方法

一、添加单个IP的方法:
  1. # cd /etc/sysconfig/network-scripts
  2. # cp ifcfg-eth0 ifcfg-eth0:0
  3. # nano ifcfg-eth0:0
复制代码

使用cp命令复制一个eth0的文件,新的文件名为eth0:0 ,然后用nano编辑此文件。不习惯用nano的可以用vi等命令。打开文件后编辑:

  1. DEVICE=eth0:0      #此处添加:0,保持和文件名一致,添加多个IP依次递增
  2. ONBOOT=yes                      #是否开机激活
  3. BOOTPROTO=static              #静态IP,如果需要DHCP获取请输入dhcp
  4. IPADDR=192.168.1.2            #此处修改为要添加的IP
  5. NETMASK=255.255.255.0      #子网掩码根据你的实际情况作修改
复制代码


文件编辑完之后,运行:
  1. /etc/init.d/network reload
复制代码


ifconfig 看新的IP是否已经加上。

二、批量添加IP:

在/etc/sysconfig/network-scripts下创建一个range文件,也可以用vi等编辑
  1. nano /etc/sysconfig/network-scripts/ifcfg-eth0-range0
复制代码
  1. DEVICE=eth0
  2. ONBOOT=yes
  3. BOOTPROTO=static
  4. IPADDR_START=192.168.2.2     #起始IP
  5. IPADDR_END=192.168.2.254         #结束IP
  6. CLONENUM_START=1        #表示这段IP网卡号从eth0:1开始
  7. 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的文件:

  1. DEVICE=eth1
  2. ONBOOT=yes
  3. BOOTPROTO=static
  4. IPADDR=192.168.0.18
  5. NETMASK=255.255.255.0
  6. 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值