通过ip命令
[root@sre01 network-scripts]# ip addr show ens36
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c0:78:db brd ff:ff:ff:ff:ff:ff
inet 11.11.11.11/24 brd 11.11.11.255 scope global noprefixroute ens36
valid_lft forever preferred_lft forever
inet6 fe80::b6a2:7637:c95c:843e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@sre01 network-scripts]# ip addr add 12.12.12.12/24 dev ens36
[root@sre01 network-scripts]# ip addr show ens36
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c0:78:db brd ff:ff:ff:ff:ff:ff
inet 11.11.11.11/24 brd 11.11.11.255 scope global noprefixroute ens36
valid_lft forever preferred_lft forever
inet 12.12.12.12/24 scope global ens36
valid_lft forever preferred_lft forever
inet6 fe80::b6a2:7637:c95c:843e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
指定网卡别名
[root@sre01 network-scripts]# ip addr add 13.13.13.13/24 dev ens36 label ens36:1
[root@sre01 network-scripts]# ip addr show ens36
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c0:78:db brd ff:ff:ff:ff:ff:ff
inet 11.11.11.11/24 brd 11.11.11.255 scope global noprefixroute ens36
valid_lft forever preferred_lft forever
inet 12.12.12.12/24 scope global ens36
valid_lft forever preferred_lft forever
inet 13.13.13.13/24 scope global ens36:1
valid_lft forever preferred_lft forever
inet6 fe80::b6a2:7637:c95c:843e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
删除网卡别名
[root@sre01 network-scripts]# ip addr flush dev ens36 label ens36:1
[root@sre01 network-scripts]# ip addr show ens36
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c0:78:db brd ff:ff:ff:ff:ff:ff
inet 11.11.11.11/24 brd 11.11.11.255 scope global noprefixroute ens36
valid_lft forever preferred_lft forever
inet 12.12.12.12/24 scope global ens36
valid_lft forever preferred_lft forever
inet6 fe80::b6a2:7637:c95c:843e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
通过ifconfig命令
[root@sre01 network-scripts]# ifconfig ens36:0 13.13.13.13/24 up
[root@sre01 network-scripts]# ip addr show ens36
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c0:78:db brd ff:ff:ff:ff:ff:ff
inet 11.11.11.11/24 brd 11.11.11.255 scope global noprefixroute ens36
valid_lft forever preferred_lft forever
inet 12.12.12.12/24 scope global ens36
valid_lft forever preferred_lft forever
inet 13.13.13.13/24 brd 13.13.13.255 scope global ens36:0
valid_lft forever preferred_lft forever
inet6 fe80::b6a2:7637:c95c:843e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@sre01 network-scripts]#
[root@sre01 network-scripts]# ifconfig ens36:0 down
[root@sre01 network-scripts]# ip addr show ens36
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c0:78:db brd ff:ff:ff:ff:ff:ff
inet 11.11.11.11/24 brd 11.11.11.255 scope global noprefixroute ens36
valid_lft forever preferred_lft forever
inet 12.12.12.12/24 scope global ens36
valid_lft forever preferred_lft forever
inet6 fe80::b6a2:7637:c95c:843e/64 scope link noprefixroute
valid_lft forever preferred_lft forever