Tuesday, August 6, 2013

How to change IP address in linux

There are many ways to change your IP address in linux.
Start by finding the current ip address by typing
or in some cases

The output should be something like this:
eth0      Link encap:Ethernet  HWaddr 00:0c:29:e8:23:ba
             inet addr:  Bcast:  Mask:
             inet6 addr: fe80::20c:29ff:fee8:23ba/64 Scope:Link
             UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
             RX packets:307505062 errors:0 dropped:2743 overruns:0 frame:0

in this case is my IP address.
Now I want to change my address to the static IP address
This is easily done with this command:
ifconfig eth0 netmask up

My IP address is now changed to the static ip

Persistant static IP address

Changing the IP address with ifconfig will only make the computer keep that address until a reboot.
To make your static IP address static you will need to change the config file for the network interface.
Edit this file with your favorite editor: /etc/network/interfaces

auto eth0
iface eth0 inet static

The above lines in the config file will make the network interface use the static IP address and use as gateway.
After changing this file you will need to restart the network service, this can usually be done by the command:
service networking restart
as root or by just rebooting your computer.

Monday, July 29, 2013

How do i find out my ip

Finding out what IP address your computer uses could be useful in many cases.
Here is a quick guide for how we can find the IP address in different operating systems.


In pretty much every version of windows we can find the IP address easily using the command tool. Start buy pressing the windows key and R at the same time, then write 'cmd' and press enter.
You should now see a black box, here write 'ipconfig' and press enter.
A chunk of text will appear. Scroll upwards until you see the line:
IPv4-adress . . . . . . . . . . . :
The number followed that line is your computers IP address.

Mac / OSX

On the Mac you find the IP address by starting up the program called Terminal and in the black box you write 'ifconfig' and press enter.
Now look for the line saying 'inet'
The number followed that line is your computers IP address.


Finding the ip address in linux is as easy as on the Mac, in the terminal you only need to write 'ifconfig' or on some distros you might need to write '/sbin/ifconfig' and press enter.
Look for the line 'inet addr:'
The number on that line will be the ip address of your linux-machine.