LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Internet screwed up from ifconfig (https://www.linuxquestions.org/questions/linux-networking-3/internet-screwed-up-from-ifconfig-433869/)

ctkroeker 04-10-2006 06:45 PM

Internet screwed up from ifconfig
 
I did something like this just a little while ago to change my IP address
Code:

sudo ifconfig eth0 192.168.0.120 netmask 255.255.255.0 up
and now I canīt connect to the internet at all. It was really stupid to just do it like that, but I didnīt know how to get a static IP address otherwise (Iīm running Xubuntu). Iīd apreciate any help at the moment (Iīm writing this from another machine on the network) and hope to get this resolved fast.
BTW, when I open Firefox, it pops up an error saying that it couldnīt connect to the internet.
Hereīs kinda what iconfig says.
Code:

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:80:C8:F8:4A:53 
          inet addr:192.168.0.120  Bcast:192.168.0.255  Mask:255.255.255.0
          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:100
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:9 Base address:0x5000

Iīll have to fix this from the command line.
here is my network info that I want to be static:
IP: 192.168.0.120 (router is default 192.168.0.1)
Mask: 255.255.255.0
Any help will be greatly appreciated and I apologize if this has been asked before (I searched a lot).

pljvaldez 04-10-2006 06:50 PM

http://textsnippets.com/posts/show/319

Just use sudo nano /etc/network/interfaces and use the address 192.168.0.120 instead of 192.168.0.100 in the link above...

Then you should just have to do sudo ifdown eth0 and sudo ifup eth0 to restart the network.

Or use /etc/init.d/networking restart (I just found this command)...

ctkroeker 04-10-2006 07:30 PM

I did what you said, pljvaldez, and I got this:

Quote:

~$ sudo ifconfig -a eth0

Link encap:Ethernet HWaddr 00:08:54:22:0F:32
BROADCAST 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)
Interrupt:17 Base address:0xec00

lo
Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:402 errors:0 dropped:0 overruns:0 frame:0
TX packets:402 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14461 (14.1 KiB) TX bytes:14461 (14.1 KiB)

pljvaldez 04-10-2006 07:49 PM

Can you post your /etc/network/interfaces?

ctkroeker 04-10-2006 07:55 PM

Quote:

Originally Posted by pljvaldez
Can you post your /etc/network/interfaces?

Not really, because Iīm not at home now, but I verified it and I know for a fact that itīs exactly like one in the link you gave me, except for the last part of the IP adress.
BTW, ipconfig doesnīt work. Itīs not installed, but I guess using ifconfig works too.
I rebooted my PC just in case, but no difference.

pljvaldez 04-10-2006 07:59 PM

ipconfig is a windows command. In linux, it's ifconfig. Hmmmm. That's odd that it didn't work for your setup. It looks like the settings didn't take. That's why I was curious to see the output of the file. To see if maybe there's a typo or something...

Do you have DHCP on your network that you can use? If so, sometimes the router will allow you to do "static DHCP" which is to assign an IP based on the MAC address of your card. Then the machine can continue to use DHCP, but it will always get the same address.

ctkroeker 04-10-2006 08:08 PM

Here is a screenshot of it http://cory.mensajerofm.org/images/dhcp.jpg

pljvaldez 04-10-2006 08:28 PM

From what I can tell, no static IP option for you...

I guess when you get home, post your /etc/network/interfaces and we can go from there...

ctkroeker 04-11-2006 04:33 PM

OK. I got it fixed with some help at ubuntuforums.org
Here is what I did:
Code:

sudo nano /etc/resolv.conf
Write dns information you've got from your ISP like this:
Code:

nameserver [nameserver IP #1]
nameserver [nameserver IP #2]

Code:

sudo ifconfig eth0 192.168.0.120 netmask 255.255.255.0 up sudo route add default gw 192.168.0.1
Code:

ping 192.168.0.1
to see if you can reach your gateway.

ctkroeker 04-11-2006 07:29 PM

Ok, now I have a problem because when I reboot the /etc/resolv.conf get's overwritten and I have to enter the commands every time I reboot my PC. How can I make it do it automatically every time I boot?

pljvaldez 04-11-2006 11:13 PM

Did you disable the dhcp client?


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