I have a laptop with lubuntu 11 with two network interfaces, wireless and wired. Wireless interface connects to the router with DHCP and provides access to the internet. The wired interface has a staic ip address from a different range for internal LAN. I would like to allow computers on the LAN get access to internet using laptop's wireless connection. What are my options here? Do I need a bridge, NAT, firewall?
Ubuntu – sharing internet between network interfaces
Yes, that is what you need to do. Sharing an internet connection using Network Manager will setup the sharer as a DHCP server, etc, which is not what you want.
You can read how to do it here: http://manpages.ubuntu.com/manpages/lucid/en/man5/bridge-utils-interfaces.5.html
Ok it works like this, when you are INSIDE the virtual environment just forget about virtualbox. Assumming you have the following setup, it should all work out:
MAIN HOST (The one where you are running virtualbox with both guess insides) - It should have an internet access. Does not matter if it through a proxy, inside an intranet or a normal connection to your ISP. It should have access to the internet.
VIRTUALBOX - VIRTUAL HOST (UBUNTU) - It should have one network connection to your MAIN HOST which provides internet and one network connection (Called by default Internal Network) which we will use to share the connection. It should be noted that after finishing the whole sharing explanation this can also work if the HOST is Windows.
VIRTUALBOX - VIRTUAL GUEST (WINDOWS) - It should have one network connection to the "Internal Network".
With all of this setup in that specific way you can do the following:
VIRTUAL HOST (Ubuntu)
- In your Ubuntu 10.04 go to Connection Indicator in the Panel (Network Manager Applet)
- Go to Edit Connections.
- Select your INTERNAL NETWORK interface (Since you will see 2, example eth0 and eth1. One of them is the internal one that connects to the rest of the virtual guests and the other one connects to your MAIN HOST) and open it.
- Go to IPv4 Settings and in the Method field select "Shared with Other Computers".
- Apply and you are done with the VIRTUAL HOST (Ubuntu). Now for the VIRTUAL GUEST (Windows).
NOTE - Some people might suggest a little more complicated iptables, masquerade console commands. There is no need for this since (I think) Ubuntu 9.04 or higher. Since the Network Manager updated itself several years ago everything from Modem, Cellphones and shared wifi connections has been easier than ever.
VIRTUAL GUEST (Windows)
Go to the "Network Manager" in Windows and select the only connection you have. Go to the Ipv4 TCP Protocol and verify that it has the IP set to Dynamic/Auto. It should now see the connection from the ubuntu box. IF by any case it does not work, since you have Windows 7 which includes a pretty nifty way of checking for internet acces you should run this tool from the network manager in windows and make it look for the internet. in this same manner I have made around 50 setups for windows xp, windows vista and windows 7. Most of which are for windows 7. So I might be going out of a limb here but for 50 tests am pretty sure this will work ^^.
NOTE - There is actually no need for a DHCP Server like in Ubuntu server to share. There is also no need for a DNS server in windows. The default setup that comes in ubuntu and windows can deal with a simple task like this. The thing to remember here is that, when inside the virtual environment just forget about the host. Imagine yourself in a lan party with 2 PCs which one has an internet connection and another connection to the lan and the other PC wants to have internet shared to. Eliminating the association between the virtual place and the real place (MAIN HOST) helps in solving several network problems.
NOTE 2 - Additional you NEED (Let me rephrase that, YOU REALLY REALLY!!! NEED) to use the version from VirtualBox and the Extension of Virtualbox to have everything working as it should. The latest version up to this moment which is the 4.1.4 version which came on October 3rd has many problems solved and since version 4.1.2 I can vouch that the horrible problems about random mouse movement and sharing virtual folders is gone.
The latest version can be found here: https://www.virtualbox.org/wiki/Linux_Downloads
And the extension for the latest here: https://www.virtualbox.org/wiki/Downloads
Why am I making such a big fuss over using the Virtualbox from the site and not a PPA or the OSE version. Because first Virtualbox will add after installing the package (Just double click it after downloading it) the ppa or repo to get the latest updates. Second the OSE has many less features than the one in the webpage (This difference started from when innotek was the main company and in those days OSE and virtualbox normal were the same). Now the virtualbox from the main page has way too many more things. Also many PPA out there are obsolete or not updated so fast as the main repo from virtualbox.
NOTE 3 - Since Virtualbox 4.1.4 there is no need to download the extension again. Virtualbox will automatically check to see if the extension is compatible or up to date with the latest version installed. But you still need to install it if you haven't yet done so. At least the first time. After that there is no more need to do it.
Lubuntu comes with Network-manager, which makes this very easy. Click on the network icon in your panel, and select Edit connections.
In the dialog that appears, select the wired interface and click Edit. In the IPv4-settings pane in the new dialog, you can select Method: "Shared with other computers".
Any internet connection will now be shared on your wired connection, complete with DHCP.