ifconfig is deprecated. Here is how to use ip command
ifconfig command developed by BSD was depreciated years ago but its available to use in many linux system for network interface communication maybe considering its wild use in past years and for those fearing changes too. But its replacement ip is far more handy to use. Apart from ifconfig, many system administration utility like: arp, ipmaddr, route, iptunnel, nameif, mii-tool have become obsolete. The net-tools were used as foundation for the NET-3 networking distribution in Linux based OS.
Though most of the linux distro have the packages already installed but in some cases like: Ubuntu Docker, you might need to get hands dirty for that. This simple command will get you back to years:
sudo apt-get install net-tools
Now, lets get familiar with iproute2 suite to display & analyze the network interface parameters. The newly introduced commands can be used in the form of sub-commands shortened like in Cisco-IOS style like: ip addr is equivalent to ip a.
It lists all interfaces with their associated information. But if you wish to see only IPV4 or IPV6 info, just enter ip -4 a or ip -6 a
ip a show wlan0
It enables you to see information regarding specific interface.
This command lists the routing table. But if you want to route all traffic via the 192.168.0.254 gateway connected via eth0 network interface, enter the command: ip route add 192.168.1.0/24 dev eth0. Also, del in place of add deletes the route.
ip route add default via 0.0.0.0
It changes the default gateway to 0.0.0.0
ip a add 192.168.10.100/24 dev eth0
This add command assigns specific IP address to the eth0 interface. It is equivalent to ifconfig eth0 192.168.10.100 with the ifconfig command.
Similarly, del in place of add deletes the address from interface.
Flushing all addresses from all interfaces on the 192.168.10.x network can be done with the command:
ip -s -s a f to 192.168.10.0/24
Now you may want to set up or close down interfaces which is handy with the new command on modern Linux distributions:
ip link set dev eth0 down
ip link set dev eth0 up
The link commands, the interface can be controlled both in physical and logical level.
Though, ifconfig may work for sometime more but its recommended choice since 2.4 kernels. Its better to switch to newer way of handling network interfaces.
You might also like
The news of Microsoft open-sourcing some of its software and development of Linux Based OS for Azure is not old. But in the mean time, a hacker has spotted Linux
Day after launching third version of flagship killer phone OnePlus 3, the company has released the kernel source code files of the OnePlus 3 to developers on github. The release
In another improvement on Microsoft welcoming Linux platforms, Azure is now offering Red Hat Enterprise Linux licenses. Starting from 17th Feb, users can deploy Red Hat Linux Enterprise (RHLE) from the