LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Static IP (private) not working (https://www.linuxquestions.org/questions/linux-networking-3/static-ip-private-not-working-684417/)

figure002 11-18-2008 03:08 PM

Static IP (private) not working
 
Hello,

I have set a static local IP address for my machine, but after that I can't get on the internet. I'm running openSuSE 11.0 with a Broadcom card on a laptop.

Usually my settings are set to DHCP which always assigned me to the local address 192.168.1.6. But recently the router gave me a new private IP address, which means I have to update all the port forwarding rules. But I want to avoid that by setting 192.168.1.6 as my static IP.

Internet works fine when set to DHCP, but when I use "yast2 lan" to change to a static IP, I can't get on the internet.

I used the following settings to set it to static:
Local static IP: 192.168.1.6 (this ip is not in use, and i tried other ip's also)
Subnetmask: 255.255.255.0 (which is the same when DHCP is enabled)
DNS/Nameserver: 192.168.1.1 (which is also the same when DHCP is enabled)

When I do an ifconfig afterwards, the ip is indeed set to the new address. But websites still can't be found. Anyone got an idea how to fix this?

anomie 11-18-2008 03:12 PM

# cat /etc/resolv.conf

?

It's not clear whether you're saying you can't connect to the 'net or whether you simply can not resolve names. If resolve.conf does not contain nameservers when you set a static IP, there's your problem.

figure002 11-18-2008 03:23 PM

Quote:

Originally Posted by anomie (Post 3346685)
# cat /etc/resolv.conf
It's not clear whether you're saying you can't connect to the 'net or whether you simply can not resolve names. If resolve.conf does not contain nameservers when you set a static IP, there's your problem.

What I meant whas, I can't access websites, or use Skype, or anything that uses the internet. A simple 'ping google.com' doesn't work either.

I don't really know what you mean by "can't resolve names", but i just found something weird when viewing the contents of '/etc/resolve.conf'.

When DHCP is enabled:
Code:

# generated by NetworkManager, do not edit!

nameserver 192.168.1.1

When DHCP is not enabled:
Code:

# generated by NetworkManager, do not edit!
So it's missing one line: "nameserver 192.168.1.1"
How do I fix this without manually editing the file? I prefer to use graphical tools to set these things rather then manually editing things.

billymayday 11-18-2008 03:23 PM

You could probably have your dhcp serve assign a specific IP based on the MAC address as well - same result, less fiddling

Edit cross typing I see.

billymayday 11-18-2008 03:24 PM

Probably from network manager would be my guess.

figure002 11-18-2008 03:36 PM

Ok, I just set the nameserver with the same network manager, and this is what I got:

# cat /etc/resolv.conf

When DHCP is enabled and internet is working:
Code:

nameserver 192.168.1.1
search site

When DHCP is disabled (internet not working):
Code:

domain site
nameserver 192.168.1.1


About "assigning a specific IP based on the MAC address". I just went through all my router settings, but there is no such option :(

billymayday 11-18-2008 03:47 PM

What IP are you assigning, is it 192.168.1.6?

From the command line, can you post the results of:

ifconfig
route
dig www.google.com

You will probably need to be root or use sudo.

heloma 11-18-2008 03:53 PM

1- ping your gateway, if it pings, go to next step, if not, you have a network problem.
2- ping external ip (4.2.2.2), if it pings, go to next step, if not, you have a routing problem.
3- add external dns server to your /etc/resolv.conf (internet dns servers 4.2.2.2, 142.77.1.1)

heloma.

figure002 11-18-2008 03:58 PM

Yes, I'm assigning 192.168.1.6

When DHCP is enabled:
Code:

saibot:~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 00:15:F2:38:43:9B 
          inet addr:192.168.1.54  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:f2ff:fe38:439b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5973 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5793 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3118953 (2.9 Mb)  TX bytes:1163277 (1.1 Mb)
          Interrupt:19 Base address:0xc00

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4866 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4866 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:262322 (256.1 Kb)  TX bytes:262322 (256.1 Kb)

wlan0    Link encap:Ethernet  HWaddr 00:15:F2:1D:95:7B 
          inet addr:192.168.1.55  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:f2ff:fe1d:957b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:898 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1258 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:119919 (117.1 Kb)  TX bytes:271354 (264.9 Kb)

wmaster0  Link encap:UNSPEC  HWaddr 00-15-F2-1D-95-7B-35-37-00-00-00-00-00-00-00-00 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

saibot:~ # route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.1.0    *              255.255.255.0  U    0      0        0 eth0
192.168.1.0    *              255.255.255.0  U    0      0        0 wlan0
loopback        *              255.0.0.0      U    0      0        0 lo
default        192.168.1.1    0.0.0.0        UG    0      0        0 eth0
saibot:~ # dig www.google.com

; <<>> DiG 9.4.2-P1 <<>> www.google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39254
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com.                        IN        A

;; ANSWER SECTION:
www.google.com.                604685        IN        CNAME        www.l.google.com.
www.l.google.com.        188        IN        A        74.125.79.103
www.l.google.com.        188        IN        A        74.125.79.99
www.l.google.com.        188        IN        A        74.125.79.147
www.l.google.com.        188        IN        A        74.125.79.104

;; Query time: 34 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Tue Nov 18 22:50:35 2008
;; MSG SIZE  rcvd: 116

When DHCP is disabled and set to static IP:
Code:

saibot:~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 00:15:F2:38:43:9B 
          inet addr:192.168.1.6  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:f2ff:fe38:439b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6003 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5821 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3123870 (2.9 Mb)  TX bytes:1168505 (1.1 Mb)
          Interrupt:19 Base address:0xc00

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4867 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4867 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:262351 (256.2 Kb)  TX bytes:262351 (256.2 Kb)

wlan0    Link encap:Ethernet  HWaddr 00:15:F2:1D:95:7B 
          inet addr:192.168.1.55  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:f2ff:fe1d:957b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:908 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1279 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:121677 (118.8 Kb)  TX bytes:275999 (269.5 Kb)

wmaster0  Link encap:UNSPEC  HWaddr 00-15-F2-1D-95-7B-35-37-00-00-00-00-00-00-00-00 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

saibot:~ # route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.1.0    *              255.255.255.0  U    0      0        0 eth0
192.168.1.0    *              255.255.255.0  U    0      0        0 wlan0
loopback        *              255.0.0.0      U    0      0        0 lo
default        192.168.1.1    0.0.0.0        UG    0      0        0 wlan0
saibot:~ # dig www.google.com

; <<>> DiG 9.4.2-P1 <<>> www.google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52924
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com.                        IN        A

;; ANSWER SECTION:
www.google.com.                604598        IN        CNAME        www.l.google.com.
www.l.google.com.        101        IN        A        74.125.79.103
www.l.google.com.        101        IN        A        74.125.79.99
www.l.google.com.        101        IN        A        74.125.79.147
www.l.google.com.        101        IN        A        74.125.79.104

;; Query time: 32 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Tue Nov 18 22:52:02 2008
;; MSG SIZE  rcvd: 116


billymayday 11-18-2008 04:06 PM

Ok, so when you use DHCP, the default route is via eth0, but through wlan0 otherwise. However dig (that's a namserver lookup) works because it's being routed through eth0 because it's on 192.168.1.1 (see first line of route output).

Am I correct in saying that you are both wired in and trying to use your wireless card? It looks to me like th wireless card isn't working properly if that's the case.

figure002 11-18-2008 04:08 PM

I think I should have disabled my wlan in the previous step. I redid the same step, but this time with wireless disabled:

When DHCP is disabled:
Code:

saibot:~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 00:15:F2:38:43:9B 
          inet addr:192.168.1.6  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:f2ff:fe38:439b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6486 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6335 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3282799 (3.1 Mb)  TX bytes:1292303 (1.2 Mb)
          Interrupt:19 Base address:0xc00

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4896 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4896 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:263192 (257.0 Kb)  TX bytes:263192 (257.0 Kb)

saibot:~ # route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.1.0    *              255.255.255.0  U    0      0        0 eth0
loopback        *              255.0.0.0      U    0      0        0 lo
saibot:~ # dig www.google.com

; <<>> DiG 9.4.2-P1 <<>> www.google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19441
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com.                        IN        A

;; ANSWER SECTION:
www.google.com.                604041        IN        CNAME        www.l.google.com.
www.l.google.com.        146        IN        A        74.125.79.147
www.l.google.com.        146        IN        A        74.125.79.104
www.l.google.com.        146        IN        A        74.125.79.103
www.l.google.com.        146        IN        A        74.125.79.99

;; Query time: 31 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Tue Nov 18 23:01:19 2008
;; MSG SIZE  rcvd: 116

And in response to heloma:

Code:

saibot:~ # ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.10 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.02 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.942 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.936 ms
^C
--- 192.168.1.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3011ms
rtt min/avg/max/mdev = 0.936/1.003/1.108/0.070 ms
saibot:~ # ping 4.2.2.2
connect: Network is unreachable
saibot:~ # ping 82.173.xxx.xx (my public ip)
connect: Network is unreachable
saibot:~ #

So that means it's a routing problem?

Quote:

Originally Posted by billymayday (Post 3346745)
Am I correct in saying that you are both wired in and trying to use your wireless card? It looks to me like th wireless card isn't working properly if that's the case.

Yes, it is true that both wireless and cable were enabled. But wireless works fine when DHCP is enabled. Wireless works very slow when DHCP is disabled for cable only. I am just trying to set a static IP for cable, not wireless.

billymayday 11-18-2008 04:12 PM

Yes. What distro are you using?

figure002 11-18-2008 04:16 PM

Quote:

Originally Posted by billymayday (Post 3346755)
Yes. What distro are you using?

See my first post, I'm using openSuSE 11.0

billymayday 11-18-2008 04:20 PM

Sorry, running a few responses in tandem here. Let me have a look at my OpenSuSe box and come back to you.

billymayday 11-18-2008 04:27 PM

When you open up Network Settings from yast, there's a routing tab on the RHS.

You need to add 192.161.1.1 as the default gateway.

figure002 11-18-2008 04:33 PM

Quote:

Originally Posted by billymayday (Post 3346772)
When you open up Network Settings from yast, there's a routing tab on the RHS.

You need to add 192.161.1.1 as the default gateway.

Everything under the routing tab is disabled. The button for Add is disabled too. And the dropdown menu for Standard Gateway is empty. So I can't change anything there..

EDIT: Turns out I could just enter the gateway IP (192.168.1.1) in the empty list, but internet still didn't work after that.

billymayday 11-18-2008 04:37 PM

Are you running yast as root?

Try firing it up from a root terminal session (just type yast2 at the command line)

figure002 11-18-2008 04:44 PM

Yes, I'm running Yast as root, because I have to enter my root password everytime I run Yast. I also fired up Yast from a root terminal session, but there was no difference.

billymayday 11-18-2008 04:53 PM

Something is awry then.

Either you have entered something wrong that is causing this or yast is on strike. I can change it here OK.

You are using "Network Settings" from the "Network Devices" tab?

billymayday 11-18-2008 05:00 PM

You can always add the route manually. Not sure if it will persist in SuSe

Quote:

route add default gw 192.168.1.1

The_Nerd 11-18-2008 06:29 PM

I had a similar problem to what you are experiencing just today. It turned out to be a IP conflict between the two devices in my computer. For some reason, when I changed one devices IP address (eth0) it would change the other one's as well to the same thing. Even though the second network device (eth1) was disabled, this caused a conflict. Maybe try removing your wireless completely? Disable it in the bios?

billymayday 11-18-2008 06:32 PM

Except it seems pretty clear it's a routing problem since there is no default gateway.

Were you experiencing a routing issue or just IP conflict?

The_Nerd 11-18-2008 10:20 PM

Quote:

Originally Posted by billymayday (Post 3346909)
Except it seems pretty clear it's a routing problem since there is no default gateway.

Were you experiencing a routing issue or just IP conflict?

Yes, however it was the same for me today. It seamed like a routing problem at first, because sometimes I could ping the router/the 'net (google), and suddenly it would stop. I am just saying it might be possible...

figure002 11-19-2008 08:03 AM

Quote:

Originally Posted by billymayday (Post 3346815)
You are using "Network Settings" from the "Network Devices" tab?

I use the Network Settings in Yast, and then use the second tab to change the eth0 device to static IP. I used the third tab to set 'Nameserver 1' to 192.168.1.1 and Domainname to 'site'. And most options in the fourth tab (Routing) are disabled, except for the Default Gateway menu, which is an empty menu.

Quote:

Originally Posted by billymayday (Post 3346829)
You can always add the route manually. Not sure if it will persist in SuSe
route add default gw 192.168.1.1

I tried that before, but it didn't work. After that command I still couldn't load any webpages.


Quote:

Originally Posted by The_Nerd (Post 3346908)
I had a similar problem to what you are experiencing just today. It turned out to be a IP conflict between the two devices in my computer. For some reason, when I changed one devices IP address (eth0) it would change the other one's as well to the same thing. Even though the second network device (eth1) was disabled, this caused a conflict. Maybe try removing your wireless completely? Disable it in the bios?

So when you would do ifconfig, both eth0 and wlan would have the same IP? That isn't the case with me, as you can see from my previous posts. My wlan has a different IP than eth0. Also I didn't get an IP conflict.

heloma 11-19-2008 08:20 AM

This is definitly a routing issue, you need to add a static route (default gateway):
as root #route add default gw 192.168.1.1

If you are using Linksys, you will need also to clear your routing table.

good luck.


heloma

DotHQ 11-19-2008 08:21 AM

Reading through this one thing does not make sense to me. In post 11 you posted the stats with dhcp off. In the ifconfig I see:
Quote:

RX packets:6486 errors:0 dropped:0 overruns:0 frame:0
TX packets:6335 errors:0 dropped:0 overruns:0 carrier:0
Whenever I've seen my ifconfig show that I'm transmitting and receiving packets, that's a good thing. But here you are indeed transmitting and receiving but have no connetion. :confused:

Are you restarting networking after you make these changes?

service network restart works on my distros ...

figure002 11-19-2008 09:41 AM

I finally got it to work.

First I tried the following commands as root:
# route add default gw 192.168.1.1
followed by
# service network restart

But this only worked half. Skype would then work, but i could not ping to google.com or visit websites.

So I took another look at billymayday's advice. He told me to set the Default Gateway to '192.168.1.1' in the Routing tab in the Network Settings. When I tried this earlier, another option (Actualize DNS-data through DHCP) under the DNS tab was enabled. This time I disabled it and manually entered '192.168.1.1' for 'Namespace 1'. This in combination with the Default Gateway set to 192.168.1.1, does work :D I hope this works for other people also.

Thanks a lot for your help guys!

heloma 11-19-2008 02:45 PM

You need to add external dns servers to your hostfile,

add the following lines to /etc/resolv.conf
nameserver 4.2.2.2
nameserver 142.77.1.1



that's it !


All times are GMT -5. The time now is 11:04 PM.