LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-07-2013, 01:52 PM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Rep: Reputation: Disabled
Setting static IP


Why doesn't ifconfig show wlan0's IP address as 192.168.0.200? How do I make it do so. Sometimes I can SSH into it using 192.168.0.200, but other times only 192.168.0.104 seems to work.

Why do I have identical files at:
/etc/sysconfig/networking/profiles/default/ifcfg-wlan0
/etc/sysconfig/networking/devices/ifcfg-wlan0
/etc/sysconfig/network-scripts/ifcfg-wlan0

Thank you

Code:
[root@desktop ~]# cat /etc/sysconfig/networking/profiles/default/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=88:51:fb:51:df:70
IPV6INIT=yes
IPV6_AUTOCONF="yes"
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID="e636c50d-822a-498b-8156-3c3b75d4fe4b"
USERCTL=no
IPADDR=192.168.0.201
NETMASK=255.255.255.0
DNS2=8.8.4.4
GATEWAY=192.168.0.1
DNS1=8.8.8.8

[root@desktop ~]# cat /etc/sysconfig/networking/devices/ifcfg-wlan0
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
GATEWAY=192.168.0.1
DNS1=8.8.8.8
DEVICE=wlan0
BOOTPROTO=none
NETMASK=255.255.255.0
DNS2=8.8.4.4
TYPE=Wireless
HWADDR=b8:76:3f:69:31:95
IPADDR=192.168.0.200
IPV6INIT=no
ONBOOT=yes
USERCTL=no

[root@desktop ~]# cat /etc/sysconfig/network-scripts/ifcfg-wlan0
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
GATEWAY=192.168.0.1
DNS1=8.8.8.8
DEVICE=wlan0
BOOTPROTO=none
NETMASK=255.255.255.0
DNS2=8.8.4.4
TYPE=Wireless
HWADDR=b8:76:3f:69:31:95
IPADDR=192.168.0.200
IPV6INIT=no
ONBOOT=yes
USERCTL=no

[root@desktop ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 88:51:FB:51:DF:70
          inet addr:192.168.0.201  Bcast:192.168.0.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)

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: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 B8:76:3F:69:31:95
          inet addr:192.168.0.104  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::ba76:3fff:fe69:3195/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2098 errors:0 dropped:0 overruns:0 frame:0
          TX packets:579 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:418993 (409.1 KiB)  TX bytes:95179 (92.9 KiB)

[root@desktop ~]#

Last edited by NotionCommotion; 07-07-2013 at 11:03 PM.
 
Old 07-07-2013, 09:34 PM   #2
Linux MR
Member
 
Registered: May 2013
Location: Pacific North West
Distribution: Red Hat, Scientific, Fedora, openSuSE, Mageia, Mint, Arch
Posts: 57

Rep: Reputation: Disabled
I'm most familiar with Red Hat and Fedora and the setting to make the IP static is bootproto

Quote:
file: /etc/sysconfig/network-scripts/ifcfg-<device>
parameter: BOOTPROTO=static
After setting the BOOTPROTO I would suggest restarting the network service.

Hope that helps
 
Old 07-07-2013, 10:13 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mint, OpenBSD
Posts: 11,342
Blog Entries: 12

Rep: Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730
What distro are you using? How to set a static IP address can vary depending on the init system of your distro.
 
Old 07-07-2013, 10:52 PM   #4
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Original Poster
Rep: Reputation: Disabled
Thank you Gents,

I am using CentOS 6.4.

The eth0 files seem to have been made magically, by me but I forgot, or after I used system-config-network.

I know I manually copied one of the wlan0 files, and modified another to make them look the same in an attempt to mimic the eth0 files.

If only one of the three is important, I wish to only modify those and ignore the rest.

Thanks again for your help.
 
Old 07-07-2013, 10:55 PM   #5
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mint, OpenBSD
Posts: 11,342
Blog Entries: 12

Rep: Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730Reputation: 2730
CentOS works like RHEL.

This should help:

http://www.broexperts.com/2013/03/ho...in-centos-6-3/
 
Old 07-08-2013, 02:30 AM   #6
mddnix
Member
 
Registered: Mar 2013
Location: Bangalore, India
Distribution: Redhat, Arch, Ubuntu
Posts: 505

Rep: Reputation: 137Reputation: 137
@NotionCommotion

1.In Redhat/CentOS/SL/OL,

ethX = Ethernet Physical connection
wlan0 - Wireless connection

2.You should not edit manually files under '/etc/sysconfig/networking/' directory. It is used by 'system-config-network' tool, which redhat says is now deprecated. You should use files under '/etc/sysconfig/network-scripts/' ONLY.

3. Which do you have/use - Physical connection(eth) or Wireless connection(wlan)? Remove the other irrelevant file.

Typical ifcfg-eth0 sample for static IP:
Quote:
DEVICE=eth0
NAME="System eth0"
TYPE=Ethernet

ONBOOT=yes
BOOTPROTO=none
#NM_CONTROLLED=yes

IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1

DNS1=8.8.8.8
DNS2=8.8.4.4

DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
USERCTL=no
#NM_CONTROLLED=yes (use this if you want NetworkManager to control the connection (little two computers icon in system tray).
PREFIX=24 (Alternative NETMASK=255.255.255.0)

After editing file (in /network-scripts/), restart service to take effect

Depending on your configuration

Code:
# service network status
# service NetworkManager status

# service network restart
# service NetworkManager restart

Last edited by mddnix; 07-08-2013 at 02:43 AM.
 
Old 07-08-2013, 09:25 AM   #7
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Original Poster
Rep: Reputation: Disabled
Thank you Frank,

I made the changes per the Bros Experts. Specifically, changes from my existing...

/etc/sysconfig/network-scripts/ifcfg-wlan0
Code:
BOOTPROTO="static"
NM_CONTROLLED="no" #Was none
/etc/sysconfig/network
Code:
GATEWAY=192.168.1.100 #Added
/etc/resolv.conf
Code:
nameserver 192.168.1.200 #Added before nameserver 8.8.8.8 and nameserver 8.8.4.4
Unfortunately, lost ssh communication to my server

What actions were made by these changes, and why do you think I lost communication?
 
Old 07-08-2013, 10:10 AM   #8
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Original Poster
Rep: Reputation: Disabled
mddesai, I appreciate the "whys" you should do something. Thank you

Quote:
2. You should not edit manually files under '/etc/sysconfig/networking/' directory. It is used by 'system-config-network' tool, which redhat says is now deprecated. You should use files under '/etc/sysconfig/network-scripts/' ONLY.
Thank you, great information. Should I just modify /etc/sysconfig/network-scripts/ manually? Do I not worry about the other two since I will no longer using system-config-network?

Quote:
3. Which do you have/use - Physical connection(eth) or Wireless connection(wlan)? Remove the other irrelevant file.
wlan, however, if wlan stops, I want like to default upon eth, however, it isn't 100% necessarily. Confirm you are recommending I delete /etc/sysconfig/network-scripts/eth0 in its entirety. I am not using NetworkManager, and this is probably the reason I lost communication (see previous post to Frank)

Below is the new /etc/sysconfig/network-scripts/wlan0 I propose to use. Look good? Please check out my comment/questions throughout it.
Code:
DEVICE=wlan0 #Changed to wireless
NAME="System wlan0"
TYPE=Wireless

ONBOOT=yes
BOOTPROTO=none #Why not static?
#NM_CONTROLLED=yes

IPADDR=192.168.0.100 #Note 1 was change to 0
PREFIX=24 #What does this do?  Why not using NETMASK?
# NETMASK=255.255.255.0
GATEWAY=192.168.0.1

DNS1=8.8.8.8
DNS2=8.8.4.4

#Please describe why you include these
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
USERCTL=no 

#There were not on your list.  Please describe why
UUID="e636c50d-822a-498b-8156-3c3b75d4fe4b"
HWADDR=88:51:fb:51:df:70
 
Old 07-08-2013, 10:15 AM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
BOOTPROTO=none is to tell the startup code NOT to try things like DHCP, which can change all kinds of things.

PREFIX=24 defines the same (and used) the same way as netmask. The advantage is that it can also work for IPv6 where netmasks get horribly complicated.

DEFROUTE=yes is so you get a default route. If you have more than one network interface, only one of them should have "yes", the others "no". Or just the one you want to use for your default route. In my case, I have it on the second network interface. The first one is my internal net, the second is the route to the internet.

IPV4_FAILURE_FATAL=yes will stop the boot process because you are telling the system that you MUST have IPv4 available.

IPV6INIT=no is to disable the use of IPv6. This is sometimes useful because some ill-mannered applications will not handle DNS lookups if a lookup fails on IPv6, and doesn't try an IPv4 lookup. Disabling IPv6 forces all applications to use IPv4 only.

USERCTL=no prevents users from doing things to this interface.

Last edited by jpollard; 07-08-2013 at 10:22 AM.
 
Old 07-08-2013, 10:27 AM   #10
Mousepad123
LQ Newbie
 
Registered: Oct 2012
Distribution: CentOS or Debian
Posts: 25

Rep: Reputation: 3
Although this issue looks as though it's been solved, I would like to say one thing:

If you need to set a temporary static IP, you can use this command:

Code:
ifconfig eth0 192.168.1.2/24
(that would set the IP of adapter eth0 to 192.168.1.2 with a netmask of 24 (255.255.255.0) until you reboot)
 
Old 07-08-2013, 10:35 AM   #11
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Original Poster
Rep: Reputation: Disabled
Thanks jpollard,

Just to confirm, BOOTPROTO=static is something I definitely do not want, correct?
 
Old 07-08-2013, 11:18 AM   #12
mddnix
Member
 
Registered: Mar 2013
Location: Bangalore, India
Distribution: Redhat, Arch, Ubuntu
Posts: 505

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by NotionCommotion View Post
Should I just modify /etc/sysconfig/network-scripts/ manually? Do I not worry about the other two since I will no longer using system-config-network?
Redhat in its documentation, has clearly mentioned NOT to use anything under /sysconfig/networking/ and SHOULD only use scripts under /sysconfig/network-scripts/. (links I have attached below).

Either you edit the script, or Network Manger edits the script, both are written to same script that are under /sysconfig/network-scripts/ - in order who edits it last. Exactly why scripts under /sysconfig/networking/ are used I don’t know, but whatever you do to scripts in /network-scripts/ are updated to /networking/, so eventually both will be same. However, Redhat says it is now depreciated.

Its your wish if you want to use Network Manager or not. Personally I feel its redundant, so I don’t use it (chkconfig NetworkManager off)
Quote:
Originally Posted by NotionCommotion View Post
wlan, however, if wlan stops, I want like to default upon eth, however, it isn't 100% necessarily. Confirm you are recommending I delete /etc/sysconfig/network-scripts/eth0 in its entirety.
If you are using both interfaces, you don't have to delete. let them be there. no harm
Quote:
Originally Posted by NotionCommotion View Post
Below is the new /etc/sysconfig/network-scripts/wlan0 I propose to use. Look good? Please check out my comment/questions throughout it.
To be frank, I have never setup wireless devices – only servers and desktops with wired connections. So I'm unaware of wireless LAN setup HOWTO.
Quote:
Just to confirm, BOOTPROTO=static is something I definitely do not want, correct?
I think you can put either none or static. both are same.

Links:
Chapter 8. NetworkManager (GUI Tool)
Chapter 9. Network Interfaces (For manual edit)
Red Hat Enterprise Linux 6 Deployment Guide (Full book online)
Red Hat Enterprise Linux 6 Deployment Guide (PDF Download - Right click and save)

Last edited by mddnix; 07-08-2013 at 11:19 AM.
 
Old 07-08-2013, 11:20 AM   #13
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by NotionCommotion View Post
Thanks jpollard,

Just to confirm, BOOTPROTO=static is something I definitely do not want, correct?
"static" is no longer defined. The only valid values for BOOTPROTO are:

none No boot-time protocol should be used.
bootp The BOOTP protocol should be used.
dhcp The DHCP protocol should be used.

From http://www.centos.org/docs/2/rhl-rg-...rkscripts.html (which is a bit dated)
and: https://github.com/cobbler/cobbler/issues/361 (which is the most recent, and over a PXE boot bug where "static" was still accepted)
 
Old 07-08-2013, 12:07 PM   #14
mddnix
Member
 
Registered: Mar 2013
Location: Bangalore, India
Distribution: Redhat, Arch, Ubuntu
Posts: 505

Rep: Reputation: 137Reputation: 137
Regarding parameters in ethernet config file, jpollard has already explainted it right.

About UUID, it is genetrated by Network Manager tool to differentiate between different inerfaces. unless you use NetworkManager you can remove this parameter safely.

HWADDR, are physical hardware address embedded in NIC. unless you have more than one NIC, you can also ignore this parameter too.

More about these parameters are in 2nd-4th page of document i have posted. (Chapter 9. Network Interfaces)

Last edited by mddnix; 07-08-2013 at 12:09 PM.
 
Old 07-08-2013, 01:24 PM   #15
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Original Poster
Rep: Reputation: Disabled
Thank you all for your help.

I made the changes, and ifconfig still shows a different IP than 192.168.0.200. See below. Note that I can PuTTY into the server using either 192.168.0.106 or 192.168.0.200. Any thoughts why?

If I have both a wireless NIC and a CAT-5 NIC, any reason for HWADDR?

PS. Why am I setting up wireless on a server one might ask? It is only for development purposes, is located in my garage, and just didn't want to deal with running wire.


Code:
[root@desktop ~]# cat /etc/sysconfig/network-scripts/ifcfg-wlan0
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.

DEVICE=wlan0
NAME=wlan0
TYPE=Wireless

ONBOOT=yes
BOOTPROTO=none
#NM_CONTROLLED=yes

IPADDR=192.168.0.200
PREFIX=24
# NETMASK=255.255.255.0
GATEWAY=192.168.0.1

DNS1=8.8.8.8
DNS2=8.8.4.4

DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
USERCTL=no

[root@desktop ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 88:51:FB:51:DF:70
          inet addr:192.168.0.201  Bcast:192.168.0.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)

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: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 B8:76:3F:69:31:95
          inet addr:192.168.0.106  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::ba76:3fff:fe69:3195/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1315 errors:0 dropped:0 overruns:0 frame:0
          TX packets:120 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:388810 (379.6 KiB)  TX bytes:19225 (18.7 KiB)

[root@desktop ~]#
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting static IP on linux PCs with no static IP address from internet provider? solvetek Linux - Networking 1 10-22-2011 09:04 AM
Setting a static IP dreakon SUSE / openSUSE 2 10-02-2005 04:08 PM
Setting a static IP hongman Linux - Networking 6 02-22-2005 06:07 AM
Setting Static IP smurfix Debian 6 02-20-2005 04:07 PM
Setting a Static IP wh33t Mandriva 1 12-20-2003 06:04 AM


All times are GMT -5. The time now is 02:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration