Convert DHCP network configuration to static IP configuration

My friend wanted to know how to change or convert DHCP network configuration to static configuration. After initial installation, he wanted to change network settings. Further, his system is w/o GUI system aka X Windows. Here is quick way to accomplish the same:

Your main network configuration file is /etc/network/interfaces

Desired new sample settings:
=> Host IP address 192.168.1.100
=> Netmask: 255.255.255.0
=> Network ID: 192.168.1.0
=> Broadcast IP: 192.168.1.255
=> Gateway/Router IP: 192.168.1.254
=> DNS Server: 192.168.1.254

Open network configuration file
$ sudo vi /etc/network/interfacesOR$ sudo nano /etc/network/interfaces

Find and remove dhcp entry:
iface eth0 inet dhcp

Append new network settings:

iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

Save and close the file. Restart the network:
$ sudo /etc/init.d/networking restart

Task: Define new DNS servers

Open /etc/resolv.conf file
$ sudo vi /etc/resolv.conf

You need to remove old DNS server assigned by DHCP server:
search myisp.com
nameserver 192.168.1.254
nameserver 202.54.1.20
nameserver 202.54.1.30

Save and close the file.

Task: Test DNS server

$ host cyberciti.biz

Network command line cheat sheet

You can also use commands to change settings. Please note that these settings are temporary and not the permanent. Use above method to make network changes permanent or GUI tool as described below.

Task: Display network interface information

$ ifconfig

Task: Take down network interface eth0 / take a network interface down

$ sudo ifconfig eth0 downOR $ sudo ifdown eth0

Task: Bring a network interface eth0 up

$ sudo ifconfig eth0 upOR$ sudo ifup eth0

Task: Change IP address and netmask from command line

Activate network interface eth0 with a new IP (192.168.1.50) / netmask:
$ sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 up

Task: Display the routing table

$ /sbin/route OR$ /sbin/route -n
Output:

Kernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Ifacelocalnet        *               255.255.255.0   U     0      0        0 ra0172.16.114.0    *               255.255.255.0   U     0      0        0 eth0172.16.236.0    *               255.255.255.0   U     0      0        0 eth1default         192.168.1.254   0.0.0.0         UG    0      0        0 ra0

Task: Add a new gateway

$ sudo route add default gw 172.16.236.0

Task: Display current active Internet connections (servers and established connection)

$ netstat -nat

Task: Display open ports

$ sudo netstat -tulpOR$ sudo netstat -tulpn

Task: Display network interfaces stats (RX/TX etc)

$ netstat -i

Task: Display output for active/established connections only

$ netstat -e
$ netstat -te
$ netstat -tue

Where,

  • -t : TCP connections
  • -u : UDP connections
  • -e : Established

Task: Test network connectivity

Send ICMP ECHO_REQUEST to network hosts, routers, servers etc with ping command. This verifies connectivity exists between local host and remote network system:
$ ping router
$ ping 192.168.1.254
$ ping cyberciti.biz

See simple Linux system monitoring with ping command and scripts for more information.

Task: Use GUI (Graphical Configuration) network Tool

If you are new, use GUI configuration tool, type the following command at terminal:
$ network-admin &

Above command is Ubuntu's GUI for configuring network connections tool.

Final tip – Learn how find out more information about commands

A man page is your best friend when you wanted to learn more about particular command or syntax. For example, read detailed information about ifconfig and netstat command:
$ man ifconfig
$ man netstat

Just get a short help with all command options by appending –help option to each command:
$ netstat --help

Find out what command is used for particular task by searching the short descriptions and manual page names for the keyword:
$ man -k 'delete directory'
$ apropos -s 1 remove

Display short descriptions of a command:
$ whatis rm
$ whatis netstat

Linux offers an excellent collection of utilities, which can be use to finding the files and executables, remember you cannot memorize all the commands and files 😉

Ubuntu Hudson

Create hudson directory structure

  • cd /usr/share/
  • mkdir hudson
  • chown tomcat6:tomcat6 /usr/share/hudson
  • ls -l 'hudson'

Deploy WAR file

— Ubuntu Server Setup —

Download here.

Installed Ubuntu Server 11.04

  • openSSH, if not from Install click here.
  • NSF NetWork File Share, (Linux/UNIX only, click here).
  • Samba File Share, (If windows needs access, click here).

Performance tool (server then desktop)

  • $ sudo apt-get install nmon –> here.
  • $ sudo apt-get install htop –> here.
  • Xosview –> here.

Apply Patches

Ability to Search for packages

  • sudo apt-get install aptitude
  • sudo aptitude search <package part>

Application Setup

High availability Ubuntu servers

FTP

SSH should work for most needs (Filezilla), but if FTP is needed

CRONTAB

  • here.
  • Setup backups
  • Clean scripts
  • etc….

Change Hostname

The Command Terminal allows you to control your computer by typing a series of commands in the box.

  • into the command terminal
    • $ sudo pico /etc/hostname
  • Enter your administrative password
  • A window will open titled hostname (/etc) – pico. Replace your system's current name with the new one.
  • Select Save from the tool panel at the top of the window.
    • $ sudo pico /etc/hostname
  • change host name for 127.0.0.1
  • Select Save from the tool panel at the top of the window.
  • Close the Command Terminal.
  • Restart your system. -> here

How to install Maven on Ubuntu

Setup as HTTP:

http://dongchimi.unfix.net/resources/openBooks/MavenTheDefinitiveGuide/repository.html

http://www.google.com/#sclient=psy&hl=en&source=hp&q=setup+inhouse+maven+repository&aq=f&aqi=&aql=&oq=&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=f0ab8257b6a47f59&biw=1536&bih=804

To install Apache Maven on Ubuntu OS, you can use the “apt-get” command.

1. Search Maven package – apt-cache search

Search the Maven package in Ubuntu with apt command – apt-cache search maven

~$ apt-cache search maven....maven-ant-helper - helper scripts for building Maven components with antmaven2 - Java software project management and comprehension tool

2. Install it – apt-get install

Install Maven with command – sudo apt-get install maven2. Apt will configured Maven for you automatically.
~$ sudo apt-get install maven22 upgraded, 87 newly installed, 0 to remove and 263 not upgraded.Need to get 97.2MB of archives.After this operation, 271MB of additional disk space will be used.Do you want to continue [Y/n]? y....download many packages, patient

3. Verification

Type “mvn -version” to verify your installation.
mkyong@mkyong-desktop:~$ mvn -versionMaven version: 2.0.9Java version: 1.6.0_0OS name: "linux" version: "2.6.28-11-generic" arch: "i386" Family: "unix"mkyong@mkyong-desktop:~$

4. Done

If you see the above message, the Apache Maven is installed successfully.
 Where Maven installed?
The Apt-get installation will install all the Maven required files in the following folder structure

/usr/bin/mvn/usr/share/maven2//etc/maven2

P.S The Maven configuration is store in /etc/maven2

Remote desktop

This is only need for Ubuntu Desktop, it will not work for server.

Info via: http://www.makeuseof.com/tag/how-to-establish-simple-remote-desktop-access-between-ubuntu-and-windows/

Adept Ubuntu users would already be thinking about the System > Preferences > Remote Desktop menu entry. Of course we will use that. However, it lets you configure your computer to allow/disallow remote desktop access. It doesn’t let you connect to a remote computer. Extra software is required for that, which we will look at now.

Allow Remote Desktop Connections

First off, you would need to enable remote desktop on the Linux computer that you want to access via remote desktop. Doing so is easy by using the System > Preferences > Remote Desktop option. In the dialog that shows up – check “Allow other users to view your desktop”. You can also configure additional options like requiring password for remote access and notification icons. It is advisable to use a password for remote access, so that only trusted users may be able to establish a connection.

With all that set up, its time to connect to it from another computer. Three possible scenarios arise: you can connect using another Linux machine, or you might want to connect using a Windows PC or MAC. All require slightly different approaches. Here’s how.

Connecting From Another Linux Machine

Ubuntu uses Virtual Networking Connections for remote desktop. Your best bet would be to use a VNC viewer to access the remote desktop. Use the command sudo apt-get install xvnc4viewer to install VNC viewer. Now all you have to do is to issue the sudo vncviewer <hostname/ip> command. You will be asked for a password (if it is configured on the remote machine) and you can then view and interact with the remote desktop.

Connect To Ubuntu From A Windows PC

If you would to connect from a Windows computer, you can use TightVNC, tvnjviewer-2.6.2-bin.zip (JAR) (647.50 kb) or uVNC (There is also a seemingly portable version available that would run off your USB drive without installing, however it stores entries in the registry). Specify the IP address and the port number (default is 5900 and is not required to be mentioned explicitly), specify bandwidth that is available to you, hit Connect and you can access the desktop of the remote machine easily.

Keep in mind that none of these clients support encryption and you have only established an unencrypted connection up until now. Teamviewer and LogMeIn encrypt the the data flow between the two computer. You can use a SSH tunnel to encrypt the flow of data. Here are the steps in brief:
  • You need OpenSSH. (sudo apt-get openssh-server).
  • Create the tunnel using ssh -L 5900:localhost:5900 <ip address>, where IP address is the address of the remote computer. If you are connecting using a Windows computer, you can use PuTTY to create a tunnel.
  • Establish the connection as before however, this time you need to connect to localhost at port 5900 (or whatever port you specified in the command above). VNC client will then utilize the tunnel you just created and traffic between the two endpoints will now be encrypted.

While this is a lot of work compared to the one-click solution offered by Teamviewer or LogMeIn, it is certainly more configurable and caters to a wide variety of needs. Moreover, you only need to do the configuration once and you can also establish a VNC connection with a headless server (with some more configuration though!).

Connect To Ubuntu From A MAC

Mac users can also use their favorite VNC client (like Chicken of the VNC) and you should be able to remotely access the desktop of the said Linux machine.


Tag Cloud