Skip to content

Network Command


On newer Ubuntu releases, you may not have "ifconfig" command by default. Instead, you have "ip" command out-of-box. "ip" is starting to replace "ifconfig" in newer Linux distributions.

You can still install ifconfig if it's not present in the system:

$ sudo apt-get install net-tools

Similarly, you can manually install the ip tool:

$ sudo apt-get install iproute2
  • Display Current Network Settings
$ ifconfig
$ ip a
  • Enable and Disable an Interface
$ sudo ifconfig eth0 up
$ sudo ifconfig eth0 down
$ sudo ip link set eth0 up
$ sudo ip link set eth0 down
  • Assign a IP/Netmask to an Interface
$ sudo ifconfig eth0
$ sudo ifconfig eth0 netmask
$ sudo ifconfig eth0 del
$ sudo ifconfig eth0 mtu 1080
$ sudo ip addr add dev eth0
$ sudo ip addr del dev eth0
$ sudo ip link set dev eth0 mtu 1500
  • Show Routing Table
$ route -n
$ sudo route add default gw
$ sudo route add -net netmask gw
$ ip route show
$ sudo ip route add default via
$ sudo ip route add via dev eth0
$ sudo ip route del
$ sudo ip route del default via dev eth1


  • nslookup: to perform a DNS lookup

    $ nslookup    
  • netstat: to get statistics for network ports and shows port availability

    # to list all TCP ports
    $ netstat -at
  • traceroute: to track the route that packets take to reach a destination on a TCP/IP network

    $ sudo traceroute -T