I installed Ubuntu 13.10 server (64-bit) in a VirtualBox 4.3.6 VM (Windows host) with one NAT adapter assigned. The only non-default software selected during installation was OpenSSH. So far so good... I could ping the world and the address is 10.0.2.15 as would be expected (per ifconfig the NAT adapter is eth0 at this point).
I want to access the VM via the host without any port-mapping. Since bridging isn't an option (I can't get a second direct IP from outside the host) I created a host-only adapter (with DHCP enabled and all), edited /etc/network/interfaces (duplicating the eth0 defaults for eth1), shut the VM down, attached the new host-only adapter (selected paravirtualized), and rebooted.
At this point /etc/network/interfaces contained the following:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
And indeed it all works... but per ifconfig the NAT adapter is now eth1, while the newly-added host-only adapter is eth0. I want it the other way around - and that leads to all kinds of problems!
First I tried adding the MAC addresses to the interfaces file, e.g., "hwaddress ether xx:xx:xx:xx:xx:xx" as I expect it to be for eth0 and eth1. No joy... that ends up breaking networking entirely. I commented out those lines and rebooted (I actually had to disable that host-only adapter and reboot again, then I could finally re-enable it... this may be a clue.)
Reading further, I see many references to updating /etc/udev/rules.d/70-persistent-net.rules to swap the MAC addresses. Great idea! Except that other than a README file /etc/udev/rules.d is completely empty. I tried "sudo udevadm trigger" (and a few permutations thereof)... no change.
So question #1: what happened to 70-persistent-net.rules? Is that deprecated? /etc/udev/rules.d is empty except for a README file.
Next, I tried the following:
sudo ifconfig eth0 down sudo ifconfig eth1 down sudo ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx sudo ifconfig eth1 hw ether yy:yy:yy:yy:yy:yy sudo ifconfig eth0 up sudo ifconfig eth1 up
Hmm. ifconfig now reports the expected mac addresses but the IP addresses are still as they were. So I reboot...
And again, networking is broken (it is around this point that one learns the merit of editing /etc/init/failsafe.conf to shorten network delays during the networking debug process). The contents of /etc/network/interfaces are unchanged from how they look above. ifconfig now reports that eth0 and eth1 have the same (NAT adapter MAC) address even though I really did swap the MAC addresses above. Restore the MACs per the same procedure and reboot and we're back where we started (eth0 = host-only and eth1 = NAT).
Therefore, the main question is: how do you swap eth0 and eth1 correctly on Ubuntu 13.10? On CentOS (given DHCP) it was as easy as swapping the MAC addresses in /etc/sysconfig/network-scripts/ifcfg-eth0 and ifcfg-eth1 and then rebooting. On Ubuntu it's like pulling teeth... everything that should work won't work, and I am stumped. I suspect there's something relatively new going on under the hood (thus the "missing" rules files and so on) but what could it be? Note that the network-manager isn't installed by default either (and it's definitely not present).
Update: Just for grins I created another VM with the same default server setup (including OpenSSH as before), with one network adapter (NAT). No change - networking works as it normally would for this configuration, but there's nothing in /etc/udev/rules.d except a README file (I even checked as root... nothing).