Pular para o conteúdo principal

Use the command line to gather your networking information in Linux

Use the command line to gather your networking information in Linux: "

I have been asked, by numerous readers, to intersperse my regular rants and raves with some beginner technical posts. So from this point on you will find the occasional article targeted for new users — this one being one of them.


You’re new to Linux. You’ve installed a distribution that seems to be working out just perfectly for you. But you’ve come up against a small hitch - you need to know your networking information. For whatever reason you need to know your IP Address, your hostname, your DNS addresses, and your gateway address. How do you find this information? You could go to your desktop environments’ networking GUI tool, but that would depend upon the distribution and the desktop. So let’s take a more universal approach to this task - the command line.


Although many newbies fear the command line, the tasks you will see below are a very simple way of getting to know both the command line AND your networking configuration.


IP address


The first bit of information we want to find out is the IP address of our machine. If you’ve used Windows enough, you know the command ipconfig will give you this bit of information (and more). For Linux, the command is ifconfig. If you issue the command without arguments you will see listed all addresses associated with all networking interfaces. A typical entry will look like:


eth0 Link encap:Ethernet  HWaddr 00:30:1b:81:d3:f7
inet addr:192.168.1.108 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::230:1bff:fe81:d3f7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1610700 errors:0 dropped:0 overruns:0 frame:0
TX packets:1185599 errors:5 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1790159713 (1.7 GB) TX bytes:160110456 (160.1 MB)
Interrupt:32 Base address:0x2000

As you can see, the address you are looking for is the inet addr and, in this case, would be 192.168.1.108.


Hostname


The next piece of information is the hostname. If you notice in your terminal window (the window you are running your commands in) you will see that your bash prompt looks like:


jlwallen@ubuntu:~$

You can see a portion of the hostname there (in this case, “ubuntu”). To get the full hostname you would issue the command hostname. On my machine it’s ubuntu.wallen.local.


DNS information


To find your current DNS addresses, issue the command less /etc/resolv.conf which will reveal something like:


# Generated by NetworkManager
nameserver 74.128.19.102
nameserver 74.128.17.114

Gateway


Figure 1

Figure A


Now we come to the gateway address. The command used to find your gateway, netstat, is a very powerful command that can print network connections, routing tables, interface statistics, NAT connections, and multicast memberships. For the purposes of this article we are going to issue the command using the n and r switches like so:


netstat -nr

Which will output something like you see in Figure A. As you can see there are basically three addresses listed but only one address has an associated gateway. That solo gateway address listed in the gateway address for your machine.


Wrap it up


There you go. You have now used the command line and done so to gather up your basic networking information for your new Linux box. Pretty simple stuff eh? We’ll continue on with new-user-friendly articles now and then and eventually those new users will be drilling down deeper and deeper into the Linux operating system.





"

Comentários

Postagens mais visitadas deste blog

Improve Windows Security By Closing Open Ports

Improve Windows Security By Closing Open Ports : " A standard Windows operating system has a number of ports open after installation. Some of these ports are needed for the system to function properly while others might not. These ports can pose a security risk as every open port on a system might be an entry point for a malicious user. A port basically allows communication to or from the device. Characteristics are a port number, an IP address and a protocol type. This article will give you the tools at hand to identify and evaluate the open ports on your Windows system to make a decision in the end whether they can or should be closed or left open. Software programs and tools that we will use: CurrPorts : Available for 32-bit and 64-bit editions of Windows. It is a port monitor that displays all open ports on a computer system. We will use it to identify the ports and the programs that are using them. Windows Task Manager: Also used to identify the programs and link some p

Diagnosing a Blue Screen of Death Error in Windows

Diagnosing a Blue Screen of Death Error in Windows : For many years now the famous Blue Screen of Death (BSoD) has been the ultimate indication that something disastrous has happened to make your computer die, but how useful is the information in the BSoD and the respective crash dump file that Windows produces? The best article I ever found explaining the BSoD in depth is here on the Microsoft website, however it’s quite technical and doesn’t discuss how to actually troubleshoot a problem. The crash dump file is just technical details of what was being held in the computer’s memory at the time of the crash, and this will include details on every driver and service that was loaded, and every piece of software that was running. The most useful pieces of information are to be found on the BSoD itself and are highlighted on the screenshot below. These are the BSoD error name, the stop error code and the name of the driver or service that has failed (this last one might not always appea

Use BGInfo to Build a Database of System Information of Your Network Computers

Use BGInfo to Build a Database of System Information of Your Network Computers : " One of the more popular tools of the Sysinternals suite among system administrators is BGInfo which tacks real-time system information to your desktop wallpaper when you first login. For obvious reasons, having information such as system memory, available hard drive space and system up time (among others) right in front of you is very convenient when you are managing several systems. A little known feature about this handy utility is the ability to have system information automatically saved to a SQL database or some other data file. With a few minutes of setup work you can easily configure BGInfo to record system information of all your network computers in a centralized storage location. You can then use this data to monitor or report on these systems however you see fit. BGInfo Setup If you are familiar with BGInfo, you can skip this section. However, if you have never used this tool, it takes ju