How can I assign static IP to cent OS

asked 25 Jul '13, 01:17

Praful's gravatar image

Praful ♦♦
1264925
accept rate: 5%


The following are the instructions to assign a static IP at the client’s VM- 1.Power the VM ON and use the <ifconfig> command to check the default IP configuration assigned to the VM. We are only interested in the IP that is configured at the Ethernet interface. If you only see the Loopback interface, then do a ‘service network restart’ command and then enter the ‘ifconfig’ command to see the interfaces that are up. 2.If a cloned copy of the VM was used, then go to /etc/udev/rules.d/ folder and open the 70-persistent-net.rules file and make sure that the MAC address that was seen during the ifconfig output and the MAC address that is specified in this file at the corresponding Ethernet interface are the same. If not, replace the MAC address in the file with the one that was seen in the ifconfig output. 3.Now go to the /etc/sysconfig/network-scripts folder and look for the ifcfg-eth<number> file where number is the Ethernet interface ID that was seen in the ifconfig output. If the ifconfig output showed ‘eth5’ and you do not see a ‘ifcfg-eth-5’ file, then you have to create a new file under this name. You could open any existing ifcfg-eth file and make a copy of it and rename it as ifcfg-eth-5 (in this case). 4.Open the ifcfg-eth-<number> file in a VI editor and make the following configurations. a. Update the device name to name of the Ethernet interface(say eth1) as seen in the if config output. b. You could remove the lines beginning with USERCTL, PEERDNS, IPV6INIT and DNS1. c. Now add the following to the file. - HWADDR=specify the MAC address seen in the ifconfig output. - BOOTPROTO=static (change from DHCP to static) - NM_CONTROLLED=no - IPADDR=enter the IP address - NETMASK=enter the network mask - GATEWAY=enter the IP of the gateway. Now save the file. Make sure that the Ethernet interface id in the file name is correct. 5. Open the ‘/etc/resolv.conf’ file in the VI editor and append the line ‘nameserver<space> IPaddress of the DNS server specified’. If the DNS server specified was 10.20.1.2 then append the line - nameserver 10.20.1.2 . Save the file. 6. Now enter the command ‘service network restart’ and make sure that the [OK] status appears under the Bringing up interface <your interface=""> process. To verify the process, you could do a <ifconfig> or a ping test.

link

answered 25 Jul '13, 01:19

Praful's gravatar image

Praful ♦♦
1264925
accept rate: 5%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1
×1

Asked: 25 Jul '13, 01:17

Seen: 1,465 times

Last updated: 25 Jul '13, 01:19

Related questions