To setup ip for debian or ubuntu server is not easy for someone who is not familiar with command line. For normal ubuntu desktop user, there is always NetworkManager applet to easily set up the network using GUI, which is very easy. There are 2 ways to setup ip for debian or ubuntu server. One will set the ip temporarily and the otehr one will permanently set the ip. I will show both :)
To set ip temporarily using ifconfig and route commands
1. Run the command below to set ip and netmask
$ sudo ifconfig eth0 10.20.1.10 netmask 255.255.255.0 up
where eth0 is the name of the interface, 255.255.255.0 is the netmask and up to activate the interface
2. run route command to set default gateway
$ sudo route add default gw 10.20.1.1
where 10.20.1.1 is your gateway ip
3. You can check the configuration that you have setup using commands route -n to see the gateway and ifconfig to see the ip address
Done.
To permanently set up the ip and gateway, you have to edit /etc/network/interfaces. It is advisable if you backup the existing interfaces file, if it is available.
1. Backup /etc/network/interfaces
$ sudo cp /etc/network/interfaces /etc/network/interfaces.bak
2. Open the /etc/network/interfaces using your favorite text editor
$ sudo vi /etc/network/interfaces
3. Add the below setting to add ip, netmask and gateway
# The loopback interface
auto lo
iface lo inet loopback
# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
#set your static IP below
address 10.20.1.10
#set your default gateway IP here
gateway 10.20.1.1
# set your netmask, network and broadcast ip below
netmask 255.255.255.0
network 10.20.1.0
broadcast 10.20.1.255
4. Save your configuration and restart network
$ sudo /etc/init.d/network restart
5. Your debian/ubuntu server machine is now operating with the new ip. Check ip and gateway using ifconfig and route -n
Monday, May 25, 2009
Setting ip in debian/ubuntu server
Sunday, May 24, 2009
Setting ip in redhat,fedora and centos
For redhat, fedora and centos, to set ip temporarily, you can use ifconfig and route commands(you have to be root to do these steps)
1. Run the command below to set ip and netmask
# ifconfig eth0 10.20.1.10 netmask 255.255.255.0 up
where eth0 is the name of the interface, 255.255.255.0 is the netmask and up to activate the interface
2. run route command to set default gateway
# route add default gw 10.20.1.1
where 10.20.1.1 is your gateway ip
3. You can check the configuration that you have setup using commands route -n to see the gateway and ifconfig to see the ip address
To setup the ip and gateway permanently, follow below steps (You have to be root to do these steps)
1. Go to folder /etc/sysconfig/network-scripts
# cd /etc/sysconfig/network-scripts
2. Backup your existing configuration
# cp ifcfg-eth0 ifcfg-eth0.bak
3. Open ifcfg-eth0 with your favorite editor
# vi ifcfg-eth0
4. Add below line to the ifcfg-eth0 file to setup your ip
BOOTPROTO=static
DEVICE=eth0
IPADDR=10.20.1.20
NETMASK=255.255.255.0
NETWORK=10.20.1.0
ONBOOT=yes
TYPE=Ethernet
5. Save the file
6. Add below line to /etc/sysconfig/network to set your gateway
GATEWAY=10.20.1.1
7. Save and restart network
# /etc/init.d/network restart
8. Done. Check your newly created ip using ifconfig and gateway using route -n commands
Monday, April 27, 2009
MSCOSCONF2009
MSC Malaysia Open Source Software Conference(MSCOSCONF2009) is an open source conference that will be held in Malaysia on 31 May - 3 June, 2009, organized by MAMPU and MDEC of Malaysia. There will be great speakers presenting their stuff on the event, great activities and much more. For further details, visit http://www.mscmalaysia.my/osconf and http://www.mscoscon.my.
Tuesday, April 14, 2009
Installing virtualbox 2.2.0 on ubuntu 8.10
To install virtualbox is fairly easy. Just follow the instructions below:
1. Open /etc/apt/sources.list and add this line deb http://download.virtualbox.org/virtualbox/debian intrepid non-free
2. Import sun public-key and register it using apt-key (wget is for downloading, apt-key is for registering the key to your machine)
$ wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O - | sudo apt-key add -
OK
3. Update your system's package index file
$ sudo apt-get update
4. Install virtualbox 2.2
$ sudo apt-get install virtualbox-2.2
Done, that's all :)
Friday, April 10, 2009
Adding local directory to apt sources.list
I faced this problem when trying to install the latest version of lyx, frontend for the famous LaTeX/TeX document processor. Lyx is available at the ubuntu main repo, but the version is kind of outdated. After checking at http://www.getdeb.net, a latest version is available. After downloading the lyx and lyx-common package from here, I tried to install both of them using "dpkg -i *.deb" but they have unsatisfied dependencies. One of the way to solve this is to download all the dependencies and put them inside one directory, and run "dpkg -i *.deb" but I think I wanna try another solution which is using apt to install them. This is where "Adding local directory to apt sources.list" comes into the picture. The steps will be explained below:
1. Create the directory to put all the deb files you downloaded, in this case I'll create /home/foo/debs
$ mkdir /home/foo/debs
2. Put all the downloaded deb files into the directory
$ mv /home/foo/Desktop/*.deb /home/foo/debs
3. Check the current priorities and section for the package, find entry named Section and Priority:
$ dpkg --info lyx_1.6.2-1~getdeb1_i386.deb
Here are some of the info:
Package: lyx
Section: editors
Priority: optional
Homepage: http://www.lyx.org/
4. Create override file. Override file is used to override the default priority and section setting of the package (refer to no. 3 for guide on how to check section and priority). Override file contains 3 columns: package, priority, section. Package is the name of the package, priority is low, medium, high or optional and section is the section to which it belongs.
Example of override file content:
## Override
#Package priority section
lyx low editors
5. Create Packages.gz inside /home/foo/debs
$ cd /home/foo/debs
$ sudo dpkg-scanpackages . override | gzip -c9 > Packages.gz
6. If you are too lazy to do the override file, you do not have to. Just change the "dpkg --scanpackages" command above to this:
$ cd /home/foo/debs
$ sudo dpkg-scanpackages . /dev/null | gzip -c9 > Packages.gz
If you follow this path, ignore step 4 and 5
7. Add this line to /etc/apt/sources.list
deb file:///home/foo/debs /
8. Resynchronize the package index files from their sources
$ sudo apt-get update
9. Install your application (in this case, lyx)
$ sudo apt-get install lyx
Apt will fetch the deb files from your local file directory also. Congratulations, you just created a local file repository in your own computer :)