LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   set ip to fixed addr (https://www.linuxquestions.org/questions/linux-newbie-8/set-ip-to-fixed-addr-283769/)

compzoo 01-29-2005 02:08 PM

my pingwing won't surf the net
 
How can I change my linux box to come up at the same ip address everytime?

I have dhcp setup in my router and want this box to always appear at 192.168.1.4.

When I rebooted it now its at 192.168.1.5????

thanks

compzoo 01-29-2005 03:27 PM

hmmmm
 
I was able to set this through webmin....

but for some reason i can't get out on the internet...I can see my website at http://192.168.1.4, but I get an unknown host error when i try to surf the net..

any ideas?

thanks

dijkstra 01-29-2005 03:32 PM

You have your router set up for dynamic IP addressing. I believe one way to solve your problem is to foreward all requests on port 80 to the box's DNS entry (it's name) (It's a router config thing)

compzoo 01-29-2005 03:38 PM

I don't want the world to see the linux box until i secure it...it's setup as an intranet server right now...so i don't want to forward port 80 to it yet...

i was able to surf the internet and have others internally see the intranet site on this linux box until today...

now i get unkown host when trying to go to say... google

dijkstra 01-29-2005 03:39 PM

Unless you can only not get out with one machine. The issue isn't with your linux box. It's with your router. Go to the config page (probably http://192.168.1.1 and see if that gives you any indication that your WAN or Internet status, is active. I'm assuming your using your router as a DHCP server judging by the fact that you've got a 192 IP range.

compzoo 01-29-2005 03:41 PM

it has to be active because i am online right now with this windows box...it's hooked to the same router???

update..i checked the router and it shows 2 windows machines connected and the linux box at 192.168.1.4 where i want it.

both windows boxes can surf the net..the pingwin can't???

dijkstra 01-29-2005 03:45 PM

Quote:

Unless you can only not get out with one machine.
So the problem is that only the machine you're using as a web server can't get out?

JimBass 01-29-2005 03:46 PM

You have a few choices, most of which have little if anything to do with your linux box.

1) Super Easy - Go into your router and tell it to alwasy give the linux box the same IP. To do this you usually need to tell the router/dhcp server the MAC address of the computer's network card. To find your MAC address, do this:
Code:

su -
(password)
ifconfig eth0 (or eth1, or whatever eth you use to get online. If you only have 1, it is eth0).

It is possible that your router won't support static IPs, particularly if you have the cheapest of cheap routers. If this is the case, you can assign a static IP to your linux box. I don't know the path to the network config files in Suse, but it is likely close to Fedora. You would change to the network config file, and edit it from dhcp to having a staic address, and then give the static. You'll need to check out 2 files actually, the network config and the resolv.conf, which gives the nameserver addresses to your linux box. You'd have to do this:

Code:

su
(password)
(actual path may vary based on distro) vim /etc/sysconfig/network-scripts/ifcfg-eth0

Change it from:
Code:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet

to be:

Code:

DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.1.255
IPADDR=192.168.1.4
NETMASK=255.255.255.0
NETWORK=192.168.1.0
GATEWAY=192.168.1.1  (assuming your router is at 192.168.1.1, if elsewhere just change it)
ONBOOT=yes
TYPE=Ethernet

You'll also need to take a look at the file /etc/resolv.conf. That is where the nameservers are listed. your resolv.conf should have the current nameservers that the router is giving out. Just take a look at it, and copy the file to a backup incase it gets horked when you make this cahnge. Chances are very good your router is either giving out itself as the DNS server, or the DNS servers directly from your highspeed provider. You shouldn't have to actually make any changes to resolv.conf, just save the backup incase restarting the network services screws it up.

The only problem you might encounter in the future is if your high scpeed provider changes the address of their DNS servers in the future, and that is possible but very unlikely. You'll still have access to the net, but your computer won't be able to translate human names for websites (google.com) into IP addresses (216.239.39.99). If other computers in your LAN have connection but your linux box can't resolv names, this is what happened.

Now the final issue, restarting the network services. The other OS way to do this is to reboot the machine, and that will do it, but is a craptastic way of accomplishing what should be a 2 second solution. You have to be root again, and can give one of 2 simple commands. You can either do:
Code:

ifdown eth0                    (followed by)
ifup eth0

Or the even easier:
Code:

/etc/rc.d/init.d/network restart
That should solve your issue. It is easier to tell the router to give you the same address, but it isn't at all hard to make your linux box come up at a given address on its own.

Peace,
JimBass

Dark_Helmet 01-29-2005 03:48 PM

Assuming you have a router capable of reserving IP addresses...

My suggestion: return the box to using dhcp

Your router probably has the ability to assign a specific IP address to a specific MAC address. On my Red Hat box, you can see the MAC address using ifconfig:
Code:

ifconfig eth0
It's shown as "HWaddr" in that command's output. It may be slightly different for Suse.

Then you take that value, open up your router's configuration interface, punch in the MAC address, associate the IP address you want, and then reboot/reset/power cycle the router. You may need to release the IP on your box, and then renew it, but that should be it. Using DHCP, your box will get the necessary gateway/dns settings (which will likely point back to the router), and for all intents and purposes, have a static IP even though it's using DHCP.

EDIT:
Crikey... I was too slow.

dijkstra 01-29-2005 03:49 PM

Is your router a linux box or a lynksis/belkin/etc.?

compzoo 01-29-2005 03:53 PM

hmmm /etc/resolv.conf is empty???

what should be in there?

compzoo 01-29-2005 03:55 PM

netgear router.....

this all worked yesterday... my son was surfing the net on the linux box...when the prob showed up

JimBass 01-29-2005 03:57 PM

/etc/resolv.conf must have the DNS server IP addresses. That is why you think it can't get on the internet. Actually it can, but it can't change human names into IP addresses. Simple solution - open a cmd prompt on the winblow$ box, and type ipconfig /all and find out the dns server addresses. Add those addresses into the resolv.conf file, and restart the network services. You should be able to resolve names then.

Peace,
JimBass

dijkstra 01-29-2005 04:38 PM

Wonder how it happened? Desperate deletion? And by the way. Just because you have to pay for it doesn't mean it sucks... :-D

compzoo 01-29-2005 05:47 PM

Quote:

Originally posted by Dark_Helmet
Assuming you have a router capable of reserving IP addresses...

My suggestion: return the box to using dhcp

Your router probably has the ability to assign a specific IP address to a specific MAC address. On my Red Hat box, you can see the MAC address using ifconfig:
Code:

ifconfig eth0
It's shown as "HWaddr" in that command's output. It may be slightly different for Suse.

Then you take that value, open up your router's configuration interface, punch in the MAC address, associate the IP address you want, and then reboot/reset/power cycle the router. You may need to release the IP on your box, and then renew it, but that should be it. Using DHCP, your box will get the necessary gateway/dns settings (which will likely point back to the router), and for all intents and purposes, have a static IP even though it's using DHCP.

EDIT:
Crikey... I was too slow.

I set the router to always port the linux box to the ip i wanted... set the linux box back to dhcp from the router...the resolv.conf has the nameservers... everything is kewl again.

Thanks i'm kinda hooked on this linux stuff... reminds me of the old dos days..:cool:
Now if I could only load dreaweaver, fireworks and flash on a linux box i'd be completely switched over . hmmm maybe i need to get a mac for that stuff!


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