Forget ifconfig and route. Use iproute2 instead.

The legacy ifconfig and route commands can now be seen as being deprecated and be no longer used for setup of network configuration.

People who are comfortable using ifconfig and route will be fine with the new iproute2 suite, which provides similar functionality and improves upon the older net tools.

Here’s a short n’ sweet cheat sheet using iproute2 for network configuring.  If you want more in-depth information, go here.

Configure network card:
ip link set mtu 1500 dev eth0 (use mtu 9000 if on 1000M gigabit network for more efficiency)

Showing all network cards/IP information

ip addr show

Adding one or several IP addresses on network card.
The iproute2 suite doesn’t need fictitious interfaces such as eth0:1, eth0:2, etc.  This is legacy naming scheme for ifconfig. The ‘label’ will allow older ifconfig to be able to see all the addresses.
Using the CIDR notation with network prefix (after the slash) will automatically calculate the broadcast and netmask.
ip addr add 192.168.0.213/24 label eth0:1 dev eth0

Removing an IP address from network card
ip addr del 192.168.0.213/24 dev eth0

Adding default route
ip route add default via 192.168.0.1

Viewing routes
ip route show

Turning up/down network card
ip link set eth0 up
ip link set eth0 down

This entry was posted in FreeBSD, Linux, Web/Tech. Bookmark the permalink.