Permanent local IP on Windows and Ubuntu systems

1

1

I use an Ubuntu system and frequently connect to my parent's Windows system on the local network. But, using DHCP, the computers IP address are always different, making it a chore to find what IP address the machines are before connecting to them.

Is there a way to let the systems ask for a permanent IP address from the DHCP server?

Oxwivi

Posted 2011-11-26T08:19:45.490

Reputation: 312

Do not connect to addresses; connect to names. – user1686 – 2011-11-26T13:26:23.993

@grawity How would that work? If, for example, I had a web UI running on port 8080 of a computer named Example-PC, what do I write in my browser? – Oxwivi – 2011-11-26T13:59:41.107

http://Example-PC:8080/ – user1686 – 2011-11-26T14:13:03.283

@grawity Doesn't work. – Oxwivi – 2011-11-26T14:58:49.973

@grawity It did work, when I wrote the name of my Ubuntu system when using it. But it did not resolve the Windows system. – Oxwivi – 2011-11-26T15:46:48.923

I had forgotten the "Ubuntu" part, sorry. Install nss_wins on Ubuntu, that should allow it to use the Windows name service. I had posted more details in an earlier question on local name resolution.

– user1686 – 2011-11-26T15:51:47.590

@grawity Not sure what package provides that, but I probably already have that, since I have /etc/nsswitch.conf. Do I need to enable anything in it? And you might want to hammer out an answer. – Oxwivi – 2011-11-26T16:07:29.897

nss_wins might be part of the Samba package on Ubuntu (which makes sense, since it is part of Samba, but I remember Debian packaging it separately). The presence of nsswitch.conf means nothing; it is a generic "name service switch" config file. To enable nss_wins and access Windows from Ubuntu, you would simply edit the "hosts" line in this file - I think it will be done automatically. (To access your Ubuntu from Windows, you'll need the "samba" service running; again, automatic.) – user1686 – 2011-11-26T16:22:17.530

In installed Samba, nmbd started running, except that the computer names are still not resolved. Wonder if I should reboot. – Oxwivi – 2011-11-26T16:35:48.000

@grawity It's working now, please post an answer, so I can select it as the solution. – Oxwivi – 2011-11-26T17:21:52.790

@grawity Or maybe not, sometimes it works, sometimes not. :( – Oxwivi – 2011-11-26T19:08:00.687

Answers

1

Check your parent's router settings, under DHCP there should be an option for allocating a fixed address to a given MAC address. I've not come across a router that doesn't allow you to reserve an IP address.

Tog

Posted 2011-11-26T08:19:45.490

Reputation: 4 747

3

You need to set a static IP.

Ubuntu

Run the following, and note down the netmask and gateway:

sudo ifconfig 

Edit /etc/network/interfaces, and, assuming your NIC is eth0, add the IP, netmask and gateway addresses noted earlier:

auto lo eth0
iface lo inet loopback
iface eth0 inet static
address xxx.xxx.xxx.xxx # enter your IP address
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx

Windows

Run ipconfig command in Command Prompt to get the default gateway and netmask.

  1. Open Network Connections

  2. Right-click the network connection you want to configure, and then click Properties.

  3. On the General tab (for a local area connection) or the Networking tab (all other connections), click the Internet Protocol (TCP/IP) component, and then click Properties.

  4. Click Use the following IP address for a local area connection, in IP address, Subnet mask, and Default gateway, type the IP address, subnet mask, and default gateway addresses.

  5. Click Use the following DNS server addresses.

  6. In Preferred DNS server and Alternate DNS server, type the primary and secondary DNS server addresses. This is usually the same as your default gateway

If you need to do something more advanced here's the official howto for Windows and a howto for Linux.

Journeyman Geek

Posted 2011-11-26T08:19:45.490

Reputation: 119 122

Can't this be done on a network-by-network basis? It's a wireless netowrk (I tagged the question as such), and could cause a problem if I connected to a different network. Or if there are some other system connected to the system using the IP addresses we defined. – Oxwivi – 2011-11-26T08:57:14.617

unfortunately you cant do what without some form of connection management. there's no reason static IPs shouldn't work on wireless though – Journeyman Geek – 2011-11-26T09:46:17.910

I'm not saying static IP won't work on wireless networks, I'm saying there might be IP address conflicts if I connect to a different network. Or can I ask to be assigned an IP address near the limit of the address space? (192.168.1.100)? And my Ubuntu system is a desktop, got NetworkManager. – Oxwivi – 2011-11-26T14:02:39.260

that would probably work - but most systems i run seem to favour IP addresses between 192.168.1.100-200... so going low might work better – Journeyman Geek – 2011-11-26T14:05:06.007

I don't know, in my network, there are three systems which revolves around .2, .4, and .6. It depends on the network, then? This is annoying... – Oxwivi – 2011-11-26T14:44:34.323