LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Having internet with USE_DHCP="" in rc.inet1.conf possible? (http://www.linuxquestions.org/questions/slackware-14/having-internet-with-use_dhcp%3D-in-rc-inet1-conf-possible-4175450762/)

stf92 02-19-2013 05:07 AM

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?

Didier Spaier 02-19-2013 05:19 AM

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.

stf92 02-19-2013 05:39 AM

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?

wildwizard 02-19-2013 05:51 AM

If you try putting the following in a file under /lib/dhcpcd/dhcpcd-hooks/

Code:

ip addr add 192.168.0.100/24 eth0
That might be persistent.

There are examples for other distros but they have totally different network configuration systems so I don't know how to convert them over.

Didier Spaier 02-19-2013 05:54 AM

Does one of your boxes act as a NAT router, or are they all directly connected to the Internet ?

stf92 02-19-2013 05:59 AM

The two computers in my LAN are connected to a NAT router and this to the cable modem.

wildwizard 02-19-2013 06:02 AM

Hmm.

Did you set a default route (Shown as "GATEWAY" in rc.inet1.conf) when you tired the static only settings?

stf92 02-19-2013 06:05 AM

Yes, I put

GATEWAY="192.168.0.1"

which was in the output of the route command.

allend 02-19-2013 06:07 AM

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:

1.
To access the configuration utility, open a web-browser and type the default address
http://tplinklogin.net in the address field of the browser.
After a moment, a login window will appear, similar to the Figure 3-4. Enter admin for the User
Name and Password, both in lower case letters. Then click the OK button or press the Enter key.
Once you have accesss to the router, you can do the address reservation according to the manual section 4.7.3
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.

stf92 02-19-2013 06:24 AM

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?

TobiSGD 02-19-2013 06:34 AM

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.

allend 02-19-2013 06:43 AM

Quote:

Just give them a static IP, set the router as gateway and all is fine.
I do not recommend doing this. Setting up DHCP correctly will pay dividends in the future. It will make adding additional devices to your LAN much easier.

stf92 02-19-2013 06:43 AM

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?

allend 02-19-2013 06:48 AM

To use DHCP you want USE_DHCP="yes"

The settings in rc.inet1.conf are LAN settings in your setup.

414N 02-19-2013 06:59 AM

Quote:

Originally Posted by stf92 (Post 4895019)
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?

Disabling DHCP, you also need to set up the gateway (as you already did) AND the name server in /etc/resolv.conf, like this:
Code:

nameserver 192.168.0.1
otherwise you won't be able to resolve remote host names.


All times are GMT -5. The time now is 07:20 PM.