LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Setting up a static I.P. address (http://www.linuxquestions.org/questions/linux-networking-3/setting-up-a-static-i-p-address-370797/)

partyk1d24 10-07-2005 07:59 PM

Setting up a static I.P. address
 
How do I set up a static I.p. on my box in order to forward port requests?

Brian1 10-07-2005 08:07 PM

Are you using a cable/dsl router?
If so do you know the IP you use to connect to your router from the lan side?
If you do then do this. If it is say 192.168.1.1 then you want to use and ip like 192.168.1.10 with a subnet of 255.255.255.0 and a gateway of 192.168.1.1. For you DNS you could use your routers IP or your providers DNS numbers. The numbers the router sees on the wan side. Once done then you can port forward to the internal lan PC.

Brian1

partyk1d24 10-07-2005 08:11 PM

Right but how do I change that in Linux?

partyk1d24 10-07-2005 08:13 PM

I want my ip to be lets say 192.168.1.234 what would I edit to make it defualt to that on startup.

Brian1 10-07-2005 08:54 PM

What distro and Gui are you using? There is problably a nice gui tool to do this.

For now post your /etc/sysconfig/network-scripts/ifcfg-eth0.

Here is a basic example that should work for you.
Code:

DEVICE=eth0
BOOTPROTO=none
BROADCAST=192.168.1.255
# HWADDR=00:90:F5:0D:2F:85
IPADDR=192.168.1.234
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
TYPE=Ethernet
GATEWAY=192.168.1.1
USERCTL=no
PEERDNS=yes
IPV6INIT=no

If you have something similiar then as root in a terminal session run the following commands: (Note make a backup of the file before changing)

/sbin/ifconfig eth0 down

edit your ifcfg-eth0 file. Save and Exit

edit /etc/resolv.conf and add either your providers DNS numbers or use the router's IP. Save and Exit.
nameserver 192.168.1.1

/sbin/ifconfig eth0 up

/sbin/ifconfig eth0 to see if looks correct.

Brian1

carlosinfl 10-07-2005 09:55 PM

#su
#nano /etc/network/interfaces

Once that opens, delete what you see and enter:

auto eth0
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1


Make your own changes to the IP address.

partyk1d24 10-07-2005 10:23 PM

Ok first I am running RH9 and my vim /etc/sysconfig/network-scripts/ifcfg-eth0
is
Code:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

What all should I add?

partyk1d24 10-07-2005 10:30 PM

So from what I read I made this my eth0

Code:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
#here on down is my work
BROADCAST=192.168.1.241
IPADDR=192.168.1.281
NETMASK=255.255.255.0
NETWORK=192.168.1.0
TYPE=Ethernet
GATEWAY=192.168.1.1

What else should I need or is this ok? and do I have to restart any processes?

Brian1 10-08-2005 02:53 PM

IP address is to incorrect for IPv4 format. You can only have values from 1-255. Normally 255 is reserved for broadcast. So your IP of 192.168.1.281 will not work it needs to be 192.168.1.2-254. Also bootpront needs to be none not dhcp. If a standard store bought router then make broadcats 192.168.1.255.

Just copy the contents of my upper post to your ifcfg-eth0. Before doing this run the command ' ifdown eth0 ', edit ifcfg-eth0, then run ' ifup eth0 '

From what I have read you want it to look like this:
Code:

DEVICE=eth0
BOOTPROTO=none
onBOOT=yes
#here on down is my work
BROADCAST=192.168.1.255
IPADDR=192.168.1.234
NETMASK=255.255.255.0
NETWORK=192.168.1.0
TYPE=Ethernet
GATEWAY=192.168.1.1

Hope this helps.
Brian1

namit 10-23-2005 10:20 AM

Thanks for that really helpfull works great

:)

namit 10-27-2005 11:32 AM

Hey how do you setup the DNS on this setup?

namit 10-30-2005 07:14 AM

anyone help me with setup up my DNS setup on linux?

TenEighty 11-20-2005 09:20 PM

you need to add a DNS IP to /etc/resolv.conf
seems most routers will forward DNS provided dynamically by the isp, so you simply use the router address. If the router is at 192.168.1.1, this line, and perhaps the only line, should be in your /etc/resolv.conf

nameserver 192.168.1.1


For more,
http://www.linuxquestions.org/questions/answers.php?action=viewarticle&artid=26

at the top of the Linuxquestions.org pages, there's an "answers" button, many many excellent articles in there.

namit 12-29-2005 06:23 AM

sweet that works perfect
using DHCP now


All times are GMT -5. The time now is 04:38 AM.