Monday, June 25, 2018

Linux CLI Networking

Working from a terminal interface sometimes is the only option. For example, when something has gone horribly wrong with an update and the system won't boot and you find yourself staring at a terminal while in recovery mode. In this example, the recovery mode does not have any networking enabled by default. Consequently, you may need the means to make that connection. Fortunately, this is fairly easy to perform.

First you'll need to know the name of the interface that you intend to enable. The following commend will give the name of all of the interfaces, so you'll need to pick the one that you want to enable.

ifconfig -a

For this example, we'll say that on the list is eth0. You'll then do something along the lines of the following command to turn it on.

ifconfig eth0 192.168.1.42 netmask 255.255.255.0 up

This will turn on the network interface, set the IP address, and the netmask. You may also need to identify your gateway, which the following command will do for you.

route add default gw 192.168.1.1 eth0

At this point, you should have a working network interface. A quick verification would be to ping a known IP address, like a Google server 8.8.8.8.

No comments: