LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-29-2016, 03:47 AM   #1
harshld
LQ Newbie
 
Registered: Nov 2016
Posts: 3

Rep: Reputation: Disabled
Configuring Static IP Addresses in Centos 7


I am trying to assign static IP address to Centos 7 with the commands

vim /etc/sysconfig/network-scripts/ifcfg-ens33

I can edit and it is saving but when i try checking for configs through ifconfig it is the same ip as of earlier through dhcp. using centos in a virtual environment of VMware.

please suggest.!!!!
 
Old 11-29-2016, 05:20 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,079

Rep: Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445
I suggest that after changing any network scripts you do a restart on your networking (or reboot) since the changes only take effect on network start.

By the way, if you intended to show us the cfg file contents inside a CODE block, that did not work.

Last edited by wpeckham; 11-29-2016 at 05:21 AM.
 
Old 11-29-2016, 08:28 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693
Centos 7, after making changes:

Code:
systemctl restart network.service
 
Old 12-01-2016, 04:06 AM   #4
harshld
LQ Newbie
 
Registered: Nov 2016
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by szboardstretcher View Post
Centos 7, after making changes:

Code:
systemctl restart network.service


Thanks, that did help. I was able to configure a static IP in centos but now it does not have any connectivity to internet.

I am using CENTOS 7 in VMWare, earlier the IP address (dhcp) was 192.168.139.135, but now when I assigned 192.168.139.100, it can neither ping any website or connect in any manner.

ping google.com
ping: unknown host google.com


this is the output when I try to do ping.

is there anything I am missing in vim /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.139.100
NETMASK=255.255.255.0
GATEWAY=192.168.139.2
DOMAIN=majan.com
DNS1=192.168.139.100
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=yes
NAME=ens33
UUID=5f06d8d9-273b-45a8-807b-35e2e27c840f
DEVICE=ens33
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes


this is what I entered.

Please help.
 
Old 12-01-2016, 04:53 AM   #5
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 363Reputation: 363Reputation: 363Reputation: 363
Can you ping by ip#? Like: ping 8.8.8.8? IF not, post: ip a;ip r
DNS1=192.168.139.100 [==] IPADDR=192.168.139.100
doesn't look 'good IMHO': I doubt that this is its own DNS server! Try MAYBE:
DNS1=192.168.139.2 (the gw, or 8.8.8.8)
 
Old 12-01-2016, 05:48 AM   #6
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,079

Rep: Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445Reputation: 2445
Following the advice given by Jjanel will determine if the problem is in the routing, or only in DNS resolution.
Generally, any good ISP will provide at least TWO DNS servers, but I always include a third that is a fast public DNS. The nameserver at 8.8.8.8 is a public DNS provided by google. They also provide a backup at 8.8.4.4, and LEvel3 communications offers 4.2.2.2, but there are MANY others. In your file settings are allowed for DNS1=, DNS2=, and DNS3=. Technically you can assign as many as you like, but the network stack will only ever use the first three: and only the first ONE if it always responds.
 
  


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
[SOLVED] Configuring Static IP CentOS so router Motorola NVG510 can recognize device and port forward NAT. jmc1987 Linux - Newbie 12 10-08-2013 09:41 PM
Changing Static IP Addresses Biggen Slackware 15 07-13-2009 08:51 PM
Howto Assign Multiple Static Public IP Addresses under SBC's PPPoE Static Ip system o trekgraham Linux - Networking 8 04-17-2007 10:51 AM
Static IP addresses BCarey Linux - Networking 5 05-06-2006 04:30 PM
Configuring domain names on static IP addresses from SBC DSL redbasin Linux - Networking 4 02-10-2004 10:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:05 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
Open Source Consulting | Domain Registration