Assign static local ip address to OS inside virtual machine with bridged connection - windows-7

I have win 7 OS on my laptop, and linux(debian 7) inside vmware. I have set the debian to have bridged connection with the network. I am connected by wifi, and if the wifi modem is being restarted the local ip address of the debian changes, e.g. from 192.168.0.106 to 192.168.0.102. Is there a way to set the local ip address, so it will always remain the same ?
Thanks

You have to change your /etc/network/interfaces like this
and after that remember to restart your service using
sudo service networking restart

ok, found the solution
here is the source
http://www.cyberciti.biz/tips/howto-ubuntu-linux-convert-dhcp-network-configuration-to-static-ip-configuration.html
basically for debian
1) vim /etc/network/interfaces
2) comment/delete this line iface eth0 inet dhcp
3) add this
iface eth0 inet static
address 192.168.1.106 # this is the ip address you want to assign
netmask 255.255.255.0
network 192.168.1.0

Related

How to bind external ip to Vagrant VM?

I have external IP address. I added it to my eth0 interface of host machine. I can successfully ping it. I want to run VM using Vagrant and set my external IP to it (I want to call my VM just like a simple VPS using this external IP address). I have next line in Vagrantfile for this:
node.vm.network "public_network", ip: myExternalIP
After my machine start I see eth2 interface inside my VM with my external IP as inet addr. But I can't get access to any open port on my vm using this IP address. Maybe I don't understand idea of public_network in Vagrant. How to bind external ip to my Vagrant VM?
Update: As I understood vagrant set default gateway of VM to interface under NAT. Due to NAT packages cant be sent from VM to external world through bridged interface.
I got it working this way:
config.vm.network "public_network", ip: "192.168.0.17"

How to restart my network properly after binding two ips with single nic in debian?

I have binded two ips with single nic (Network Interface Card) in debian this way.
step 1:
vim /etc/network/interfaces into the following format:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
auto eth0:1
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
Now 192.168.1.100 and 192.168.1.100 are all binded with my local nic.
step2:
vim /etc/network/ifstate into the following format:
lo=lo
eth0=eth0
eth0:1=eth0:1
It is time to restart my network now.
/etc/init.d/networking restart
[....] Running /etc/init.d/networking restart is deprecated because it may not r[warnble some interfaces ... (warning).
[....] Reconfiguring network interfaces...RTNETLINK answers: File exists
Failed to bring up eth0.
Ignoring unknown interface eth0:1=eth0:1.
done.
ifdown eth0 && ifup eth0
ifdown: interface eth0 not configured
RTNETLINK answers: File exists
Failed to bring up eth0.
The two ip have been binded with single NIC when to reboot my pc.
I want to know the proper way to restart networking not to reboot it.
Typically to stop/start/restart the network interface on Debian:
/etc/init.d/networking stop
/etc/init.d/networking start
/etc/init.d/networking restart
To verify changes after making changes and restarting:
ifconfig -a
https://wiki.debian.org/Bonding

How to tunnel host traffic through guest in Virtualbox using Vagrant

I have a Ubuntu host and an Ubuntu guest. I want to achieve that my host traffic is tunnelled through my guest. Thus enabling me to do analysis on the host traffic from the guest. I am assigning two interfaces to the guest (in addition to the built in NAT interface which is provided by Vagrant). I am creating a bridge interface on the host called br0. One of the guest interfaces is connected via bridging to eth0 (the host interface which is connected to the Internet) and the other guest interface is connected via bridging to the host br0 interface. On the host I am deleting my default gateway and adding a new one with:
route del default
route add default dev br0
After that I can vagrant ssh into my guest and set up a bridge interface there as well with.
brctl addbr br0
brctl addif br0 eth1
brctl addif br0 eth2
After this setup the host traffic should be routed through the guest. If I run
tcpdump -vni br0
inside the guest I can see packets but I can't connect to the Internet. There is something missing. Any ideas?
I had to enable IPv4 forwarding in the guest.
Edit /etc/sysctl.conf to enable forwarding permanently:
net.ipv4.ip_forward = 1
Run this to activate the setting without a reboot:
sysctl -p /etc/sysctl.conf

How to Add Virtual Network Interface Mavericks

I like to have a separate virtual network interface on Mavericks, so I can have static IP between the Guest to Host setup of VirtualBox. In xUbuntu, i could do that by updating /etc/network/interfaces:
#The secondary network interface
auto eth1
iface eth1 inet static
address 10.88.12.4
netmask 255.0.0.0
How to do the same in Mac Mavericks? I did try using 'system preferences'->Networks->Actions Menu->Manage Virtual Network Interfaces->Add New VLAN, however, it is giving 'Status: Cable Unplugged'. How to make virtual network interface on Maverick? Thank You
The solution was letting VirtualBox create the virtual network interface by creating "Host Only Network" by going VirtualBox VM -> Preferences -> Network -> Host Only Networks -> Add New and set up the IP/Subnet at that time
Afterwards, check the new virtual network interface by typing "ifconfig" in the command line. It will desiplay something like:
vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00
inet 10.88.12.0 netmask 0xff000000 broadcast 10.255.255.255

Boot2Docker: Connect to container over LAN

I'm using Boot2Docker 1.3.0 on my Mac and I'm pretty happy so far using it. But now I'd like to connect to a http container (exposes port 8080) not from my local machine but from another machine in my local network? If I'm doing it locally I just use http://192.168.59.103:8080 so I'm using the ip address of the docker host. This can't work for other machines in my local network but using the ip address of my mac does not work either. I'm pretty sure there are some solutions for this problem but I can't find any. It can't be that hard right? What I want is to make a request to http://[IP-Address-of-mac]:8080 from another host in my local network. I think I have to set up some routing rules on my local machine right? May anybody tell me what to do? Thanks in advance.
Best regards
Sascha
You need to port forward from the OSX box to the virtual machine
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port8080,tcp,,8080,,8080";
should do the trick
or, you could use ssh based port forwarding:
boot2docker ssh -L 8000:localhost:8000
see https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md
On your Mac, determine the IP address that it uses on your local LAN:
$ ifconfig | grep 192
inet 192.168.1.21 netmask 0xffffff00 broadcast 192.168.1.255
inet 192.168.59.3 netmask 0xffffff00 broadcast 192.168.59.255
Then port forward:
$ boot2docker ssh -vnNTL 192.168.1.21:8080:localhost:8080
Now, requests that come into your Mac on port 8080 will get forwarded to the boot2docker Linux VM on port 8080. The docker server will then forward from the exposed port (VM port 8080) to the port your container is using for httpd (probably 80).
Note that "localhost" above is from the point of view of the Linux VM, not the Mac, because that is the host you are ssh'ing into.

Resources