Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux教程 >> linux單網卡配置多IP

linux單網卡配置多IP

日期:2017/2/7 16:54:18      編輯:Linux教程

  1、通過復制一個ifcfg-eth0:1配置文件實現:
  cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1
  vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
  # Intel Corporation 82566DC Gigabit Network Connection
  DEVICE=eth0
  BOOTPROTO=none
  BROADCAST=218.95.37.255
  HWADDR=00:19:d1:34:2d:b8
  IPADDR=218.95.37.250
  NETMASK=255.255.255.192
  NETWORK=218.95.37.192
  ONBOOT=yes
  GATEWAY=218.95.37.193
  TYPE=Ethernet
  ifconfig eht0:1 up
  2、臨時方式(重啟後就丟失了):
  ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0 up
  3、腳本方式實現:
  #!/bin/sh
  eth01=/etc/sysconfig/network-scripts/ifcfg-eth0:1
  touch $eth01
  echo DEVICE=eth0:1》$eth01
  echo BOOTPROTO=none》$eth01
  echo IPADDR=192.168.40.76》$eth01
  echo NETMASK=255.255.255.0》$eth01
  echo ONBOOT=yes》$eth01
  /etc/init.d/network restart

Copyright © Windows教程網 All Rights Reserved