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

Favigen, Favicon Generator

Favigen, Favicon Generator : " Favicons are small icons that help identify websites. They are used as a visual representation of a website both in the web browser and at many online services. The three most prominent locations of favicons are the browser’s address bar, the tabbar and the bookmarks folder. Many webmasters like to create custom favicons to add that custom identifier to their website. Favicons can be created in many image and icon editors, but also online. Favigen is a straightforward favicon generator that can turn an image into a favicon. All that it takes is to pick an image from the local hard drive first, select the dimensions of the favicon and click the submit button to make the service generate the favicon. Favigen supports several image formats, including jpg and png, and it does not seem to have size restrictions either. Available image dimensions range are 16×16, 32×32 and 64×64. The generated favicon is displayed directly on the page. A click on do...

A simple rsync script to back up your home directory

A simple rsync script to back up your home directory : " Backing up important data is obviously something we should all do. Unfortunately, it is not always easy to make it happen. We get lazy; we do not have the additional hardware for a backup server; it takes a long time and a lot of CDs to back up to optical media; we do not trust online backup services; backup schemes are difficult to set up and use — any of dozens of reasons can stand in our way. Still, we know we should be backing up our important data. Modern open source Unix-like operating systems offer a plethora of options for incredibly simple, effective backup schemes, however. If the problem is figuring out how to set one up, a simple rsync solution may be exactly what you need. The rsync utility is used to synchronize files between two systems. It does so by way of incremental copies, only copying from the source to the destination what has not already been copied there, saving time, network bandwidth, and syst...

Google Wave now open to the public: faster, Robots and Gadgets aplenty!

Google Wave now open to the public: faster, Robots and Gadgets aplenty! : " Filed under: Internet , Google If you somehow missed it, Google Wave is now a bonafide Labs project: rather than being an invite-only alpha, it's now a public beta test! If you don't already have an account, just head on over to Wave and use your regular Google login details. If you've not seen any of the Google Wave introductory videos , you should check them out -- they explain the whole thing a lot more succinctly than I ever could. Wave has also been enabled for Google Apps domains -- businesses could convert their internal communication to Waves today! Leading up to this public release there have a lot of changes. It's by no means finished, but Google Wave is now a lot faster . It's also more intuitive -- more useful -- and given the large number of Robots and Gadgets now reaching prime-time readiness, it feels like the mass adoption of Wave is imminent. Also, if you're an ol...