2

I am about to set up a pc with ubuntu server 14.04.1. I want to assign it a static ip address. How can I find a valid IP address that is not already being used? Is there a way to do that from terminal?

2
  • 3
    Do you want a static IP inside the network or globally?
    – s3lph
    Sep 2, 2014 at 18:27
  • Inside the network.
    – Cam Jones
    Sep 2, 2014 at 21:11

2 Answers 2

4

You can only tell by looking at the router's list of assigned IP addresses. But the best way to accomplish this is to assign a fixed address from the router, not the computer. That way, the computer will get a fixed address via dhcp without messing with the configuration at all, and without worrying about a conflict if the router assigns that address to another device first.

There's no easy way for the Ubuntu client to know what other IP addresses have been assigned on the network.

4
  • Thanks, I ended up doing network auto-configuration. because of some uncertainties, and now I'm trying to switch internal IP from DHCP to static while keeping the same IP, so I don't think that method will work the way I want it to. Anyways thanks for answering my question.
    – Cam Jones
    Sep 4, 2014 at 1:27
  • If this is a home router, and you can't use the method I proposed, it might be best to use a number a lot higher than the current IPs, since the IPs are normally assigned from low to high addresses. Sep 4, 2014 at 1:30
  • the only reason I don't want to use your method is because I want to keep the IP that was already assigned to the machine, instead of pulling a new one because I have already set up Webmin, a remote administration tool, and I don't want to reconfigure it.
    – Cam Jones
    Sep 4, 2014 at 1:34
  • I've done that. Assuming your router is the same as the one's I've used, you can assign the current address as a permanent (static) address. I do that often so I don't need to reboot the router to assign the address. Sep 4, 2014 at 2:11
2

You can find the IP addresses of devices currently connected to your local network by doing

sudo arp-scan --interface=eth0 --localnet

if your current machine is using the wired connection eth0 interface (use ifconfig to see what your interface name is). These will of course change if you have dynamic addressing on those machines. On my server I just picked something well out of the range where most of the other addresses were (e.g. my gateway is 10.0.0.1 and I chose 10.0.0.120).

5
  • This is the output of the command, sudo: arp-scan: command not found.
    – Cam Jones
    Sep 4, 2014 at 1:20
  • Sorry that's another package to install. First do sudo apt-get install arp-scan
    – adamconkey
    Sep 4, 2014 at 1:23
  • That's a pretty cool application, does that show only wired connections, or does it show wired and wireless?
    – Cam Jones
    Sep 4, 2014 at 5:14
  • wired and wireless, though obviously it excludes the address of the machine you're issuing the command from. there are a lot of other options as well that you can explore: linux.die.net/man/1/arp-scan
    – adamconkey
    Sep 4, 2014 at 15:11
  • Thanks for the link, If I could choose 2 answers I would but I feel the other way is more full-proof.
    – Cam Jones
    Sep 5, 2014 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .