Is there a way to tell the difference between a direct connection and network connection

1

I want to configure a linux(ubuntu) machine such that when a direct connection is made with another PC my machine will enable a DHCP server and serve it an IP address, but if my machine is connected to a network with an existing DHCP server I want make sure my DHCP server is disabled and obtain an IP-address from the networks DHCP server.

If there are any better ways to manage the direct connection than having my own dhcp server, great. The only thing is that I do not want to use static IP addresses or force the external computer to use a static IP addresses.

So heres the two situations:

1. Us DHCP to serve an address to the PC

Linux box ------------- PC

2. Obtain an address automatically from the network

Linux box ------------- network

I want to automatically do the appropriate thing depending on what my machine gets connected to.

richmb

Posted 2012-10-17T21:17:38.400

Reputation: 143

What do you mean by a "direct connection" to another PC? – John – 2012-10-18T21:48:14.390

as in someone uses an ethernet cable with one end connected to my linux machine and the other to a PC. I'm assuming that Auto-MDIX will take care of the crossover-ness. – richmb – 2012-10-19T14:21:15.433

1Having a DHCP server running on your machine to serve a local NAT that's routed to your WAN is not mutually exclusive with having your WAN interface obtain an IP from a downstream DHCP server. You can just use NetworkManager to turn on connection sharing (similar to Windows' ICS) and it'll do the appropriate routing rules, DNS, DHCP, etc. – allquixotic – 2012-10-19T14:35:36.273

I think I'm going to enable dhcp fallback/auto-ip(avahi) on the linux machine and see how that works – richmb – 2012-11-05T13:43:15.150

No answers