Linux下一塊網路卡設定多個IP地址
在windows下給一塊網路卡設定多個IP,是比較容易的,今天我寫的內容是關於在LINUX系統下,給一塊網路卡設定多個IP地址,在Linux系統下面,第一塊網路卡就叫eth0,第二塊網路卡就叫eth1,這裡我們給第一塊網路卡設定多個IP,在Linux下,配置網路卡的配置檔案在目錄/etc/sysconfig/network-script/下 ,原來網路卡的配置檔名為ifcfg-eth0 ,我們給一塊網路卡配置多個IP地址的配置檔案命名為ifcfg-eth0:1和ifcfg-eth0 :2,下面看操作如下:
Last login: Fri Aug 6 00:35:49 2010 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
[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)
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地址,不用修改
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地址,不用修改
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
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地址,不用修改
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地址,不用修改
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
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
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)
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]#
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]#
我們再wind下驗證下是否通。。。
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
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
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
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
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
Reply from 172.28.90.202: bytes=32 time=17ms TTL=63
Reply from 172.28.90.202: bytes=32 time=17ms TTL=63
相關文章
- linux下一個網路卡配置多個IPLinux
- 一個網路卡下設定兩個ip地址
- 在 Ubuntu 15.10 上為單個網路卡設定多個 IP 地址Ubuntu
- Windows下單網路卡繫結多個IP地址Windows
- 多塊網路卡繫結IP在linux下Linux
- SCO一個網路卡上面繫結多個IP地址(轉)
- Linux單網路卡繫結多IP與多網路卡共用單IPLinux
- 伺服器如何設定多個不同ip地址伺服器
- win10如何修改虛擬網路卡ip_win10虛擬網路卡怎麼設定ip地址Win10
- AIX中為單網路卡配置多IP地址(轉)AI
- Windows 一個網路卡配多個IPWindows
- linux下怎樣給網路卡加第二個IP地址(轉)Linux
- Solaris下網路卡繫結多個IP
- Linux下多網路卡多網段訪問 --- 網路卡及Gateway, 路由設定(Linux OS)LinuxGateway路由
- Linux下設定靜態IP地址Linux
- 網路卡無法獲取IP地址自己給他找個
- Linux Mint 20 設定靜態IP地址Linux
- Linux多ip地址如何刪除多餘ipLinux
- 手動設定ip地址和dns ip地址和dns怎麼設定DNS
- 在 Linux 中用 nmcli 命令繫結多塊網路卡Linux
- netsh設定IP地址
- SUSE linux雙網路卡繫結一個IPLinux
- Redhat linux雙網路卡繫結一個IPRedhatLinux
- linux更改網路卡的mac地址LinuxMac
- mysql繫結多個ip地址MySql
- 多網路卡網路改“躍點數”值來設定出口IP(值越小越優先)
- 網路受限,手動設定IP地址無效
- Linux雙網路卡繫結單個IP之(team)Linux
- 【Linux】Linux網路配置基礎3 編輯配置檔案設定網路卡子介面ipLinux
- 批處理設定ip地址
- Linux中網口使用多個IP地址的常見場景和好處!Linux
- Linux 雙網路卡雙IP配置Linux
- Azure上每個VM多個IP地址
- 如何修改linux的網路卡mac地址LinuxMac
- Linux 下獲取LAN中指定IP的網路卡的MAC(實體地址)LinuxMac
- 設定Linux伺服器IP地址的shell指令碼Linux伺服器指令碼
- Linux下設定網路卡繫結 (final)Linux
- bond 雙網路卡(兩網路卡使用同一個地址)(Redhat5.5)Redhat