Question

I'm doing my client side development in windows and my server side in linux (Which I run virtually). My client side socket is set to connect on the inet addr of my linux server (using localhost never seems to work for me, I guess because I'm running linux virtually).

My main problem is that my inet addr keeps changing (usually increments by 1) and then I have to rebuild my client code and transfer it over to the server which is very annoying.

Is there anyway to manually set my inet addr or to keep it from changing?

Thanks in advance.

Was it helpful?

Solution

Edit /etc/network/interfaces and define something like:

auto eth0
iface eth0 inet static
    address 10.0.0.10
    netmask 255.255.255.0
    gateway 10.0.0.1

In this case, assuming your network address is 10.0.0.0/24, and the gateway (Windows machine) has the 10.0.0.1 as interface for your Linux machine. Also, this assumes you want to set the network interface eth0.

Then:

$ sudo ifdown eth0
$ sudo ifup eth0

The first one is to shutdown the network interface and the second one is to re-activate it with the new settings.

OTHER TIPS

Josh, this is because you are using dhcp. Make sure to set a fixed address. The easiest way assuming you run RH or CentOS is to run: system-config-network-tui

It looks like you are using DHCP and you are using bridging to get your virtual machine to access the network. Easiest way to check this, is by comparing IP addresses within the Windows machine and the Ubuntu machine: if they are within the same range, you're likely in bridging.

This means that your virtual machine is accessible from everywhere within your local subnet.

You could use the DHCP and DNS server (likely your router) to assign a fixed IP address to your Ubuntu machine.

You could also just refer to your Ubuntu machine by its DNS name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top