I can create a network between my ubuntu 14.04 and another machine by connecting ethernet cable between my ubuntu machine and second machine, and then setting "IPv4" to "share to other computers". The network created has IP that's something like 10.42.0.x. I'm doing this not to share internet, but to create a network between two machines, and this works very well.

For the two machines to address each other using hostname, I'd edit their /etc/hosts with respective IPs. I'd like this to be simpler, using MAC to IP mapping that's found in modern routers. What would be the easiest way to accomplish this?

  • How could that be simpler than adding a line to your hosts file? – Jos Apr 10 '15 at 12:59
  • The second machine is my raspberry pi, often run headless and buried in another machine. I network between that and my ubuntu and run heavier computation (machine vision for example) on the ubuntu. Current (above) setup require getting DHCP leased address from raspberry pi to edit into /etc/hosts. an easiler solution would be to map that specific MAC to an IP. How does ubuntu handle internet sharing internally? – Bill Apr 10 '15 at 14:32
  • Are you saying that your are already running a DHCP server on your RPi? And is the RPi running Ubuntu also? If yes, yes, then the answer will be very easy. – Doug Smythies Apr 10 '15 at 14:40
  • Sorry if it didn't came across clearly - RPi eth0 is only DHCP client. My ubuntu (on laptop) becomes DHCP server when I enable the "shared to other computers" option in network manager. – Bill Apr 10 '15 at 15:08
  • As I dig deeper, it appears internet sharing of network manager causes a command line execution of dnsmasq (not daemon) with HARD-CODED lease address range and options, and afaik not configurable, e.g. setup static leases.. Can anyone confirm this? – Bill Apr 10 '15 at 15:12

Typically, IP address assignment based on MAC is achieved via a DHCP server and its configuration file in /etc/dhcp/dhcpd.conf. The below example reserves a pool of IP addresses for guests, and the rest are assigned based on MAC:

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks...

default-lease-time 86400;
max-lease-time 93000;
option domain-name "xxxxxx.com";
option domain-name-servers;
option subnet-mask;
option broadcast-address;
option routers;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# The Basic DHCP allocated addresses

subnet netmask {

# Some specifically declared static IP addresses

host Wireless-R {
  hardware ethernet 00:22:6B:82:01:55;

host Doug-XPS {
  hardware ethernet 00:23:4d:a6:ed:c4;

host Doug-XPS {
  hardware ethernet 00:23:4d:a6:ed:c4;

host Doug-XPS2 {
  hardware ethernet 00:21:9B:F9:21:26;

host S10 {
  hardware ethernet A0:F3:C1:10:22:EA;

Alternatively, and if you prefer to use dnsmasq, or are already using it by default, you can specify via MAC in /etc/dnsmasq.conf via:


Disclaimer: I am actually not familiar with dnsmasq, but the DHCP example is directly from my system.

  • thanks! current network manager appear to run dnsmasq with some references to external config files.. if that works I'll try your static ip line. I'll test that on my work machine monday. Thanks for your detailed example! – Bill Apr 10 '15 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.