Why ifconfig command should not be used any more in RHEL7?
We could see the IP address configured on any network interface
using command #ip addr show command.
Here you could see there already IP “192.168.0.12” is configured on network interface “eno16777736”
[root@rhelserver
/]# ip addr show
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
valid_lft forever preferred_lft
forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft
forever
2:
eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000
link/ether 00:0c:29:3b:3c:a0 brd
ff:ff:ff:ff:ff:ff
inet
192.168.0.12/24 brd 192.168.0.255 scope global eno16777736
valid_lft forever preferred_lft
forever
inet6 fe80::20c:29ff:fe3b:3ca0/64 scope
link
valid_lft forever preferred_lft
forever
[root@rhelserver
/]#
|
You could check the route information via
command #ip route show
[root@rhelserver
/]# ip route show
default
via 192.168.0.1 dev eno16777736 proto
static metric 1024
192.168.0.0/24
dev eno16777736 proto kernel scope link
src 192.168.0.12
|
Now
I am trying to add one more IP address “10.0.0.10”
on interface “eno16777736”.
# ip addr add dev eno16777736 10.0.0.10/24
[root@rhelserver
/]# ip addr add dev eno16777736 10.0.0.10/24
[root@rhelserver
/]# ip addr show
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
valid_lft forever preferred_lft
forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft
forever
2:
eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000
link/ether 00:0c:29:3b:3c:a0 brd
ff:ff:ff:ff:ff:ff
inet
192.168.0.12/24 brd 192.168.0.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet 10.0.0.10/24
scope global eno16777736
valid_lft forever preferred_lft
forever
inet6 fe80::20c:29ff:fe3b:3ca0/64 scope
link
valid_lft forever preferred_lft
forever
|
We
could see both IP “192.168.0.24”
& “10.0.0.10” are configured on
interface “eno16777736”
Now
let’s use “ifconfig”, as many of us
are used to using ifconfig command.
[root@rhelserver
/]# ifconfig
eno16777736:
flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet
192.168.0.12 netmask
255.255.255.0 broadcast 192.168.0.255
inet6 fe80::20c:29ff:fe3b:3ca0 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:3b:3c:a0 txqueuelen 1000 (Ethernet)
RX packets 627 bytes 74074 (72.3 KiB)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 708 bytes 45361 (44.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
lo:
flags=73<UP,LOOPBACK,RUNNING>
mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop
txqueuelen 0 (Local Loopback)
RX packets 461 bytes 45712 (44.6 KiB)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 461 bytes 45712 (44.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
|
As
you could see, we could see first IP address “192.168.0.12” , but “ifconfig”
command has no capabilities of showing other IP address i.e. “10.0.0.24”
Even
if you use # ifconfig –a, It will
not show the IP address “10.0.0.10”
[root@rhelserver
/]# ifconfig -a
eno16777736:
flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet
192.168.0.12 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::20c:29ff:fe3b:3ca0 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:3b:3c:a0 txqueuelen 1000 (Ethernet)
RX packets 627 bytes 74074 (72.3 KiB)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 708 bytes 45361 (44.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
lo:
flags=73<UP,LOOPBACK,RUNNING>
mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop
txqueuelen 0 (Local Loopback)
RX packets 461 bytes 45712 (44.6 KiB)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 461 bytes 45712 (44.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
|
It
would be shocking for many sys admin, who like ifconfig command so much, but
the man page of ifconfig command says.
#
man ifconfig
IFCONFIG(8)
Linux System Administrator's Manual
IFCONFIG(8)
NAME
ifconfig - configure a network
interface
SYNOPSIS
ifconfig [-v] [-a] [-s] [interface]
ifconfig [-v] interface [aftype]
options | address ...
NOTE
This program is obsolete! For replacement check ip addr and ip link. For statistics use ip -s link.
|
So
do not use ifconfig command any
more, you may miss any network information configured on the network interface.
Thank you for reading.
For Reading
other article, visit to “https://sites.google.com/site/unixwikis/”
No comments:
Post a Comment