Wednesday, July 14, 2010

Set A Static IP Address On Ubuntu 10.04 Lucid Lynx

It is not intuitively obvious how to assign Ubuntu 10.04 Lucid Lynx a a static IP address from the command line. However, much of Linux administration involves the editing of text files, and assigning a static IP address is no different. You’ll need to edit the following file:

/etc/network/interfaces

Initially, the file only contains information about your local loopback address:

auto lo
iface lo inet loopback

To assign a static IP address, you’ll need to make some changes to this file.
Let’s say you want to assign a static IP of 192.168.1.2 to your eth0 network connection (the first Ethernet adapter on your system; if you only have one, it will be eth0), with a subnet mask of 255.255.255.0 and a local gateway of 192.168.1.1. First, make a backup copy of the interfaces file:
sudo cp /etc/network/interfaces ~
This will make a backup copy in your home directory in case something goes amiss during the editing process. Next, fire up a text editor:

sudo vi /etc/network/interfaces

(Obviously you can substitue emacs or your editor of choice.)
Once the file is open, add the following lines:
iface eth0 inet static
address 192.168.1.2
netmask 255.255.252.0
gateway 192.168.1.1

Once you’ve added these lines, save the interfaces file to disk, and exit your text editor. If you want to add a static DNS server, you’ll need to edit the /etc/resolv.conf file with this command:
sudo vi /etc/resolv.conf

To set a static DNS server with the address of 192.168.1.10, add this line to the file:
nameserver 192.168.1.10
Save the file, and exit your text editor.

You’ll then to need have your system load the new IP configuration. You can do that by rebooting, but if that takes too long, you can use this command to force Ubuntu to re-read the configuration files:
sudo ifup eth0

Your system will then have a static IP address.

Saturday, July 3, 2010

Ubuntu Networking Configuration Using Command Line

The basics for any network based on *nix hosts is the Transport Control Protocol/ Internet Protocol (TCP/IP) combination of three protocols. This combination consists of the Internet Protocol (IP),Transport Control Protocol (TCP), and Universal Datagram Protocol (UDP).
By Default most of the users configure their network card during the installation of Ubuntu. You can however, use the ifconfig command at the shell prompt or Ubuntu’s graphical network configuration tools, such as network-admin, to edit your system’s network device information or to add or remove network devices on your system

Configure Network Interface Using Command-Line
You can configure a network interface from the command line using the networking utilities. You configure your network client hosts with the command line by using commands to change your current settings or by editing a number of system files.

Configuring DHCP address for your network card
If you want to configure DHCP address you need to edit the /etc/network/interfaces and you need to enter the following lines replace eth0 with your network interface card

sudo vi /etc/network/interfaces

# The primary network interface – use DHCP to find our address
auto eth0
iface eth0 inet dhcp


Configuring Static IP address for your network card
If you want to configure Static IP address you need to edit the /etc/network/interfaces and you need to enter the following lines replace eth0 with your network interface card

sudo vi /etc/network/interfaces

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255
After entering all the details you need to restart networking services using the following command

sudo /etc/init.d/networking restart

If you are server system administrator or normal user some time you need to assign a second ipaddress to your Ubuntu machine.For this you need to edit the /etc/network/interfaces file and you need to add the following syntax.Below one is the only example you need to chnage according to your ip address settings

sudo vi /etc/network/interfaces 


auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x 


You need to enter all the details like address,netmask,network,broadcast and gateways values after entering all the values save this file and you need to restart networking services in debian using the following command to take effect of our new ipaddress.

After entering all the details you need to restart networking services using the following command

sudo /etc/init.d/networking restart 


Setting your ubuntu system hostname 


Setting up your hostname upon a ubuntu installation is very straightforward. You can directly query, or set, the hostname with the hostname command.

As an user you can see your current hostname with

sudo/bin/hostname                 

Example
To set the hostname directly you can become root and run

sudo /bin/hostname newname

When your system boots it will automatically read the hostname from the file /etc/hostname
If you want to know more about how to setup host name check here

Setting up DNS
When it comes to DNS setup Ubuntu doesn’t differ from other distributions. You can add hostname and IP address to the file /etc/hosts for static lookups.

To cause your machine to consult with a particular server for name lookups you simply add their addresses to /etc/resolv.conf.

For example a machine which should perform lookups from the DNS server at IP address 192.168.3.2 would have a resolv.conf file looking like this

sudo vi /etc/resolv.conf

enter the following details

search test.com
nameserver 192.168.3.2