Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using Ubuntu on VirtualBox in Dell Laptop and wanted to know how I can configure the static IP in Ubuntu so that I can browse internet on Ubuntu and also use putty.

I am using data card for internet.

Currently in /etc/network/interfaces the settings is as follows:

iface eth0 inet dhcp
share|improve this question
    
If host is connected to the internet, then why don't you just go into the VM settings and enable WIFI? –  nerof61 Mar 6 '13 at 16:44
    
Ubuntu desktop or server? –  mikewhatever Mar 6 '13 at 16:48
    
Do you want to browse the internet and use putty, or do you specifically want to have a static IP address? Your question seems to suffer from the XY-problem. –  zwets Mar 6 '13 at 19:22

3 Answers 3

Find your actual network configuration using ifconfig. You should see something similar to

eth0 Link encap Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.1.10 Bcast 192.168.1.255 Mask:255.255.255.0

Change your interfaces to

auto etho0
iface etho0 inet static
address 192.168.1.115
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 192.168.1.1

The actual change may need to be modified to something more specific for you. IE if you're routers IP is 10.0.0.1 then your gateway and dns-nameservers would need to be configured accordingly. I set the address to 192.168.1.115 because the odds of you getting enough connections to reach that IP and have any conflict from DHCP are slim to none. Let me know if this works for you. Good luck.

--Also. Your network adapter should be bridged.--

share|improve this answer
    
Thanks Morqan, your method worked perfectly. –  Ibn Saeed Jun 15 at 11:19

The easiest method is through network manager:

1- From the top of the screen select the network icon, next to the clock and volume, then click Edit Connections.

2- From the window that opens, go to Wired tab, select your connection (there should be only one connection, if you didn't touch anything). Then click Edit.

3- From the IPv4 Settings tab change Method from Automatic (DHCP) to Manual.

4- Under Addresses feild, click on Add.

5- Enter your desired IP address and subnet mask and click Save, you can also enter an optional DNS server here.

share|improve this answer
1  
Though this will get the OP a static IP address on the guest, it is unlikely to fulfill his/her wish "to browse the internet and use putty". If OP has left the configuration of the VM Network Adapter at the default (NAT), it is more likely that s/he will have no internet connectivity at all. –  zwets Mar 6 '13 at 19:20
    
yes I see, let me fix that. –  Soroosh129 Mar 6 '13 at 19:26
    
@zwets aha, you have an answer, so I'll wait to see your comment on me editing the post. –  Soroosh129 Mar 6 '13 at 19:28

If you want to connect your Ubuntu VM to the internet, there is no need to pick a static IP address. Assuming the host has an internet connection, and you have created a default (NAT) network adapter for your virtual machine, then just stick to DHCP in Ubuntu. It will get an IP address from the host and the host will do the NAT-ting to the internet.

If you insist on having a static IP address for the guest, then configure the virtual network adapter for bridged networking and allocate it to a network card on the host.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.