Two IP addresses on 1 host (1 for host and one for guest)
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Two IP addresses on 1 host (1 for host and one for guest)
Hi,
I have a problem with setting up a working environment with a following configuration:
1 host OS on a dedicated server (Ubuntu, it's already working). It has an IP address XX.XXX.YY.YY with a mask of: 255.255.255.252 and the operator has assigned a second IP address: XX.XXX.YZ.VW, mask: 255.255.255.255
Gateway is the same of course.
I want to assign the second ip address to a VirtualBox VM. I have no idea how to do that, could you please help?
Did you tried NAT.?. As for as I know, Virtual box by default assign IP address using DHCP in range of 10.xx.xx.xx. With NAT your guest OS should work fine.
We have a similar situation here - additional IP addresses with netmask /32 assigned by ISP. You need to bridge the VM in virtual box. Then in your VM, put something like this in your /etc/network/interfaces:
Code:
auto eth0
iface eth0 inet static
address XX.XXX.YZ.VW
netmask 255.255.255.255
post-up ip route add XX.XXX.YY.YQ/255.255.255.252 dev eth0; route add default gw XX.XXX.YY.YP eth0
Where XX.XXX.YY.YP is the default gateway IP and XX.XXX.YY.YQ/255.255.255.252 is the network.
I tried what you wrote. In the configuration you wrote, there is absolutely nothing to configure on the host, only in the VM? If that is the case, then it's not working for me. I did apply what you wrote, but have not tampered with ifconfig on the host - it has it's first IP address. Doesn't work.
Basically, I am using virtualbox on my other dedicated server but there I have no problems at all -> because one of the providers allows me to use DHCP, so I bridge my VBox interfaces and if I have several of them, I get different IP's for different MAC addresses.
Unfortunately now I have to cope with different provider... So, to sum up:
"You have to create a virtual interface, we are routing IP to the main IP of your server: XX.XXX.Z4.42.
You have to resign from bridging because it is not going to work."
If .41 is refusing to route packets coming from .61, maybe you can route them through .42. To make that work, allow IP forwarding, FORWARD iptables chain and set static route on .42 and set default gateway on .61 to .42 instead of .41:
Code:
# on .42:
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -s XX.XXX.Z3.61 -j ACCEPT
iptables -A FORWARD -d XX.XXX.Z3.61 -j ACCEPT
ip route add XX.XXX.Z3.61/255.255.255.255 dev eth0
# on .61:
auto eth0
iface eth0 inet static
address XX.XXX.Z3.61
netmask 255.255.255.255
post-up ip route add XX.XXX.Z4.40/255.255.255.252 dev eth0; route add default gw XX.XXX.Z4.42 eth0
So, basically I have vboxnet0 interface with 192.168.56.1 on host machine. Virtualbox is in host-only mode. Virtualbox has 192.168.56.101 IP address assigned.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.