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
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:2465 errors:0 dropped:0 overruns:0 frame:0
TX packets:1562 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
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
[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:3380 errors:0 dropped:0 overruns:0 frame:0
TX packets:2216 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
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
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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:48 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen: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
valid_lft forever preferred_lft forever
ip的方式未来趋势
ip add是查看
网卡重启别名ip失效:携程配置文件(/etc/sysconfig/network-scripts/ifcfg-eth0:1))
网卡重启后辅助ip也会失效
查看网络状态:
ifconfig
ip
route -n
hostname(uname -n) 查看主机名
netstat(ESTABLISHED建立连接的状态,数量即表示网络连接数)
lsof
转载于:https://blog.51cto.com/sandshell/1948078