In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to set up multiple IP addresses for a network card in Linux. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
It is relatively easy to set up multiple IP for a network card under windows. What I wrote today is about setting multiple IP addresses for a network card under the LINUX system. Under the Linux system, the first network card is called eth0, and the second network card is called eth2. Here we set multiple IP for the first network card. Under Linux, the configuration file of the network card is under the directory / etc/sysconfig/network-script/. The configuration file of the original Nic is named ifcfg-eth0, and the configuration files that configure multiple IP addresses for one Nic are named ifcfg-eth0:1 and ifcfg-eth0: 2. The following operations are as follows:
Last login: Fri Aug 6 00:35:49 2010 from 172.28.102.41
[root@rep1 ~] # ifconfig # the configuration of the original network card
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/
Directory path of [root@rep1 ~] # cd / etc/sysconfig/network-scripts/ # configuration file
[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 # copy the original Nic configuration
[root@rep1 network-scripts] # cp ifcfg-eth0 ifcfg-eth0:2 # copy the original Nic configuration
[root@rep1 network-scripts] # vi ifcfg-eth0:1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0:1 # modify here
BOOTPROTO=static
BROADCAST=172.28.255.255 # broadcast address of the IP address
HWADDR=00:0C:29:D5:39:A0 # MAC address, no need to modify
IPADDR=172.28.90.201 # set the new 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 # modify here
BOOTPROTO=static
BROADCAST=172.28.255.255 # broadcast address of the IP address
HWADDR=00:0C:29:D5:39:A0 # MAC address, no need to modify
IPADDR=172.28.90.202 # set the new 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 # restart the network service
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 # verify whether it is successful after modification
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] #
Let's check under wind to see if it works.
C:\ Documents and Settings\ Administrator > ping 172.28.90.101
Pinging 172.28.90.101 with 32 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 trip 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 32 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 trip 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 32 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
The above is how to set multiple IP addresses for a network card in Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.