LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting static IP (https://www.linuxquestions.org/questions/linux-newbie-8/setting-static-ip-4175468784/)

Madhu Desai 07-08-2013 01:01 PM

Clearly there are some other files where NIC is getting IP address other than what you are specifying (192.168.0.201 & 192.168.0.106).

Give o/p of following commands:

Code:

# ls -l /etc/sysconfig/network-scripts/ifcfg-*
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# cat /etc/sysconfig/network-scripts/ifcfg-wlan0
# cat /etc/udev/rules.d/70-persistent-net.rules
# service NetworkManager status
# service network status
# route

...Or, simply what you can do is
  1. Delete all ifcfg-* files in /etc/sysconfig/network-scripts/ (or move it to somewhere else).
  2. Delete file /etc/udev/rules.d/70-persistent-net.rules
  3. Start NetworkManager if switched off (chkconfig NetworkManager on)
  4. Reboot
  5. start system-config-network tool
    Choose 'Device Configuration' and set static IP address for both Network Interfaces (wired & wireless).
  6. Restart network service (service network restart)
  7. Now use the created files (ifcfg-eth0 and ifcfg-wlan0) as templates for future edits.
  8. Switchoff NetworkManager if you dont want (chkconfig NetworkManager off)

NotionCommotion 07-09-2013 08:13 AM

Thank you mddesai,

Quote:

Clearly there are some other files where NIC is getting IP address other than what you are specifying (192.168.0.200 & 192.168.0.106).
Code:

login as: root
root@192.168.0.200's password:
Last login: Mon Jul  8 04:16:49 2013 from 192.168.0.104
[root@desktop ~]# ls -l /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. 3 root root 276 Jul  7 14:09 /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r--. 1 root root 254 Jan  9 03:13 /etc/sysconfig/network-scripts/ifcfg-lo
-rw-r--r--. 3 root root 351 Jul  8 03:28 /etc/sysconfig/network-scripts/ifcfg-wlan0
[root@desktop ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO="Static"
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/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 ~]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="88:51:fb:51:df:70", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1814:0x539b (rt2800pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b8:76:3f:69:31:95", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
[root@desktop ~]# service NetworkManager status
NetworkManager: unrecognized service
[root@desktop ~]# service network status
Configured devices:
lo eth0 wlan0
Currently active devices:
lo wlan0 eth0
[root@desktop ~]# service NetworkManager status
NetworkManager: unrecognized service
[root@desktop ~]# route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.0.0    *              255.255.255.0  U    0      0        0 wlan0
192.168.0.0    *              255.255.255.0  U    0      0        0 eth0
link-local      *              255.255.0.0    U    1002  0        0 wlan0
link-local      *              255.255.0.0    U    1003  0        0 eth0
default        192.168.0.1    0.0.0.0        UG    0      0        0 wlan0
[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:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:104 (104.0 b)  TX bytes:104 (104.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:91083 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6558 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:27503823 (26.2 MiB)  TX bytes:737707 (720.4 KiB)

[root@desktop ~]#

Quote:

...Or, simply what you can do is
Should I also delete /etc/sysconfig/networking/profiles/default/ifcfg-wlan0 and /etc/sysconfig/networking/devices/ifcfg-wlan0?

Madhu Desai 07-09-2013 11:47 AM

Quote:

# ls -l /etc/sysconfig/network-scripts/ifcfg-*
OK. Only interface files available are ifcfg-eth0, ifcfg-wlan0 and ifcfg-lo

Quote:

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
Working properly. Yo have set IP to 192.168.0.201/24, and in ifconfig its showing IP as 192.168.0.201 (eth0). No problemo.

Quote:

# cat /etc/sysconfig/network-scripts/ifcfg-wlan0
I'm not expert in wifi setup, but what i understand is wifi are protected and you have to give encryption key (for WEP/WPA etc) to connect to wireless access point. You should also mention SSID of that wireless router, i guess. Anyway, just look at these links.. you will get an idea. Also i never knew there is iwconfig just like ifconfig. this is something new to me. great...

Enabling wpa_supplicant without NetworkManager
How to configure Wireless on CentOS System
http://www.pantz.org/software/wpa_su...2andlinux.html

Quote:

# cat /etc/udev/rules.d/70-persistent-net.rules
Hardware address for wired interface (eth0) is "88:51:fb:51:df:70" - and thats what you have put in ifcfg-eth0. OK
Hardware address for wireless interface (wlan0) is "b8:76:3f:69:31:95" - You have to mention it in ifcfg-wlan0, as you have two network interfaces.
If you think/doubt hardware addresses are not correct, then you can delete 70-persistent-net.rules file. CentOS will automatically create new file at next boot, and present correct hw address for NICs.

Code:

# service NetworkManager status
NetworkManager: unrecognized service

So you are not using Network Manager, then there is no need to specify 'NM_CONTROLLED=yes' parameter in config files

Quote:

# route
I just wanted to see are there any other subnets. only available subnet is 192.168.0.0/24. OK

Hmmm!!! The only problem is wireless interface... i guess you have to go through the links i have provided. This is out of my expertise.

Edit:
Quote:

Should I also delete /etc/sysconfig/networking/profiles/default/ifcfg-wlan0 and /etc/sysconfig/networking/devices/ifcfg-wlan0?
You can try that... but make sure to take backup of those config files before deleting them.


All times are GMT -5. The time now is 10:59 AM.