Linux系統線上增加多個ip(轉)

ba發表於2007-08-12
Linux系統線上增加多個ip(轉)[@more@]首先檢視ip
程式碼:
linuxedu.net# ifconfig

eth0 Link encap:Ethernet HWaddr 00:50:BA:EF:21:E2
inet addr:192.168.1.1 Bcast:192.168.1.255 mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3433865 errors:0 dropped:0 overruns:0 frame:0
TX packets:2730922 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2610363482 (2489.4 Mb) TX bytes:577832769 (551.0 Mb)
Interrupt:11 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:811139 errors:0 dropped:0 overruns:0 frame:0
TX packets:811139 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2007636558 (1914.6 Mb) TX bytes:2007636558 (1914.6 Mb)

新增ip

程式碼:
ifconfig eth0:0 192.168.1.2 netmask 255.255.255.255 up

在檢視.
程式碼:
linuxedu.net# ifconfig

eth0 Link encap:Ethernet HWaddr 00:50:BA:EF:21:E2
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3433865 errors:0 dropped:0 overruns:0 frame:0
TX packets:2730922 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2610363482 (2489.4 Mb) TX bytes:577832769 (551.0 Mb)
Interrupt:11 Base address:0xc000
eth0:0 Link encap:Ethernet HWaddr 00:50:BA:EF:21:E2
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3433471 errors:0 dropped:0 overruns:0 frame:0
TX packets:2730637 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2610321034 (2489.3 Mb) TX bytes:577696691 (550.9 Mb)
Interrupt:11 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:811139 errors:0 dropped:0 overruns:0 frame:0
TX packets:811139 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2007636558 (1914.6 Mb) TX bytes:2007636558 (1914.6 Mb)
最後寫到檔案裡,使從新啟動時生效.
vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
程式碼:

DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2


去掉ip
程式碼:
ifconfig eth0:0 192.168.1.2 netmask 255.255.255.255 down
rm /etc/sysconfig/network-scripts/ifcfg-eth0:0


完成.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617731/viewspace-950156/,如需轉載,請註明出處,否則將追究法律責任。

相關文章