ifconfig檢視配置别名ip等
[root@oldboy ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:37:E5:DD
inet addr:192.168.1.110 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe37:e5dd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2386 errors:0 dropped:0 overruns:0 frame:0
TX packets:1465 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:210774 (205.8 KiB) TX bytes:179501 (175.2 KiB)
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:65536 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1280 (1.2 KiB) TX bytes:1280 (1.2 KiB)
指定檢視一個裝置:
[root@oldboy ~]# ifconfig eth0
RX packets:2465 errors:0 dropped:0 overruns:0 frame:0
TX packets:1562 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:217862 (212.7 KiB) TX bytes:192459 (187.9 KiB)
ifconfig給網卡配置第二個ip位址:
eth0:0(0-254)簡稱别名ip,主機網卡重新開機或者伺服器重新開機都會失效
[root@oldboy ~]# ifconfig eth0:1 192.168.1.108/24
RX packets:3380 errors:0 dropped:0 overruns:0 frame:0
TX packets:2216 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:299729 (292.7 KiB) TX bytes:270469 (264.1 KiB)
eth0:0 Link encap:Ethernet HWaddr 00:50:56:37:E5:DD
inet addr:192.168.1.109 Bcast:225.168.1.255 Mask:255.255.255.0
eth0:1 Link encap:Ethernet HWaddr 00:50:56:37:E5:DD
inet addr:192.168.1.108 Bcast:192.168.1.255 Mask:255.255.255.0
eth0:3 Link encap:Ethernet HWaddr 00:50:56:37:E5:DD
inet addr:192.168.1.107 Bcast:192.168.1.255 Mask:255.255.255.0
eth0:4 Link encap:Ethernet HWaddr 00:50:56:37:E5:DD
inet addr:192.168.1.106 Bcast:192.168.1.255 Mask:255.255.255.0
RX packets:48 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:4136 (4.0 KiB) TX bytes:4136 (4.0 KiB)
可以停用配置:ifconfig eth1:0 down
ip的方式配多個ip,成為輔助ip
heartbeat 高可用早起用的别名ip,centos6下ha也是輔助ip。
keeplived高可用一直用輔助ip
輔助ip添加方法:
[root@oldboy ~]# ip addr add 192.168.1.103/24 dev eth0:10
[root@oldboy ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:50:56:37:e5:dd brd ff:ff:ff:ff:ff:ff
inet 192.168.1.110/24 brd 192.168.1.255 scope global eth0
inet 192.168.1.109/24 brd 225.168.1.255 scope global secondary eth0:0
inet 192.168.1.108/24 brd 192.168.1.255 scope global secondary eth0:1
inet 192.168.1.107/24 brd 192.168.1.255 scope global secondary eth0:3
inet 192.168.1.106/24 brd 192.168.1.255 scope global secondary eth0:4
inet 192.168.1.103/24 scope global secondary eth0
inet6 fe80::250:56ff:fe37:e5dd/64 scope link
ip的方式未來趨勢
ip add是檢視
網卡重新開機别名ip失效:攜程配置檔案(/etc/sysconfig/network-scripts/ifcfg-eth0:1))
網卡重新開機後輔助ip也會失效
檢視網絡狀态:
ifconfig
ip
route -n
hostname(uname -n) 檢視主機名
netstat(ESTABLISHED建立連接配接的狀态,數量即表示網絡連接配接數)
lsof
本文轉自sandshell部落格51CTO部落格,原文連結http://blog.51cto.com/sandshell/1948078如需轉載請自行聯系原作者
sandshell