LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to change ip? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-ip-4175559094/)

windstory 11-17-2015 05:53 AM

how to change ip?
 
1 Attachment(s)
My box is Centos 7.1 x64 as guest on windows 10 x64 as host.

I installed Centos several times, because when I change network ip or mac address Centos could not connect with internet.

This is the photo after centos was instaled.


Any helpful comments would be appreciated.
Thanks in advance.

Shadow_7 11-17-2015 07:27 AM

As root (or with sudo)

# ifconfig eth0 192.168.1.2 netmask 255.255.255.0

Where eth0 is the interface name "ifconfig -a". And 192.168.1.2 is the IP you want to change it to. Although many times DHCP sets that up for you. With dhcpcd or dhclient depending on what your distro has and what you prefer. There's also routing that need to be setup. Which is handled for you with DHCP. There's also "ip" which is the new way of doing what ifconfig and stuff does, but I'm not that versed about it, other than it exists. And I sometimes need to use it to force IPv4 on the wifi device.

# route add default gw 192.168.1.1

Although it's more likely that dhcp is setup.

# dhclient -v eth0

pan64 11-17-2015 07:53 AM

you gave almost no information. Especially: how did you configure your network during installation? How did you try to change that IP? What kind of VM do you use? How is it configured (network related settings)?

windstory 11-17-2015 07:57 AM

1 Attachment(s)
Shadow_7/

I tried the 3 commands and the results are at the attached photo.

berndbausch 11-17-2015 08:20 AM

Quote:

Originally Posted by windstory (Post 5450900)
Shadow_7/

I tried the 3 commands and the results are at the attached photo.

It looks like your DHCP server is not accessible or not answering.

My suggestion: Read the documentation.

windstory 11-17-2015 08:37 AM

berndbausch/


L got a hint from your comment, and I did "systemctl restart network" and reboot, then internet access problem was solved.


All times are GMT -5. The time now is 07:12 PM.