zoukankan      html  css  js  c++  java
  • linux 单网卡绑定两个ip

    一、ubuntu系统:

      #vi /etc/network/interfaces  OR  $ sudo vi /etc/network/interfaces
      Modify as follows:

     1 auto eth0
     2 auto eth0:0
     3 auto eth0:1
     4 iface eth0 inet static
     5 address 192.168.1.1
     6 netmask 255.255.255.248
     7 gateway 192.168.1.254
     8 
     9 iface eth0:0 inet static
    10 address 192.168.1.2
    11 netmask 255.255.255.248
    12 
    13 iface eth0:1 inet static
    14 address 192.168.1.3
    15 netmask 255.255.255.248
    16 
    17 # add rest of alias / binds below

      Save and close the file.

      Now restart networking, enter:
        #/etc/init.d/networking restart  OR $ sudo /etc/init.d/networking restart

     二、centos系统:

      配置IP地址:
      [root@localhost network-scripts]#vi /etc/sysconfig/network-scripts/ifcfg-eth0
        DEVICE=eth0
        BOOTPROTO=static  
        ONBOOT=yes
        IPADDR=192.168.0.2  
        NETMASK=255.255.255.0
        GATEWAY=192.168.0.1
      配置完以后:
        service network restart
      修改DNS
      [aeolus@db1 etc]$ vi resolv.conf
        nameserver 202.96.128.68
        nameserver 219.136.241.206
      添加网通IP:
      [root@localhost network-scripts]#vi /etc/sysconfig/etwrok-scripts/ifcfg-eth0:0
        DEVICE=eth0:0  #其中的DEVICE为设备的名称,
        BOOTPROTO=static   #模式
        ONBOOT=yes    #开机启动
        IPADDR=192.168.0.3  #ip addr
        NETMASK=255.255.255.0  #子网掩码
        
      如果需要再绑定多一个IP地址,只需要把文件名和文件内的DEVICE中的eth0:X加一即可。
     
     
     
  • 相关阅读:
    折腾,折腾!VM7.0 虚拟机安装雪豹Mac OS snow leopard 10.6!
    STM32启动代码概述
    【淘宝装修】PS DW 介绍 教程 代码(终极篇)
    讲讲volatile的作用
    MSB与LSB
    PLL
    Bootloader之uBoot简介(转)
    AMBA、AHB、APB总线简介
    安装VMWARE WORKSTATION,提示“你已经安装过VMware,请先卸载后再安装”的解决方法
    YII 建立目录项目 YIIC
  • 原文地址:https://www.cnblogs.com/chris-cp/p/4312794.html
Copyright © 2011-2022 走看看