Having internet with USE_DHCP="" in rc.inet1.conf possible?
Hi: If I want to have static local IP address but my ISP only provides me DHCP, is that possible? To make the local hosts IPs static, I have to have
IPADDR[0]="192.168.0.2" #Example NETMASK[0]="255.255.255.0" in /etc/rc.d/rc.inet1.conf But then I must have USE_DHCP[0]="" and then I am left without internet. Is this dilemma solvable? |
If I am correct, this is possible *only* if your ISP provides you a fixed IP address (IOW when you request an IP address, the DHCP server of your ISP always gives you the same one).
Then you can just use the "static IP" option of 'netconfig' to set up your wired network connection. I assume the NetworkManager option is usable as well for that, but didn't actually check. |
Thanks. My ISP only gives dynamic IPs. But there must be a way I can choose an IP for the machines in my LAN. For the moment, what I do is to run ifconfig and use the IP appearing to the right of inet. Example:
# ifconfig eth0 inet 192.168.0.100 and I use 192.168.0.100 for that machine. But then, may be tomorrow, I run ifconfig and the inet number has change, which is very upsetting. Is there a solution? |
If you try putting the following in a file under /lib/dhcpcd/dhcpcd-hooks/
Code:
ip addr add 192.168.0.100/24 eth0 There are examples for other distros but they have totally different network configuration systems so I don't know how to convert them over. |
Does one of your boxes act as a NAT router, or are they all directly connected to the Internet ?
|
The two computers in my LAN are connected to a NAT router and this to the cable modem.
|
Hmm.
Did you set a default route (Shown as "GATEWAY" in rc.inet1.conf) when you tired the static only settings? |
Yes, I put
GATEWAY="192.168.0.1" which was in the output of the route command. |
Following from my suggestion in your thread, the answer is YES.
You do not need to use any Windows setup software. You can access your router and do configuration using a web browser on your Slackware box. Again, from the manual Quote:
When this is completed, your Slackware box will always be assigned the same IP address. The behaviour will be exactly like assigning a static IP address to your Slackware box. I do this with my setup, so that my desktop, laptop wired interface and laptop wireless interface are always assigned the same IP address. This is necessary for me to be able to use NFS without addressing issues. I think you need to understand the steps involved in establishing your connection to the internet. When you turn your router on, it sends out a DHCP request to your ISP's DHCP server and the ISP's server responds and assigns your router a WAN IP address. As you have seen, this is likely to be different from one connection to the next. This is the IP address that would be reported if you were to do a query to whatsmyip or similar. Your router also contains a DHCP server (enabled by default with your hardware). If you have your Slackware box set to use DHCP, it will send a DHCP request that will go to your router's DHCP server. The router's DHCP server will respond and assign your SLackware box a LAN IP address. By using address reservation, this will always be the same IP address. |
You are the first person who explains this with clarity. It's now a week long since I began reading the Linux Network Administrator's Guide, only to find, just now, that is does not mention DHCP anywhere. I've lost my time. Now I am reading http://www.tldp.org/HOWTO/Cable-Modem/index.html but I'm afraid the part covering DHCP is inaccessible.
What I can't understand is that my problem has to be a very common one for people having two computers connected to the same ISP account. Why pay for two accounts? |
You don't pay for two accounts. Your problem is a problem in understanding, it is neither a physical nor a hardware problem, so for most people it is not a common problem. From reading your threads I get the feeling that you tend to over-complicate simple things, preventing yourself from seeing the simple solutions. I will explain it once more here, as I have done in your other thread regarding the same topic (in the future please ask follow up questions in the already existing thread).
Your router and the PCs in your local net are totally independent from your modem and the Internet. While your modem gets an IP from your ISP (via DHCP) this has absolutely nothing to do with DHCP in your local network. Again, those networks are independent, your local machines don't care at all (and don't need to know) how the modem gets its IP. Just give them a static IP, set the router as gateway and all is fine. |
Quote:
|
OK. But I repeat once more. If I put USE_DHCP="" I am left without internet. Are the settings in inet1.conf LAN settings or WAN settings?
|
To use DHCP you want USE_DHCP="yes"
The settings in rc.inet1.conf are LAN settings in your setup. |
Quote:
Code:
nameserver 192.168.0.1 |
I'll try first doing it the simple way, as TobiSGD says and, if I succeed, I will then do it as allend says (1). So, if I understood well, I must do
IPADDR[0]="192.168.0.2" #Example NETMASK[0]="255.255.255.0" USE_DHCP[0]="yes" GATEWAY="<the IP the modem gets from the ISP> However, I've already done this and it did not work, but I'll do it again. That is, I will have internet, but the IP of this machine won't be 192.168.0.2. By the way, what do you mean "set the router as gateway", TobiSGS? Anything to do with GATEWAY=? (1) If I don't, I'll follow allend anyways. |
If all you want is a static IP on your machine while being able to access the internet through your modem, you only need to set up 3 things manually while disabling DHCP:
Keep in mind that if you switch again to using DHCP without telling it to keep the resolv.conf file as-is, it will be overwritten. |
Now you are finding out why DHCP will ultimately be better and easier. DHCP handles the gateway, network mask and name resolution stuff automatically.
The gateway address is the LAN IP address of your router, probably 192.168.0.1 |
Quote:
See this example: Code:
PC1 (IP: 192.168.0.100)-- Quote:
Quote:
|
I'm in agreement with allend here, as I mentioned in the other thread. Leave the machines as DHCP and use the simple web interface of your router to give them static IP addresses.
There's just a small thing that's not quite clicking that's making this seem a lot more complicated than it is. This looks like it might describe what's going on: http://networking.nitecruzr.net/2005...at-router.html You could also google "NAT Router" but some of the explanations are long-winded and take in more cases than the simple home network. |
I use a setup similar, I think, to what you're trying to do; maybe this will help (and, well, maybe not but here goes).
I've had DSL and now satellite service. The ISP provides a modem or modem/router that typically is DHCP -- you connect a computer to it (say a Windows machine) and away you go (Windows machines all default to DHCP). Typically, the modem has an address such as 192.168.0.1 or 192.168.1.1; that is you gateway (to the internet) address. The other side of the modem, the Internet side, has the address assigned to you by the ISP server which will vary every time the modem is turned off for a while then turned back on (that's what DHCP does at the ISP end, it "leases" an address to your modem at power up). On your side of the modem, when you power up a computer, the modem's DHCP assigns an address to your connection, something like 192.168.1.100 (and these addresses can vary, but they'll never be 192.168.0.1 or 192.168.1.1, the gateway address). Now, you want to connect multiple devices to your Internet connection; computers, printers, TV set-top, whatever, and you want it wired (or maybe wired and wireless, who knows). So, you get yourself, oh, say a 4-port router. What the router gives you is route for your devices to talk to each other and to the Internet. You can do this with either DHCP or fixed-IP, both of which require a little bit of configuration so everybody knows who they are and who everybody else is (think telephone numbers here, might make it easier). When you installed Slackware you were questioned about setting up your network; you gave each system a name and a domain (maybe). If you chose DHCP, you were all done; however, if you chose fixed-IP, you were prompted to enter addresses. Here's the trick: DHCP (in the router) will usually start leasing at 192.168.1.100 (or something like that, it won't start at 192.168.1.2). That means that you can specify the address of each device from 192.168.1.2 through 192.168.1.99 -- pretty neat, huh? And, wonder of wonders, the router will handle that just fine. You don't need to set anything in the router for this to work -- well, you do have enable DHCP in the router if it isn't enabled by default, but you don't have to list server addresses in there. My in-house systems are fixed-IP (I prefer it that way). When I execute netconfig (the Slackware utility you set up you network with), I give a name, an address, netmaksk, gateway address and a DNS address. Those are saved in /etc/rc.d/rc.inet1.conf and look like this: Code:
# Config information for eth0: Code:
192.168.1.10 fubar.com fubar Simple? Yup. My /etc/hosts file (on every server) looks like Code:
# For loopbacking. Can you do this same thing with DHCP? Of course. This link, http://www.linuxquestions.org/questi...9/#post4826521, will take you a example of a working DHCP network configuration (with thanks to @kikinovak, a pretty smart guy). As you scan though it you'll see that device names and addresses are assigned and DHCP (in the router) will honor those. The important thing is that devices configured with fixed-IP or DCHP (as described) can find each other (so you can do stuff like use scp between them without fooling around). Now, you can plug a Windows box into your router and it'll work (to the Internet anyway) because the router will give it a lease at 192.168.1.100 or so and that will not interfere with your configured device addresses. Pretty slick. Hope this helps some. |
Quote:
Code:
ssh: connect to host SERVER_HOST port 22: no route to host. EDIT: thank you tronayne for your kind advices. |
If you're using static addresses, fixed-IP, add all devices to the /etc/hosts file on all machines, then they can find each other.
Oh, yeah, when you change network settings it's a good idea to reboot the machine you changed 'em on (if you didn't already do that). You don't need to reboot any others. |
Quote:
ifconfig eth0 192.168.0.2 then all is fine. But when I reboot, I am again 192.168.0.100! |
On that box run netconfig. Give it name, domain, netmask (the default ought to OK), address is 192.168.0.2, gateway is 192.168.0.1, DNS, oh, 8.8.8.8 (that's Google's DNS server). Review the settings on the page that pops up and exit netconfig.
netconf wipes out /etc/hosts, so edit in the other machine(s) names and addresses. Reboot. Ought to do it. |
Quote:
This is, I find, quicker to set up than setting a fixed IP on each machine individually and means that if machines are taken from your network and plugged into a new network they'll likely start to work there too. It also leaves the rest of the DHCP range for any new devices you introduce. Of course host file entries still need adding for other machines on the network but that should be easier to explain one the router settings have been seen. Personally, that is how I would solve this particular problem. That and some reading of the principals involved. Perhaps it's just me but using manually configured fixed IP addresses seems a little "old fashioned" and long-winded? |
To run netconfig is what I did, but no use. Now, in /etc/resolv.conf I put 192.168.0.1. Should it be 8.8.8.8?
|
Most routers that I've fiddled with tend to lose their little minds doing DNS (maybe that's changed, but I dunno) -- for some reason or other they stop serving DNS after a period of time and I find it more useful to simply put entries in /etc/resolv.conf. At least the one's I have do that.
You ISP ought to provide one or two DNS addresses or you can use Google's freebies (8.8.8.8 and 8.8.4.4) and your /etc/resolv.conf ought to look like this: Code:
cat /etc/resolv.conf You only need two; if the first on the list is dead, you'll sit there for quite a while waiting for the timeout to switch to the second (and so on if you have more). Trick is, ping the addresses and select the one that's the fastest to be first. |
Honestly, I don't understand well this DNS subject. One thing I know is that I do not have BINDS activated. Neither dnsmasq. I thought that in /etc/resolv.conf I have to put the IP of the gateway, which is 192.168.0.1 in my case, according to the route command.
On the other hand, I have two workarounds to momentarily solve this problem: One is to put the line ifconfig eth0 192.168.0.2 in /etc/rc.d/rc.local, so it executes each time the system boots. The other, and the one I chose, given that the ifconfig command insists in tell me that my ip address is 192.168.0.100, is to choose this ip for this machine. Doing this, all works fine. But I do not know why I can't choose an arbitrary ip in the range 192.168.0.0 192.168.0.254. |
Quote:
|
In fact, that is what netconfig did by default.
|
Quote:
|
The router probably caches and forwards dns
So from the machine that won't keep the ip address you are attempting to give it, can you post your rc.inet1.conf ? |
Quote:
Tip: do not accept a proposed setting unless you know it is appropriate in your case. |
Quote:
Code:
root@SERVER_HOST:~# cat /etc/rc.d/rc.inet1.conf |
When you originally configured networking, did you enable network manager?
Try doing 'ls -l /etc/rc.d/rc.networkmanager' and see if the file is executable |
Quote:
|
But he's been trying a few different configurations and might have initially chosen network manager, I am not positive whether doing a second netconfig after having setup network manager actually disables it from running - it very well might, but I haven't tried it so I thought it might be worth checking in case it acts as if its the first time you set up networking each time its run
|
I just had a look to 'netconfig' to be sure.
After the configuration is complete and if the user confirms it, the config files are (re)written. So the new settings override the previous ones. IOW, yes, the script takes care of cleaning the house. Knowing that it was mostly written by Patrick Volkerding, this is not very surprising ;) But setting a file in /etc/rc.d executable or not is up to the admin. |
Right. So my suggestion is simply to confirm that it is not executable,
in case on his first install he configured with network manager, netconfig would do if [ "$NETWORKMANAGER" = "yes" -a -r etc/rc.d/rc.networkmanager ]; then chmod 755 etc/rc.d/rc.networkmanager And then on second netconfig to change to static ip it might still be +X and trying to grab a dhcp addy |
Quote:
|
Yes, it is there and is executable.
|
Ok, as root just chmod -x /etc/rc.d/rc.networkmanager so that networkmanager doesn't start and interfere with your static settings, then probably simplest to reboot at that point once more
|
Yes, I already did, and now ifconfig shows the ip I set. How clever you observation. Thank you very much.
|
Cool! Now next time you you add a computer you should be able to set static ip, set gateway to your router in your first time on netconfig, and all should work and you know how to do it :)
|
Had you read http://docs.slackware.com/start?id=s...e_your_network then this whole thread would not have been necessary.
Eric |
Quote:
|
Just to complicate matters further, it is totally possible to continue to use dhcpcd (the DHCP Client Daemon) and assign static IP addresses. You just have to configure /etc/dhcpcd.conf accordingly. I have found that approach superior to /etc/rc.d/rc.inet1.conf on at least one occasion.
|
Check router ip range
@stf92
I know that this thread is marked as solved but I have the impression that some concepts are not clear enough. I assume you've already understood that the dynamic IP provided by your ISP is the external IP. What you are configuring is your LAN. Router web interfaces are a bit confusing. You should not disable dhcp in your router. Just do not use it (client) in your machines. Your router will use dhcp client to connect to your ISP and dhcp server to assign IPs to your LAN machines. Perhaps it will let you pre define some "static leases" where you associate the MAC address of each network interface with a static IP (mine let me add the host name of each machine too). Take in care that routers generally ask you to define a "range" of ips to assign, so if that range is 192.168.0.100 - 192.168.0.200 and you put 192.168.0.2 in rc.inet1.conf it will not work (probably what happened to you). What you showed on your first post for rc.inet1.conf is OK (unless 192.168.0.2 is not in the router's pre defined range like I've explained above). You can add to /etc/resolv.conf: Code:
search local Code:
nameserver 8.8.8.8 You can add to /etc/hosts in both machines (I have a linux embeded in my router so I ssh access it and edit /etc/hosts with the same values). Code:
127.0.0.1 localhost Your router configuration is what you should investigate first. - |
All times are GMT -5. The time now is 10:19 PM. |