LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Using static ips with a router (https://www.linuxquestions.org/questions/linux-hardware-18/using-static-ips-with-a-router-348646/)

jclu 07-31-2005 03:31 PM

Using static ips with a router
 
I'm having trouble setting my Debian box to use a static ip. My dad has a US Robotics wireless router with DHCP enabled for the ip range 192.168.xxx.100-199. Now we have 2 wireless connections and about 4-5 ethernet connections that are set up to use DHCP (including my Debian box). Apart from my machine, all the other computers use Windows.

Now when I tried to set /etc/network/interfaces to use a static ip for eth0, ifconfig reports the correct ip, but I can't get internet access (although I can ping the router using the gateway ip).

Here is /etc/network/interfaces:
...
# The primary network interface
auto eth0
iface eth0 inet dhcp
#iface eth0 inet static
# address 192.168.xxx.104
# netmask 255.255.255.0

As I said, if I comment out the dhcp line, and uncomment the static lines, and then run 'ifdown eth0' and 'ifup eth0' or restart, ifconfig reports the correct ip and subnet, but I can't ping anything outside the lan or access any websites.

What should I do? I want to forward some ports to my comp, and it's easier to do if my comp has a static ip. Thanks for any help.

God bless
Hiran

cdhgee 07-31-2005 04:06 PM

Have you updated the routing table to set the default route to go through the wireless router? If you run the command 'route' it will show you the current routing table - the default route needs to be the gateway. E.g. my box is configured like this:

Code:

[david@malvern ~]$ route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
fat-rk-69.t6-ln *              255.255.255.255 UH    0      0        0 ppp0
10.255.254.0    *              255.255.255.0  U    0      0        0 eth0
169.254.0.0    *              255.255.0.0    U    0      0        0 eth0
default        fat-rk-69.t6-ln 0.0.0.0        UG    0      0        0 ppp0

This tells the kernel to send all packets that don't match any of the first three rules the 'default' entry at the bottom (which is actually a DNS name but it's got truncated). It sounds like you need to configure your box to do the same. To change the default route, use the route command as follows (assuming your router's IP is 192.168.0.1).

Firstly, if you already have a default route in the routing table, run this:

Code:

route del default
Then run this to add the new default route:

Code:

route add default gw 192.168.0.1

maroonbaboon 07-31-2005 05:35 PM

Yes the above post looks like the right diagnosis. In Debian you just need the line

gateway 192.168.1.254

in that /etc/network/interfaces files (change the address to suit your router).

As well as the iface, address and netmask lines, of course.


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