Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I have my home network configured with DHCP (linux web server, 2 windows hosts) and now i want to have static ip adresses. My DHCP server is the router, not the linux server. How can i do that.
Hi,
I have my home network configured with DHCP (linux web server, 2 windows hosts) and now i want to have static ip adresses. My DHCP server is the router, not the linux server. How can i do that.
Thanks
Based on information you supplied I'd say you have to edit some configuration file in your Linux box. If you tell us what distro you are using then we can tell you what file it is. If you have a GUI installed then there may be a GUI tool for this.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
On the Linux side of the world, you need to edit the file that contains the settings; it will be named something like inet1.conf or similar and will be in the directory containing your system's start up files in /etc. If you grep for the file name, there should be a pattern like DHCP_HOSTNAME in the file (you will need to disable that, by the way).
Here's an example of inet1.conf set up for fixed IP:
Code:
# This file contains the configuration settings for network interfaces.
# If USE_DHCP[interface] is set to "yes", this overrides any other settings.
# If you don't have an interface, leave the settings null ("").
# You can configure network interfaces other than eth0,eth1... by setting
# IFNAME[interface] to the interface's name. If IFNAME[interface] is unset
# or empty, it is assumed you're configuring eth<interface>.
# Several other parameters are available, the end of this file contains a
# comprehensive set of examples.
# =============================================================================
# Config information for eth0:
IPADDR[0]="192.168.1.20"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""
# Config information for eth1:
IPADDR[1]=""
NETMASK[1]=""
USE_DHCP[1]=""
DHCP_HOSTNAME[1]=""
# Config information for eth2:
IPADDR[2]=""
NETMASK[2]=""
USE_DHCP[2]=""
DHCP_HOSTNAME[2]=""
# Config information for eth3:
IPADDR[3]=""
NETMASK[3]=""
USE_DHCP[3]=""
DHCP_HOSTNAME[3]=""
# Default gateway IP address:
GATEWAY="192.168.1.1"
<more stuff below this, nothing to do with fixed IP>
That is, the fixed IP address of the system is 192.168.1.20, the gateway address (the router) is 192.168.1.1 and the netmask is 255.255.255.0. You system will probably have values in the DHCP fields for eth0. Don't just copy the above, look for your file and read through any notes that may be in it. You may want to add your system name and the fixed IP address you've chosen (you may not want 192.168.1.20) in /etc/hosts.
On the Windows side of the world... well, can't really help your there but I run my Linux boxes fixed IP and a Windows (XP) machine as DHCP to the same router and it all works fine. Other than that, can't help you with Windows.
You have to have your static IP address on the same subnet. For instance, if you have net 192.168.1.0/24, (mask 255.255.255.0) then use static address 192.168.1.something.
The way you do this depends on whether you want your router to offer dhcp to other machines or not. So you could set up static IP on your linux box and, when you are sure this is working turn dhcp off on the router.
An alternative approach is to the one I suggest in my earlier post. Restrict the range of addresses the router offers, up to for example 192.168.1.200 and set your static address for 192.168.1.201. The reason for restricting the range is to make sure that 192.168.1.201 is not given to another computer while yours is off.
Alternatively you set your router to always associate your PC with a particular address. You still connect to it dynamically with dhcp but the router always allocates the same address. This way you need to configure the router but do not need to change anything on the PC.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
The inet1.conf example I gave you above is from Slackware 12. If you have, say, a Linksys router, it by default starts DHCP addresses at 192.168.1.100; 192.168.1.2 through 192.168.1.99 can be used for fixed IP addresses (192.168.1.1 is the gateway address, don't fiddle with that). As suggested above, you can log in as root and use the netconfig to set this rather than manually editing inet1.conf
If you set your server to 192.168.1.10 you should be fine and your Windows machines will use 192.168.1.100, 192.168.1.101, etc. Don't forget that you'll need to reboot after making the changes (rebooting is the easiest way to have the setting take effect).
This assumes that you did not set your router to any other addresses or that it defaults to 192.168.1.X -- you may need to check that by pinging the address 192.168.1.0 for a response (and if you don't get one, use a browser to look at the router's settings referring to the manual that came with it).
It really is this easy, just edit inet1.conf (or run netconfig) and reboot.
When I did this my main problems were with setting the gateway address and with setting the DNS address that the netconfig script offers. I think that in the end I found that it worked if I entered the same address as gateway for DNS. Until I got that right I could connect to the router but not to the Internet.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.