Replacements for Linux Commands : Part 1





Okay so first of all, a very Happy New year to all the readers, followers, subscribers, and any one directly or indirectly related to the website. I had been writing this post from last two days, and got time to publish on this warm occasion of New Year. Neways, lets start up.

From so long we have been using many of the Linux commands, which can however can be replaced with some optional commands, which sounds damn easy and small as compared to old ones. Specifically, the commands which can be ignored while using  Linux networking are: arpifconfigiptunneliwconfig,nameifnetstat, and route. These programs (except iwconfig) are included in the net-tools package that has been unmaintained for years. The functionality provided by several of these utilities has been reproduced and improved in the new iproute2 suite, primarily by using its new ip command. The iproute2 software code and documentation are available from the Linux Foundation.

Now let’s take a closer look at these commands and their replacements.
This article will not focus on iproute2 or the ip command in detail; instead it will simply give one-to-one mappings between the deprecated commands and their new counterparts. For replacement commands that are listed as ‘not apparent’, please contact me if you know otherwise.




Deprecated command

Replacement command(s)

arp ip n (ip neighbor)
ifconfig ip a (ip addr), ip link, ip -s (ip -stats)
iptunnel ip tunnel
iwconfig iw
nameif ip link, ifrename
netstat ss, ip route (for netstat-r), ip -s link (for netstat -i), ip maddr (for netstat-g)
route ip r (ip route)

.
Now let’s take a closer look at these deprecated commands and their replacements.

This article will not focus on iproute2 or the ip command in detail; instead it will simply give one-to-one mappings between the deprecated commands and their new counterparts. For replacement commands that are listed as ‘not apparent’, please contact me if you know otherwise.



Arp

Deprecated arp commands

Replacement

arp -a [host] or –all [host]
.
Shows the entries of the specified host name or IP address. If the [host] parameter is not used, all entries will be displayed.
ip n (or ip neighbor), or ip n show
arp -d [ip_addr] or –delete [ip_addr]
.
Removes the ARP cache entry for the specified host.
ip n del [ip_addr] (this “invalidates” neighbor entries)
.
ip n f [ip_addr]
(or ip n flush [ip_addr])
arp -D or –use-device
.
Uses the hardware address associated with the specified interface.
Not apparent
arp -e
.
Shows the entries in default (Linux) style.
Not apparent
arp -f [filename] or –file [filename]
.
Similar to the -s option, only this time the address info is taken from the file that [filename] set up. If no [filename] is specified, /etc/ethers is used as default.
Not apparent
arp -H or –hw-type [type] or -t [type]
.
When setting or reading the ARP cache, this optional parameter tells arp which class of entries it should check for. The default value of this parameter is ether (i.e. hardware code 0×01 for IEEE 802.3 10Mbps Ethernet).
Not apparent
arp -i [int] or –device [int]
.
Selects an interface. When dumping the ARP cache only entries matching the specified interface will be printed. For example, arp -i eth0 -s 10.21.31.41 A321.ABCF.321A creates a static ARP entry associating IP address 10.21.31.41 with MAC address A321.ABCF.321A on eth0.
ip n [add | chg | del | repl] dev [name]
arp -n or –numeric
.
Shows IP addresses instead of trying to determine domain names.
Not apparent
arp -s [ip_addr] [hw_addr] or –set [ip_addr]
.
Manually creates a static ARP address mapping entry for host [ip_addr] with the hardware address set to [hw_addr].
ip n add [ip_addr] lladdr [mac_address] dev [device] nud [nud_state] (see example below)
arp -v
.
Uses verbose mode to provide more details.
ip -s n (or ip -stats n)
.
Some ip neighbor examples are as follows:
# ip n del 10.1.2.3 dev eth0
Invalidates the ARP cache entry for host 10.1.2.3 on device eth0.
# ip neighbor show dev eth0
Shows the ARP cache for interface eth0.
# ip n add 10.1.2.3 lladdr 1:2:3:4:5:6 dev eth0 nud perm
Adds a “permanent” ARP cache entry for host 10.1.2.3 device eth0. The Neighbor Unreachability Detection (nud) state can be one of the following:
  • noarp – entry is valid. No attempts to validate this entry will be made but it can be removed when its lifetime expires.
  • permanent – entry is valid forever and can be only be removed administratively.
  • reachable – entry is valid until the reachability timeout expires.
  • stale – entry is valid but suspicious.

Ifconfig

Deprecated ifconfig commands

Replacement

ifconfig
.
Displays details on all network interfaces.
ip a (or ip addr)
ifconfig [interface]
.
The name of the interface. This is usually a driver name followed by a unit number; for example, eth0 for the first Ethernet interface. Eth0 will usually be a PC’s primary network interface card (NIC).
ip a show dev [interface]
ifconfig [address_family]
.
To enable the interpretation of differing naming schemes used by various protocols, [address_family] is used for decoding and displaying all protocol addresses. Currently supported address families include inet (TCP/IP, default), inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk Phase 2), ipx (Novell IPX) and netrom (AMPR Packet radio).
ip -f [family] a
.
[family]
can be inet (IPv4), inet6 (IPv6), or link. Additionally, -4 = -f inet and -6 = -f inet6.
ifconfig [interface] add [address/prefixlength
.
Adds an IPv6 address to the [interface].
ip a add [ip_addr/mask] dev [interface]
ifconfig [interface] address [address]
.
Assigns the specified IP [address] to the specified [interface].
ip a add [ip_addr/mask] dev [interface]
ifconfig [interface] allmulti or -allmulti
.
Enables or disables all-multicast mode. If selected, all multicast packets on the network will be received by the [interface] specified. This enables or disables the sending of incoming frames to the kernel’s network layer.
ip mr iif [name] or ip mroute iif [name], where [name] is the interface on which multicast packets are received.
ifconfig [interface] arp or -arp
.
Enables or disables the use of the ARP protocol on this [interface].
ip link set arp on or arp off
ifconfig [interface] broadcast [address]
.
Specifies the address to use to use for broadcast transmissions. By default, the broadcast address for a subnet is the IP address with all ones in the host portion of the subnet address (i.e., a.b.c.255 for a /24 subnet).
ip a add broadcast [ip_address]
.
ip link set dev [interface] broadcast [mac_address]
(sets the link layer broadcast address)
ifconfig [interface] del [address/prefixlength]
.
Removes an IPv6 address from the [interface], such as eth0.
ip a del [ipv6_addr or ipv4_addr] dev [interface]
ifconfig [interface] down
.
Disables the [interface], such as eth0.
ip link set dev [interface] down
ifconfig [interface] hw [class] [address]
.
Sets the hardware (MAC) address of this [interface], if the device driver supports this operation. The keyword must be followed by the name of the hardware [class] and the printable ASCII equivalent of the hardware address. Hardware classes currently supported include ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom (AMPR NET/ROM).
ip link set dev [interface] address [mac_addr]
ifconfig [interface] io_addr [address]
.
Sets the start [address] in I/O space for this device.
Not apparent; possibly ethtool.
ifconfig [interface] irq [address]
.
Sets the interrupt line used by the network interface.
Not apparent; possibly ethtool.
ifconfig [interface] mem_start [address]
.
Sets the start address for shared memory of the interface.
Not apparent; possibly ethtool.
ifconfig [interface] media [type]
.
Sets physical port or medium type. Examples of [type] are 10baseT, 10base2, and AUI. A [type] value of auto will tell the interface driver to automatically determine the media type (driver support for this command varies).
Not apparent; possibly ethtool.
ifconfig [interface] mtu [n]
.
Sets the Maximum Transfer Unit (MTU) of an interface to [n].
ip link set dev [interface] mtu [n]
ifconfig [interface] multicast
.
Sets the multicast flag on the interface (should not normally be needed as the drivers set the flag correctly themselves).
ip link set dev [interface] multicast on or off
ifconfig [interface] netmask [mask_address]
.
Sets the subnet mask (not the IP address) for this [interface]. This value defaults to the standard Class A, B, or C subnet masks (based on the interface IP address) but can be changed with this command.
Not apparent
ifconfig [interface] pointopoint or -pointopoint
.
Enables or disables point-to-point mode on this [interface].
not apparent; possibly ipppd [device]. The command ip a add peer [address] specifies the address of the remote endpoint for point-to-point interfaces.
ifconfig [interface] promisc or -promisc
.
Enables or disables promiscuous mode on the [interface].
ip link set dev [interface] promisc on or off
ifconfig [interface] txquelen [n]
.
Sets the transmit queue length on the [interface]. Smaller values are recommended for connections with high latency (i.e., dial-up modems, ISDN, etc).
ip link set dev [interface] txqueuelen [n] or txqlen [n]
ifconfig [interface] tunnel [address]
.
Creates a Simple Internet Transition (IPv6-in-IPv4) device which tunnels to the IPv4 [address] provided.
ip tunnel mode sit (other possible modes are ipip and gre).
ifconfig [interface] up
.
Activates (enables) the [interface] specified.
ip link set [interface] up
.
Some examples illustrating the ip command are as follows; using the table above you should be able to figure out what they do.
# ip link show dev eth0
# ip a add 10.11.12.13/8 dev eth0
# ip link set dev eth0 up
# ip link set dev eth0 mtu 1500
# ip link set dev eth0 address 00:70:b7:d6:cd:ef

Iptunnel

Deprecated iptunnel commands

Replacement

iptunnel [add | change | del | show] ip tunnel a or add
ip tunnel chg or change
ip tunnel d or del
ip tunnel ls or show
iptunnel add [name] [mode {ipip | gre | sit} ] remote [remote_addr] local [local_addr] ip tunnel add [name] [mode {ipip | gre | sit | isatap | ip6in6 | ipip6 | any }] remote [remote_addr] local [local_addr]
iptunnel -V or –version not apparent
.
The syntax between iptunnel and ip tunnel is very similar as these examples show.
[iptunnel | ip tunnel] add ipip-tunl1 mode ipip remote 83.240.67.86 (ipip-tunl1 is the name of the tunnel, 83.240.67.86 is the IP address of the remote endpoint).
[iptunnel | ip tunnel] add ipi-tunl2 mode ipip remote 104.137.4.160 local 104.137.4.150 ttl 1
[iptunnel | ip tunnel] add gre-tunl1 mode gre remote 192.168.22.17 local 192.168.10.21 ttl 255


Click here for the Next Part : Part 2

0 Responses to “Replacements for Linux Commands : Part 1”

Post a Comment