Linux Next card set multiple IP address __linux
Last Update:2018-07-26
Source: Internet
Author: User
Under Windows to a network card to set multiple IP, is relatively easy, today I wrote the content is about in Linux system, to a network card set up multiple IP address, under the Linux system, the first network card is called Eth0, the second card is called eth1, Here we set the first network card multiple IP, under Linux, configure the network card configuration file in the directory/etc/sysconfig/network-script/, the original network card configuration file name is Ifcfg-eth0, The configuration file with multiple IP addresses configured for a NIC is named Ifcfg-eth0:1 and Ifcfg-eth0:2, and the following actions are as follows: Last Login:fri Aug 6 00:35:49 from 172.28.102.41
[Root@rep1 ~]# ifconfig # # #原来网卡的配置 Eth0 Link encap:ethernet hwaddr 00:0c:29:d5:39:a0
inet Addr:
172.28.90.101 bcast:172.28.255.255 mask:255.255.0.0
Inet6 ADDR:FE80::20C:29FF:FED5:39A0/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:3125184 errors:0 dropped:0 overruns:0 frame:0
TX packets:101356 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:462342976 (440.9 MiB) TX bytes:10788008 (10.2 MiB)
interrupt:75 Base address:0x2000 lo Link encap:local loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Up loopback RUNNING mtu:16436 metric:1
RX packets:1427 errors:0 dropped:0 overruns:0 frame:0
TX packets:1427 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3335045 (3.1 mib) TX bytes:3335045 (3.1 mib) [Root@rep1 ~]# cd/etc/sysconfig/net
Netconsole Network networking/network-scripts/
[Root@rep1 ~]# cd/etc/sysconfig/network-scripts /
#配置文件的目录路径 [Root@rep1 network-scripts]# ls
Ifcfg-eth0 IFDOWN-ISDN ifup-aliases Ifup-plip ifup-wireless
Ifcfg-lo ifdown-post IFUP-BNEP Ifup-plusb Init.ipv6-global
Ifdown ifdown-ppp Ifup-eth ifup-post net.hotplug
IFDOWN-BNEP ifdown-routes ifup-ippp ifup-ppp network-functions
Ifdown-eth ifdown-sit ifup-ipsec ifup-routes Network-functions-ipv6
IFDOWN-IPPP IFDOWN-SL Ifup-ipv6 Ifup-sit
Ifdown-ipsec Ifdown-tunnel ifup-ipx IFUP-SL
Ifdown-ipv6 ifup ifup-isdn Ifup-tunnel
[ROOT@REP1 network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1 #复制原来网卡配置 [ROOT@REP1 network-scripts]# cp ifcfg-eth0 Ifcfg-eth0:2 #复制原来网卡配置 [Root@rep1 network-scripts]# VI ifcfg-eth0:1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
Device=eth0:1 #此处修改
Bootproto=static
broadcast=172.28.255.255
#IP地址的广播地址 Hwaddr=00:0c:29:d5:39:a0
#MAC地址, no change.
ipaddr=172.28.90.201
#设置新的IP netmask=255.255.0.0
network=172.28.0.0
Onboot=yes
~
——————————————————————————————————
~
"Ifcfg-eth0:1" 9L, 206C written
[Root@rep1 network-scripts]# VI ifcfg-eth0:2
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
Device=eth0:2
#此处修改 Bootproto=static
broadcast=172.28.255.255
#IP地址的广播地址
Hwaddr=00:0c:29:d5:39:a0
#MAC地址, no change.
ipaddr=172.28.90.202
#设置新的IP
netmask=255.255.0.0
network=172.28.0.0
Onboot=yes
~
———————————————————————————————————
~
"Ifcfg-eth0:2" 9L, 206C written
[ROOT@REP1 network-scripts]# service Network Restart #重启下网络服务 Shutting down interface eth0: [OK]
Shutting down loopback interface: [OK]
Bringing up loopback interface: [OK]
Bringing Up interface eth0: [OK]
[Root@rep1 network-scripts]# ifconfig #修改好后验证是否成功 Eth0 Link encap:ethernet hwaddr 00:0c:29:d5:39:a0
inet Addr:
172.28.90.101 bcast:172.28.255.255 mask:255.255.0.0
Inet6 ADDR:FE80::20C:29FF:FED5:39A0/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:3131096 errors:0 dropped:0 overruns:0 frame:0
TX packets:101660 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:462925438 (441.4 MiB) TX bytes:10829005 (10.3 MiB)
interrupt:75 Base address:0x2000 eth0:1 Link encap:ethernet hwaddr 00:0c:29:d5:39:a0
inet Addr:
172.28.90.201 bcast:172.28.255.255 mask:255.255.0.0
Up broadcast RUNNING multicast mtu:1500 metric:1
interrupt:75 Base address:0x2000 eth0:2 Link encap:ethernet hwaddr 00:0c:29:d5:39:a0
inet Addr:
172.28.90.202 bcast:172.28.255.255 mask:255.255.0.0
Up broadcast RUNNING multicast mtu:1500 metric:1
interrupt:75 Base address:0x2000 lo Link encap:local loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Up loopback RUNNING mtu:16436 metric:1
RX packets:1427 errors:0 dropped:0 overruns:0 frame:0
TX packets:1427 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3335045 (3.1 mib) TX bytes:3335045 (3.1 MiB)
[Root@rep1 network-scripts]# ls Ifcfg-eth0 Ifdown-ipsec Ifdown-tunnel ifup-ipx IFUP-SL
ifcfg-eth0:1 Ifdown-ipv6 ifup ifup-isdn Ifup-tunnel
Ifcfg-eth0:2 IFDOWN-ISDN ifup-aliases Ifup-plip ifup-wireless
Ifcfg-lo ifdown-post IFUP-BNEP Ifup-plusb Init.ipv6-global
Ifdown ifdown-ppp Ifup-eth ifup-post net.hotplug
IFDOWN-BNEP ifdown-routes ifup-ippp ifup-ppp network-functions
Ifdown-eth ifdown-sit ifup-ipsec ifup-routes Network-functions-ipv6
IFDOWN-IPPP IFDOWN-SL Ifup-ipv6 Ifup-sit
[Root@rep1 network-scripts]#
We wind down to verify whether the ...
C:\Documents and settings\administrator>ping 172.28.90.101
Pinging 172.28.90.101 with bytes of data:
Reply from 172.28.90.101:bytes=32 time=17ms ttl=63 Reply from 172.28.90.101:bytes=32 time=14ms ttl=63 Ping statistics for 172.28.90.101:
Packets:sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trips times in Milli-seconds:
Minimum = 14ms, Maximum = 17ms, Average = 15ms
Control-c
^c
C:\Documents and settings\administrator>ping 172.28.90.201
Pinging 172.28.90.201 with bytes of data:
Reply from 172.28.90.201:bytes=32 time=38ms ttl=63 Reply from 172.28.90.201:bytes=32 time=18ms ttl=63 Reply from 172.28.90.201:bytes=32 time=2ms ttl=63 Ping statistics for 172.28.90.201:
Packets:sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trips times in Milli-seconds:
Minimum = 2ms, Maximum = 38ms, Average = 19ms
Control-c
^c
C:\Documents and settings\administrator>ping 172.28.90.202
Pinging 172.28.90.202 with bytes of data:
Reply from 172.28.90.202:bytes=32 time=39ms ttl=63 Reply from 172.28.90.202:bytes=32 time=17ms ttl=63 Reply from 172.28.90.202:bytes=32 time=17ms ttl=63