LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-19-2013, 06:03 AM   #16
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76

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.

Last edited by stf92; 02-19-2013 at 06:07 AM.
 
Old 02-19-2013, 06:12 AM   #17
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
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:
  1. the desired IP/netmask combination;
  2. the gateway, that must point to the modem local IP (not the WAN IP assigned by the ISP) e.g. 192.168.0.1;
  3. the DNS, that can be set to the modem local IP too to use the DNS configured on the modem
While the first two settings can be set in the /etc/rc.d/rc.inet1.conf file, the last one needs an appropriate "nameserver [IP]" entry in the /etc/resolv.conf file.
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.
 
1 members found this post helpful.
Old 02-19-2013, 06:14 AM   #18
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,357

Rep: Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739
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
 
Old 02-19-2013, 06:20 AM   #19
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by stf92 View Post
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>
No, as several times pointed out already, you do not use DHCP and static IPs on the same machine at the same time. And you do not set the gateway IP to the IP the the modem gets from your ISP. This IP is on the side of your network that face the Internet, not your local net.

See this example:
Code:
PC1 (IP: 192.168.0.100)--
                        |
                        --- Router (IP: 192.168.0.1 on local net, set by DHCP on the Internet side by the modem) --- Modem (IP: DHCP from ISP)
                        |
PC2 (IP: 192.168.0.101)--
In this example you would set the gateway address on both PCs to 192.168.0.1, the address of the router that is facing towards you local network. The Other IP addresses are irrelevant for you.

Quote:
Originally Posted by allend
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.
Quote:
Now you are finding out why DHCP will ultimately be better and easier. DHCP handles the gateway, network mask and name resolution stuff automatically.
Easier in larger networks, yes, I agree. In small (home) networks the approach with static IPs is much easier, especially if the machines should communicate with each other. Of course you can go for a mixed approach (I do that on my network), where machines that are always there get a static IP, but the router is still offering DHCP for temporary connections and machines that don't have to communicate with each other in a simple way.
 
Old 02-19-2013, 06:22 AM   #20
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
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.
 
Old 02-19-2013, 07:00 AM   #21
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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:
IPADDR[0]="192.168.1.10"
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"
The netconfig utility saves the system name and address in /etc/hosts like this:
Code:
192.168.1.10		fubar.com fubar
(I gave it "fubar" as the name, "com" as the domain and I manually add the alias "fubar" so I don't have to type "fubar.com" to connect to the server from another server).

Simple? Yup. My /etc/hosts file (on every server) looks like
Code:
# For loopbacking.
127.0.0.1		localhost
# Local servers
192.168.1.10		fubar.com fubar
192.168.1.15		InkJet
192.168.1.20		snafu.com snafu
192.168.1.30		pita.com pita
# Public servers
75.126.162.205		www.linuxquestions.org	linuxquestions.org
74.125.224.70		maps.google.com
74.125.224.111		maps.gstatic.com

# End of hosts.
Those "Public Servers" in there? Those are so there is no DNS look up for their addresses, /etc/hosts entries are the first place looked at before DNS is invoked. It's quicker.

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.
 
Old 02-19-2013, 07:34 AM   #22
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by 414N View Post
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:
  1. the desired IP/netmask combination;
  2. the gateway, that must point to the modem local IP (not the WAN IP assigned by the ISP) e.g. 192.168.0.1;
  3. the DNS, that can be set to the modem local IP too to use the DNS configured on the modem
While the first two settings can be set in the /etc/rc.d/rc.inet1.conf file, the last one needs an appropriate "nameserver [IP]" entry in the /etc/resolv.conf file.
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.
I did the three things in both machines, plus the /etc/hosts thing, and the result was: (a) I have internet in both machines. (b) I can slogin from machine A into machine B. (c) I CANNOT slogin from B into A. When I try I get:
Code:
ssh: connect to host SERVER_HOST port 22: no route to host.
However, while in B ifconfig gives inet=192.168.0.3, which is fine, in B it gives inet=192.168.0.100 I can't understand why. I should be inet=192.168.0.2.

EDIT: thank you tronayne for your kind advices.

Last edited by stf92; 02-19-2013 at 07:37 AM.
 
Old 02-19-2013, 07:54 AM   #23
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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.
 
Old 02-19-2013, 08:15 AM   #24
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by tronayne View Post
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.
Yes, I did that. I also reset the modem, the router and the machines several times: no use. I in A I do

ifconfig eth0 192.168.0.2

then all is fine. But when I reboot, I am again 192.168.0.100!
 
Old 02-19-2013, 08:27 AM   #25
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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.
 
Old 02-19-2013, 08:30 AM   #26
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by TobiSGD View Post
Easier in larger networks, yes, I agree. In small (home) networks the approach with static IPs is much easier, especially if the machines should communicate with each other. Of course you can go for a mixed approach (I do that on my network), where machines that are always there get a static IP, but the router is still offering DHCP for temporary connections and machines that don't have to communicate with each other in a simple way.
DHCP on most home routers gives the ability to hand out specific IP addresses to specific machines every time.
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?
 
Old 02-19-2013, 08:33 AM   #27
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
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?
 
Old 02-19-2013, 08:50 AM   #28
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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
search com
nameserver 68.94.156.1
nameserver 68.94.157.1
# Google Free DNS Servers
#nameserver 8.8.8.8
#nameserver 8.8.4.4
# HughesNet DNS Servers
#nameserver 66.82.4.8
#nameserver 66.82.4.12
The first two are ISP-provided, the others are commented out but available if the first two go away for some reason (and they then will be commented out or deleted).

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.
 
Old 02-19-2013, 10:07 AM   #29
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
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.
 
Old 02-19-2013, 11:11 AM   #30
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,048

Rep: Reputation: Disabled
Quote:
Originally Posted by stf92 View Post
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.
So, if I understand you put in /etc/resolv.conf as nameserver the IP address of your gateway, where there is no nameserver

Last edited by Didier Spaier; 02-19-2013 at 11:12 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"domain-name" and "host-name" options in dhcpd.conf m4rtin Linux - Server 3 09-20-2012 08:21 AM
xorg.conf : Explanation of "Viewport" and "Virtual" uncle-c Linux - Newbie 1 01-24-2011 11:04 AM
Error for wireless request "Set Nickname" (8B1C) -- /etc/rc.d/rc.inet1.conf hellbillyJoker Linux - Networking 1 04-06-2010 07:24 PM
Problems configuring "xorg.conf" with "ATI FGLRX" BlueSpirit Slackware 3 09-16-2006 02:01 PM
error "Set Frequency" (8b04) : when restarting rc.inet1 tux31337 Linux - Wireless Networking 1 02-13-2006 03:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration