LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   how do i set a static ip address? (http://www.linuxquestions.org/questions/linux-networking-3/how-do-i-set-a-static-ip-address-795663/)

oznola 03-15-2010 11:10 PM

how do i set a static ip address?
 
hi,

i have a ubuntu 9.10 server on a wlan behind a debian server/router/firewall.

i have had dhcp assigning the ip address to the server and then accessing the server through a port forward that has been working okay.

i want to assign a static ip address to the server so that i wont have to worry about checking that as i reboot the system and so forth.

subsequently on the ubuntu server i have /etc/network/interfaces that looks like this...

Quote:

auto eth0
iface eth0 inet static
address 192.168.10.2
gateway 192.168.10.1
netmask 255.255.255.0
then i run /etc/init.d/netwroking restart.

on the debian server/router/firewall i have added...

Quote:

192.168.10.2 oznola.localdomain oznola
to /etc/hosts and then run /etc/init.d/dnsmasq restart.

then i change the port forward rule to give it the new static ip address:192.168.10.2

after that i am still not able to ping the new server but i can see it using lookup.

also, i have observed that the old dhcp address is still leased to oznola after all the above.

am i leaving something out?



please advise.

ps. the /etc/network/interfaces on the debian server/router/firewall looks like this...


Code:

iface eth1 inet static
netmask 255.255.255.0
address 192.168.10.1

iface eth0 inet static
gateway 24.234.112.225
netmask 255.255.255.224
address 24.234.112.226


GlennsPref 03-16-2010 02:17 AM

Hi, I generally set my static ip's directly to the ifcfg file for the device.

/etc/sysconfig/network-scripts/ifcfg-eth0...
Code:

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0
GATEWAY=10.64.64.64
ONBOOT=yes
METRIC=10
MII_NOT_SUPPORTED=no
USERCTL=yes
MTU=1492
DNS1=203.2.193.67
DNS2=202.135.30.4
DOMAIN=vfinternet.au
RESOLV_MODS=no
LINK_DETECTION_DELAY=6
IPV6INIT=no
IPV6TO4INIT=no
ACCOUNTING=yes

But I don't serve pages from here (this machine).

But I've been using the same rsync script for a few years now, and the only changes are when I switch ISP's (Internet service providers)Namely, DNS1 and 2, Gateway and Domain.

/etc/sysconfig/network
Code:

HOSTNAME=GamesBox.GlennsPref.net
NETWORKING=yes
GATEWAYDEV=ppp0
FORWARD_IPV4=true
CRDA_DOMAIN=AU

I might be off topic, but I hope it gives you some pointers.

A web-page I have found usefull...
http://www.linuxhomenetworking.com/

Regards Glenn

spampig 03-16-2010 02:18 AM

If this were the desktop version I'd suspect Network Manager had a hand in the odd behaviour. However, you've pointed out that it's the server version - so I don't *think* it would be an issue.......

Checking the basics here, on the Ubuntu server what is the output of:
Quote:

ifconfig -a
?

spampig 03-16-2010 02:20 AM

Quote:

Originally Posted by GlennsPref (Post 3899940)
Hi, I generally set my static ip's directly to the ifcfg file for the device.

/etc/sysconfig/network-scripts/ifcfg-eth0...

Default Ubunutu server does not have '/etc/sysconfig/network-scripts/' AFAIR.

It has these similar offerings:

Quote:

ls -alh /etc/network
total 40K
drwxr-xr-x 6 root root 4.0K 2010-03-03 06:47 .
drwxr-xr-x 109 root root 12K 2010-03-15 13:46 ..
drwxr-xr-x 2 root root 4.0K 2009-11-17 06:47 if-down.d
drwxr-xr-x 2 root root 4.0K 2009-07-06 10:00 if-post-down.d
drwxr-xr-x 2 root root 4.0K 2009-05-14 15:58 if-pre-up.d
drwxr-xr-x 2 root root 4.0K 2009-11-17 06:47 if-up.d
-rw-r--r-- 1 root root 215 2009-05-14 16:15 interfaces
and it may be worth checking the contents of '/etc/network/if-up.d/' in case there is a script in there playing around with things.

Also check to make sure the box is not running a DHCP server itself that is tied to eth0. Look for this file: '/etc/default/dhcp3-server'

GlennsPref 03-16-2010 02:50 AM

I began to think as much, But for as fedora sys, it may have been true.

Thank you for your efforts.

Glenn

oznola 03-16-2010 03:00 AM

hi,

i have the ubuntu desktop installed on the ubuntu server. network manager is present on the machine. here is the output of ifconfig -a...

Code:

af@oznola:~$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:16:41:59:15:cc 
          inet addr:192.168.10.2  Bcast:192.168.10.255  Mask:255.255.255.0
          UP 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)
          Memory:ee000000-ee020000

irda0    Link encap:IrLAP  HWaddr 00:00:00:00 
          NOARP  MTU:2048  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:8
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

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:120 errors:0 dropped:0 overruns:0 frame:0
          TX packets:120 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11292 (11.2 KB)  TX bytes:11292 (11.2 KB)

pan0      Link encap:Ethernet  HWaddr 3a:a2:76:d9:41:99 
          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:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0    Link encap:Ethernet  HWaddr 00:13:02:99:76:fd 
          inet addr:192.168.10.53  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::213:2ff:fe99:76fd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6139 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2079263 (2.0 MB)  TX bytes:6256 (6.2 KB)

wmaster0  Link encap:UNSPEC  HWaddr 00-13-02-99-76-FD-39-39-00-00-00-00-00-00-00-00 
          UP RUNNING  MTU:0  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)

af@oznola:~$

observe the difference between the ip address of wlan0 and eth0.


here is the contents of /etc/default...

Code:

af@oznola:/etc/default$ ls -alh
total 112K
drwxr-xr-x  2 root root 4.0K 2010-03-11 07:49 .
drwxr-xr-x 136 root root  12K 2010-03-16 00:53 ..
-rw-r--r--  1 root root 5.1K 2009-10-13 01:50 acpi-support
-rw-r--r--  1 root root  638 2010-02-22 21:57 alsa
-rw-r--r--  1 root root  637 2009-08-18 06:01 apache2
-rw-r--r--  1 root root  243 2009-10-23 02:54 apport
-rw-r--r--  1 root root  47 2009-09-07 11:58 bootlogd
-rw-r--r--  1 root root  117 2010-02-22 22:02 brltty
-rw-r--r--  1 root root 1.7K 2010-02-22 21:06 console-setup
-rw-r--r--  1 root root  122 2010-01-28 02:06 cups
-rw-r--r--  1 root root  92 2009-09-07 11:58 devpts
-rw-r--r--  1 root root  58 2010-02-22 22:24 google-chrome
-rw-r--r--  1 root root  797 2010-02-22 21:24 grub
-rw-r--r--  1 root root  86 2009-09-07 11:58 halt
-rwxr-xr-x  1 root root  84 2009-11-02 10:01 kerneloops
-rw-r--r--  1 root root  19 2010-02-22 21:06 locale
-rw-r--r--  1 root root  456 2009-10-22 14:56 ntpdate
-rw-r--r--  1 root root  965 2010-01-16 08:19 pulseaudio
-rw-r--r--  1 root root  261 2010-02-22 21:24 rcS
-rw-r--r--  1 root root 1.4K 2009-06-25 06:12 rsync
-rw-r--r--  1 root root  146 2010-02-22 22:00 saned
-rw-r--r--  1 root root  95 2009-10-12 22:26 speech-dispatcher
-rw-r--r--  1 root root  289 2009-09-07 11:58 tmpfs
-rw-r--r--  1 root root 1.7K 2009-09-23 17:41 ufw
-rw-r--r--  1 root root 1.1K 2009-07-31 06:55 useradd
af@oznola:/etc/default$


oznola 03-16-2010 03:07 AM

my bad!
 
here is the contents of /etc/network/if-up.d/...

Code:

af@oznola:/etc/network/if-up.d$ ls -alh
total 32K
drwxr-xr-x 2 root root 4.0K 2010-02-22 22:37 .
drwxr-xr-x 6 root root 4.0K 2010-03-16 00:30 ..
-rwxr-xr-x 1 root root  892 2009-11-03 15:49 avahi-autoipd
-rwxr-xr-x 1 root root  504 2009-11-03 15:49 avahi-daemon
-rwxr-xr-x 1 root root 1.4K 2009-04-28 16:12 ethtool
-rwxr-xr-x 1 root root 1.2K 2009-10-22 14:56 ntpdate
-rwxr-xr-x 1 root root 1.1K 2009-09-22 06:52 postfix
-rwxr-xr-x 1 root root  128 2009-09-14 14:03 upstart
lrwxrwxrwx 1 root root  32 2010-02-22 21:22 wpasupplicant -> ../../wpa_supplicant/ifupdown.sh
af@oznola:/etc/network/if-up.d$


GlennsPref 03-16-2010 04:05 AM

wpa-supplicant is used for 802.11 wireless networking.

try without it, unless you're sure you need it to connect to the internet.

regards Glenn

spampig 03-16-2010 04:11 AM

Quote:

Originally Posted by GlennsPref (Post 3899977)
I began to think as much, But for as fedora sys, it may have been true.
Glenn

Forgive me Glenn - it's just my distro envy :-)

With regards to the original issue - I suspect the trouble is being caused by Network Manager. It used to have a habit of 'helpfully' overwriting /etc/network/interfaces (and resolv.conf for that matter) each time you restarted networking. I guess it still does something retarded like that.

A quick look at Google reveals a couple of suggestions (one is to remove Network Manager - but that may be overkill, you should be able to set a static IP with it).

Take a look at these and see if they help:
http://ubuntuforums.org/showthread.php?t=1309835
http://ubuntuforums.org/showthread.php?t=1304848

GlennsPref 03-16-2010 04:19 AM

True, I also disable resolv.conf most of the time.

Because my usb-modem offers 10.11.12.13/14 as dns servers, but linux never could connect.

strange, I guess it's linux VS window$ configs.

Cheers, Glenn

oznola 03-16-2010 04:28 PM

okay!
 
hi,

i have ~used~ the network manager to setup the static ip address and now it seems to be working okay. http://alonzofretwell.com:1234 with the port forward rule set to 192.168.10.2.

however, the lan is still showing that oznola has the dhcp lease on 192.168.10.53. it is set to expire tonight at midnight thirty-five or about 24 hours after i started to change things last night.

so do i just wait for that lease to expire?

obviously it should eventually be freed for the purpose of dhcp.

i know this is out of scope of the thread. :)

thank you for all your help.:hattip:


All times are GMT -5. The time now is 10:24 PM.