خرید بک لینک

I'm comfortable in software land but not server configuration land. Please redirect me if needed, this may be a stupid/misplaced question.

Context:

I'm using Ubuntu 14.14 within a VM on Oracle's VirtualBox. The VM's network setting is as a bridged adapter.

The host machine (for reasons I won't get into here) is a laptop that moves between a number of networks with differing configurations. For this reason, I have two configurations in /etc/network/interfaces that I switch between when I move from one place to the other. They look as follows:

When I need to be in "production" mode on one network (this works):

auto lo eth0
iface lo inet loopback
iface eth0 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.1
        dns-nameservers 8.8.8.8 8.8.4.4

When I'm on the "other" network and not in production but just need inteet access on the VM for development purposes and testing (this also works):

auto eth0
iface eth0 inet dhcp

What does not work, is switching from one config to the other on the fly with the VM ruing. Things I've tried (with sudo):

  1. dhclient -r eth0 then dhclient eth0 (doesn't work)
  2. service network-manager restart (doesn't work)
  3. any combination of 1 and 2 in varying order (doesn't work)
  4. restart the whole VM (works! ... but inconvenient)

Using ifconfig to see my results, when I try method 1, I sometimes get a lease on a new IP address but not the one specified in /etc/network/interfaces. With method 2, I see no change to my IPv4 address. With both of these methods (and method 3) I caot establish network coectivity when moving between physical networks. However, method 4 works every time.

Is there some way I can make this change to /etc/network/interfaces a live change, rather than one that requires a restart? Or is there a better way I should be approaching this configuration change when moving between networks? (In other words, it is a hassle to start the machine just to change the network configuration, then restart it immediately to have the changes take effect, every time I move this machine from one network to another.)

برچسب: نویسنده: استخدام کار تاريخ: شنبه 4 ارديبهشت 1395 ساعت: 4:59

صفحه بندی