当前位置: 技术问答>linux和unix
Linux下如何为一块网卡设置多个IP?
来源: 互联网 发布时间:2015-11-19
本文导语: 如题! 不是要ifconfig设置的那种哦,要断电后还有的那种!哪位兄弟能帮一下忙! | 搂住看看一个多网卡系统的输出结果吧 ]# ifconfig eth0 Link encap:Ethernet HWaddr 00:90:0B:05:81:78...
如题!
不是要ifconfig设置的那种哦,要断电后还有的那种!哪位兄弟能帮一下忙!
不是要ifconfig设置的那种哦,要断电后还有的那种!哪位兄弟能帮一下忙!
|
搂住看看一个多网卡系统的输出结果吧
]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:90:0B:05:81:78
inet addr:192.168.1.21 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:144202 errors:0 dropped:0 overruns:0 frame:0
TX packets:1482211 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:15380650 (14.6 Mb) TX bytes:80597612 (76.8 Mb)
Interrupt:10 Base address:0xd000
eth0:1 Link encap:Ethernet HWaddr 00:90:0B:05:81:78
inet addr:123.123.123.1 Bcast:123.123.123.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:10 Base address:0xd000
eth1 Link encap:Ethernet HWaddr 00:90:0B:05:81:79
inet addr:10.10.11.1 Bcast:10.10.11.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1025123 errors:0 dropped:0 overruns:1025093 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:47155642 (44.9 Mb)
Interrupt:11 Base address:0xf000
eth1:1 Link encap:Ethernet HWaddr 00:90:0B:05:81:79
inet addr:123.123.124.1 Bcast:123.123.124.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xf000
eth2 Link encap:Ethernet HWaddr 00:90:0B:05:81:7A
inet addr:10.10.12.1 Bcast:10.10.12.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1025131 errors:0 dropped:0 overruns:1025101 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:47155974 (44.9 Mb)
Interrupt:12 Base address:0x1000
eth2:1 Link encap:Ethernet HWaddr 00:90:0B:05:81:7A
inet addr:123.123.125.1 Bcast:123.123.125.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:12 Base address:0x1000
同样,在/etc/sysconfig/network-scripts
目录下存在多个文件,
ifcfg-eth0
ifcfg-eth0:1
ifcfg-eth1
ifcfg-eth1:1
ifcfg-eth2
ifcfg-eth2:1
所以,在系统中,我理解可能属这样的,每一个ip也就相当于一个网卡了,同一个网卡上多个ip,跟添加了多个网卡一样,只是名字有些差异而已,完全可以按照一般的配置方法去修改
如果你只有一个网卡eth0
你也可以
ifconfig eth0:1 192.168.1.1
]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:90:0B:05:81:78
inet addr:192.168.1.21 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:144202 errors:0 dropped:0 overruns:0 frame:0
TX packets:1482211 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:15380650 (14.6 Mb) TX bytes:80597612 (76.8 Mb)
Interrupt:10 Base address:0xd000
eth0:1 Link encap:Ethernet HWaddr 00:90:0B:05:81:78
inet addr:123.123.123.1 Bcast:123.123.123.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:10 Base address:0xd000
eth1 Link encap:Ethernet HWaddr 00:90:0B:05:81:79
inet addr:10.10.11.1 Bcast:10.10.11.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1025123 errors:0 dropped:0 overruns:1025093 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:47155642 (44.9 Mb)
Interrupt:11 Base address:0xf000
eth1:1 Link encap:Ethernet HWaddr 00:90:0B:05:81:79
inet addr:123.123.124.1 Bcast:123.123.124.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xf000
eth2 Link encap:Ethernet HWaddr 00:90:0B:05:81:7A
inet addr:10.10.12.1 Bcast:10.10.12.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1025131 errors:0 dropped:0 overruns:1025101 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:47155974 (44.9 Mb)
Interrupt:12 Base address:0x1000
eth2:1 Link encap:Ethernet HWaddr 00:90:0B:05:81:7A
inet addr:123.123.125.1 Bcast:123.123.125.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:12 Base address:0x1000
同样,在/etc/sysconfig/network-scripts
目录下存在多个文件,
ifcfg-eth0
ifcfg-eth0:1
ifcfg-eth1
ifcfg-eth1:1
ifcfg-eth2
ifcfg-eth2:1
所以,在系统中,我理解可能属这样的,每一个ip也就相当于一个网卡了,同一个网卡上多个ip,跟添加了多个网卡一样,只是名字有些差异而已,完全可以按照一般的配置方法去修改
如果你只有一个网卡eth0
你也可以
ifconfig eth0:1 192.168.1.1
|
会配置eth0,只要把eht0改为eth0:0就可以了。
如ifcfg-eth0:0文件里DEVICE=eth0:0
如ifcfg-eth0:0文件里DEVICE=eth0:0