LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   static IPs from a dhcp router? (https://www.linuxquestions.org/questions/slackware-14/static-ips-from-a-dhcp-router-818401/)

tramni1980 07-06-2010 11:00 PM

static IPs from a dhcp router?
 
Hello!
My ISP provides my internet via DHCP. I have a home wireless router to provide internet access, wired for my desktop machine and wireless for my laptop. My question is: Is it possible to configure the router (the Access Point) to provide internet to the desktop and the laptop via static IP? Currently I have managed to configure the internet to them via DHCP and it works. I am just curious to know whether it is possible to provide the internet for them by static IPs, given that the internet that actually goes into the Access Point (the wireless home router), is DHCP.

I fiddled with this a lot yesterday, but I only managed to get a working configuraton by DHCP for both the desktop and the laptop. If I supply them with static IPs, I can only ping the Access Point, but not beyond it. So does it at all make any sense to try to configure them by static IPs, i.e. is that virtually possible?

Regards,

Martin

dwabot 07-07-2010 12:28 AM

You can configure the home wireless router (at least I have done so with routers running Tomato and OpenWrt) to assign a static IP tied to a certain MAC address. That is how I run DHCP on my netbook but always have the same IP address when I on my home LAN (always having the same address is useful for scripting).

kingbeowulf 07-07-2010 12:41 AM

I set my router to reserve a block of IP addresses, set my wired desktop (via slackware netconfig) and printer (via print server utility) to use one of those. The wireless laptops get whatever is assigned via DHCP. My Netgear WNDR3700 has the option to reserve an IP for a particular MAC but I am too lazy to look up all those MAC values!

tramni1980 07-07-2010 02:12 AM

Quote:

Originally Posted by dwabot (Post 4025836)
You can configure the home wireless router ... to assign a static IP tied to a certain MAC address. That is how I run DHCP on my netbook

But do you still use DHCP in the rc.inet1.conf of your netbook or no?

dwabot 07-07-2010 02:46 AM

Yes. My netbook continues to use DHCP.

When my home wireless router receives a request for an IP address from my netbook... the router is configured so that it examines the netbook network interface's MAC address and always will assign it the same IP. My router runs OpenWrt and this setting is configured in the /etc/config/dhcp file.

Example: when router receives a DHCP request from network interface with MAC address 49:5b:39:13:91:a1 ... assign it IP address 192.168.1.50

tramni1980 07-07-2010 03:24 AM

I see, so you still use dhcp. My question was if it is possible to NOT use DHCP (set USE_DHCP="no" in rc.inet1.conf) in the clients of the router, when the router itself gets internet by dhcp.

My router is Wireless-N Home Router WRT120N Linksys Cisco. Actually in its setting I do not see an option for providing IPs without DHCP, there is only a "DHCP server settings" field.

As I said, I played a bit with the settings, but I could only get thing to work using dhcp=yes in the rc.inet1.confs of the clients.

Regards,

Martin

al_bye 07-07-2010 03:57 AM

Default Linksys Configuration
 
Hi,

Your router out of the box will be configured as follows: -
DHCP configured to receive a Public IP Address from your ISP (Allows access onto internet)this port is the ADSL or ethernet port. This will also have configured the DNS settings from your ISP which service name lookups i.e. google.co.uk.

On your ethernet port/WI-FI access point DNS settings will automatically sent down to the DHCP server (Configured by default to issue 192.x.x.x). You could just disable the DHCP server all together and statically assign IP address's. I think that config is on the LAN setup from memory.

Now you'll need to know the DNS server address from your ISP or use the following primary 4.2.2.4 secondary 8.8.8.8.

Make sure the Defualt Gateway is the IP address of the router 192.168.1.1 or 192.168.0.1 this will then allow you to browse the internet. As it's a home network I'd just leave the default settings on the linksys unless you want to host something from home then it becomes a different ball game.

Hope this helps

Al

tramni1980 07-07-2010 10:20 AM

Quote:

Originally Posted by al_bye (Post 4025975)
You could just disable the DHCP server all together and statically assign IP address's. ...

Now you'll need to know the DNS server address from your ISP or use the following primary 4.2.2.4 secondary 8.8.8.8.

Make sure the Default Gateway is the IP address of the router 192.168.1.1 or 192.168.0.1 this will then allow you to browse the internet.

Al

Thanks for your replies.

I tried disabling DHCP in both the router and the inet1.confs of the clients. In the "Advanced routing table" of the router configuration I set the IPs of the two machines, the netmasks and the gateway. The only place where I found DNS settings is the "DHCP server settings". So I tried both setting them to the values from /etc/rseolv.conf and with 8.8.8.8 and 8.8.4.4. The result was always the same: there is ping to the Access Point and to any external IP. But there is no ping to any site if the address is written in words (sorry, I lack terminilogy as I am not a specialist :)). So I guess it is a DNS issue, but I am at a loss. I also suspect that my DNS is dynamic.

Regards,

Martin

bgeddy 07-07-2010 12:57 PM

Quote:

I tried disabling DHCP in both the router and the inet1.confs of the clients. In the "Advanced routing table" of the router configuration I set the IPs of the two machines, the netmasks and the gateway.
You shouldn't need the set any "Advanced routing table" options and if you have I would set them back to what they were.

You can leave the DHCP server running in the router and have your client boxes use fixed IP's either by "DHCP Reservation" at the router which will let you permanently assign an IP to a Mac address so evert time a box gets it's IP via DHCP it will be the same.

The other option is to have the clients utilize static IP and not use DHCP. To do this you will need to check the router doesn't hand out IP's via DHCP to future clients that you already use statically. This should be OK as your router default is to start it's DHCP range at 192.168.1.100 so you may assign a static address in the range 192.168.1.2-192.168.1.99 without a problem.
Then you need to check the GATEWAY= setting in rc.inet1.conf. This will most likely be 192.168.1.1 (the router's address) but to make sure just set a client PC to use DHCP and when it's connected and can reach the internet run:
Code:

/sbin/route -n
to see where the Gateway has been assigned for that box. Also run:
Code:

cat /etc/resolv.conf
to see what DNS ip's have been assigned via DHCP. Again this may well be the router's IP 192.168.1.1.

Then it;s just a matter of setting the IP's (GATEWAY= in /etc/rc.d/rc.inet1.conf and nameserver in /etc/resolv.conf) then change /etc/rc.d/rc.inet1.conf to use_dhcp[0]="" from use_dhcp[0]="yes" and assign IPs to IPADDR[0]. The interfaces number may be different than [0] in my example.

This should all just work and you don't need to turn off DHCP at the router and add any routes to it's tables or anything.

onebuck 07-07-2010 07:33 PM

Hi,

Quote:

Originally Posted by tramni1980 (Post 4026394)
Thanks for your replies.

I tried disabling DHCP in both the router and the inet1.confs of the clients. In the "Advanced routing table" of the router configuration I set the IPs of the two machines, the netmasks and the gateway. The only place where I found DNS settings is the "DHCP server settings". So I tried both setting them to the values from /etc/rseolv.conf and with 8.8.8.8 and 8.8.4.4. The result was always the same: there is ping to the Access Point and to any external IP. But there is no ping to any site if the address is written in words (sorry, I lack terminilogy as I am not a specialist :)). So I guess it is a DNS issue, but I am at a loss. I also suspect that my DNS is dynamic.

Regards,

Martin

What do you assign in '/etc/resolv.conf'? for the static IP assignment for the machine?
I would be sure to include the 'DNS' provided by the ISP. Your 'route' sounds like it's setup. Post the 'route -n'.

'bgeddy' setup should work for you!

Sample '/etc/resolv.conf';
Code:

cat /etc/resolv.conf
#
#removed local DNS
#
nameserver 4.2.2.1                #Verizon L-3
nameserver 4.2.2.2
nameserver 4.2.2.3
nameserver 4.2.2.4
nameserver 208.67.222.222  # OpenDNS

I don't use Google's DNS for personal reasons.

Verizon & OpenDNS work fine along with my ISP DNS. I will have 2 ISP DNS & one fall back L-3. Works for me.
:hattip:

tramni1980 07-08-2010 01:32 AM

Quote:

Originally Posted by bgeddy (Post 4026528)
You shouldn't need the set any "Advanced routing table" options and if you have I would set them back to what they were.

You can leave the DHCP server running in the router and have your client boxes use fixed IP's either by "DHCP Reservation" at the router which will let you permanently assign an IP to a Mac address so evert time a box gets it's IP via DHCP it will be the same.

The other option is to have the clients utilize static IP and not use DHCP. To do this you will need to check the router doesn't hand out IP's via DHCP to future clients that you already use statically. This should be OK as your router default is to start it's DHCP range at 192.168.1.100 so you may assign a static address in the range 192.168.1.2-192.168.1.99 without a problem.
Then you need to check the GATEWAY= setting in rc.inet1.conf. This will most likely be 192.168.1.1 (the router's address) but to make sure just set a client PC to use DHCP and when it's connected and can reach the internet run:
Code:

/sbin/route -n
to see where the Gateway has been assigned for that box. Also run:
Code:

cat /etc/resolv.conf
to see what DNS ip's have been assigned via DHCP. Again this may well be the router's IP 192.168.1.1.

Then it;s just a matter of setting the IP's (GATEWAY= in /etc/rc.d/rc.inet1.conf and nameserver in /etc/resolv.conf) then change /etc/rc.d/rc.inet1.conf to use_dhcp[0]="" from use_dhcp[0]="yes" and assign IPs to IPADDR[0]. The interfaces number may be different than [0] in my example.

This should all just work and you don't need to turn off DHCP at the router and add any routes to it's tables or anything.

Thank you very much for your replies. Owing to them I finally have a home computer network with statically assigned IPs.

So I disabled DHCP in both the router and the clients. Of course the router gets its internet by DHCP, as this is the way my ISP provides my internet. Then I set the IPs of the two machines to 192.168.1.2 and 192.168.1.3, because the IP of the router is 192.168.1.1. Finally I edited resolv.conf and set the DNS server of my ISP. Now everything works!

Thank you very much again. This was a bit of learning experience for an amateur like me :).

Regards,

Martin


All times are GMT -5. The time now is 09:04 AM.