LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   static IP setup problem (https://www.linuxquestions.org/questions/linux-networking-3/static-ip-setup-problem-568235/)

SRS 07-10-2007 05:53 PM

static IP setup problem
 
This should be simple but it doesn't seem to work.

I'm trying to setup a simple tpc/ip network. I've got
a slackware distribution and a Belkin wireless router but I'm only using the wired ports.

First I tried DHCP but that failed. I received an offer for a good ip address but then I timed out waiting for the response to the request. So I tried just a static ip address but I still can't see anything else on the network. It appears to be a routing setup issue, I think.


My router is setup as 192.168.2.1. On my linux box I
issued the following commands:
> ifconfig eth0 192.168.2.10
> route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo

> route add default gw 192.168.2.1
> route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0

> ping 192.168.2.1
...Destination Host Unreachable.

What is wrong?
I have another linux (montavista) machine on the network
which works fine. It's routing table looks the same but without the 127.0.0.0 entry. From that machine I can ping 192.168.2.1. Oh, the montavista ip addr is 192.168.2.2. From my slackware machine I can't ping that either.

Oh, netstat -i always shows 0 for the eth0 tx/rx entries. It looks like it's not trying.

Sorry about the routing table format. I hope it's not too unreadable. It seems multiple spaces are colapsed into one.

Thanks,
Tom

Bruce Hill 07-10-2007 06:44 PM

static IP setup in Slackware
 
Tom,

Welcome to LQ!

In Slackware you should setup your network by editing the file:
Code:

/etc/rc.d/rc.inet1.conf
For an example:
Code:

# /etc/rc.d/rc.inet1.conf
#
# 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.31"
NETMASK[0]="255.255.255.0"
#USE_DHCP[0]=""
#DHCP_HOSTNAME[0]=""

# Default gateway IP address:
GATEWAY="192.168.1.1"

# Change this to "yes" for debugging output to stdout.  Unfortunately,
# /sbin/hotplug seems to disable stdout so you'll only see debugging output
# when rc.inet1 is called directly.
DEBUG_ETH_UP="yes"

The uncommented lines (without # in front of them) are what Slackware uses. Those above are on a box on a network with has a router with the address 192.168.1.1, and a computer with the address 192.168.1.31.

In your particular example above:
Code:

# Config information for eth0:
IPADDR[0]="192.168.2.10"
NETMASK[0]="255.255.255.0"
#USE_DHCP[0]=""
#DHCP_HOSTNAME[0]=""

# Default gateway IP address:
GATEWAY="192.168.2.1"

# Change this to "yes" for debugging output to stdout.  Unfortunately,
# /sbin/hotplug seems to disable stdout so you'll only see debugging output
# when rc.inet1 is called directly.
DEBUG_ETH_UP="yes"

And the problem with your text not formatting properly, especially with numbers and symbols, is remedied by using VB code. I thought you could select that when making a post, but don't know how. I do it manually. Put [_code] without the _ (underscore) in front of your text, and [_/code] without the _ (underscore) after your text.

Edit:

The file /etc/resolv.conf is also necessary to setup your DNS servers when you run a static IP. The comp I referenced above simply has "nameserver 192.168.1.1" -- but on another box running wireless, I must enter my IP's DNS servers to use the internet.

And all this can be done in Slackware by running "netconfig" as root. If you answer the questions correctly, Slackware will setup your network. This is done when you install Slackware, unless you choose to skip it.

SRS 07-10-2007 06:56 PM

Thanks for the response Bill.

Actually I did run netconfig first. But thought the commands would be easier to explain. Using netconfig I have the same results. The only difference is that the metric field in the routing table is set to 1 or the default gateway. Also I entered the nameserver ip address. That's on the other side of the gw, I assume on some box run by my isp.

I've also tried modifying the inet1.conf. As before the same results.

Bruce Hill 07-10-2007 09:27 PM

The metric field in the routing table should be set to 1 or the default gateway.
Code:

mingdao@silas:~$ /sbin/route -n
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.1.0    0.0.0.0        255.255.255.0  U    0      0        0 eth0
127.0.0.0      0.0.0.0        255.0.0.0      U    0      0        0 lo
0.0.0.0        192.168.1.1    0.0.0.0        UG    1      0        0 eth0

After editing /etc/rc.d/rc.inet1.conf you should issue "/etc/rc.d/rc.inet1 restart"

Do you have 192.168.2.10 allowed as a static IP in your router?

This might be helpful: LQ vB Code List


All times are GMT -5. The time now is 06:33 PM.