Practical Limitation of ifconfig command solve it by ip command| Difference between ifconfig and ip

Practical Limitation of ifconfig command solve it by ip command| Difference between ifconfig and ip

techessay

10 месяцев назад

37 Просмотров

A PRACTICAL APPROCH TO KNOW DIFFRENCE BETWEEN THE "ip" AND "ifconfig" AND
why use IP instead of IFCONFIG --
ifconfig sucks
On Linux, ifconfig is an archaic network interface configuration command. The implementation commonly encountered, "net-tools", has a number of problems which make it more and more unsuitable. The list of replacements is below.
1. Does not support non-labeled secondary addresses
The title speaks for itself. Execute the following with an IP address of your choice (given that eth0 already has an address), and it will not show up in ifconfig.
ip addr add 192.168.1.2/24 brd + dev ens160

2. Does not display peer address
You can set up a peer binding on Ethernet, but eventually, ifconfig will not show the peer that was just set.

# ip addr add 192.168.13.37/32 peer 192.168.13.38 dev ens160
# ifconfig ens160 192.168.13.37
3. Makes secondary addresses look like separate interfaces
People often get the impression that labeled secondary addresses are a separate interface (thanks to the dumb output of ifconfig, as a result of ioctl limitations), which in fact is not the case. You cannot use eth0:1 in iptables nor iproute2, so do not even think of eth0:1 being an interface on its own.
#ifconfig ens160:1 1.2.3.4 up
4. Does not support nor use CIDR notation
ifconfig still operates with the old-fashioned netmasks (for IPv4).

5. Strange hardware address for tun tunnels and wmaster0 interfaces
ifconfig tun0` gives lots of zeroes for the hardware address, but what for please?

tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.0.254.6 P-t-P:10.0.254.5 Mask:255.255.255.255

Additionally, this is where parsers might choke on, since the hardware address does not match typical 48-bit MAC Ethernet format.

I hear InfiniBand addresses are 20 bytes in size, but ifconfig would only show 16.
7. Overrides colon
Linux does allow interfaces to be composed of any characters, except the slash (to make it fit for filesystem exposure, cf. sysfs) and the NUL byte (obvious string terminator in C). As such, you could indeed have an interface called "eth0:foo", and properly interact with it with iproute2. But it would be inaccessible from ifconfig.
6. Not developed anymore
Except for the patch mass that some distros accumulated, the net-tools package (the variant used in Linux distributions, at least) has not seen any significant upstream development after version 1.60, released sometime about April 15 2001
Root Cause for change
The net-tools package uses obsolete ioctl() while iproute2 uses netlink socket which has a wider range of capabilities.

New equivalents
net-tools iproute2
ifconfig ip addr, ip link
ifconfig (interface stats) ip -s link
route ip route
arp ip neigh
netstat ss
netstat -M conntrack -L
netstat -g ip maddr
netstat -i ip -s link
netstat -r ip route
iptunnel ip tunnel
ipmaddr ip maddr
tunctl ip tuntap (since iproute-2.6.34)
(none) for interface rename ip link set dev OLDNAME name NEWNAME
brctl bridge (since iproute-3.5.0)
Ссылки и html тэги не поддерживаются


Комментарии: