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 |
I'm most familiar with Red Hat and Fedora and the setting to make the IP static is bootproto
Quote:
Hope that helps |
What distro are you using? How to set a static IP address can vary depending on the init system of your distro.
|
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. |
|
@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:
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 |
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" Code:
GATEWAY=192.168.1.100 #Added Code:
nameserver 192.168.1.200 #Added before nameserver 8.8.8.8 and nameserver 8.8.4.4 What actions were made by these changes, and why do you think I lost communication? |
mddesai, I appreciate the "whys" you should do something. Thank you
Quote:
Quote:
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 |
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. |
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 |
Thanks jpollard,
Just to confirm, BOOTPROTO=static is something I definitely do not want, correct? |
Quote:
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:
Quote:
Quote:
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) |
Quote:
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) |
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) |
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 |
All times are GMT -5. The time now is 08:26 AM. |