This article describes how to set up a fixed IP address to access the Internet using Fedora in the vmvm. For more information, see Fedora.
First, declare that the method is valid in Fedora 17 and 18. Other versions may be different.
1. Virtual machine configuration
This step is not required if it is not a virtual machine system. for detailed configuration information, see "graphic tutorial on setting a fixed IP address for Ubuntu in vmmachine ".
2. set static IP addresses
First, select the network interface you want to configure. you can use the ifconfig-a command to view which interfaces are currently available. generally, choose eth0 and edit the configuration file of the corresponding interface. here, eth0 is used as an example.
Copy codeThe code is as follows: sudo vi/etc/sysconfig/network-scripts/ifcfg-eth0
Change BOOTPROTO from "dhcp" to "static", add IPADDR, NETMASK, and GATEWAY parameters, and ensure that ONBOOT is "yes ". My configuration is as follows. you can change the configurations as needed.
Copy codeThe code is as follows: UUID = "2be778d0-e42b-4a3e-9ad6-598f1681c4a9"
NM_CONTROLLED = "yes"
DEVICE = "eth0"
IPADDR = 192.168.1.dr
NETMASK = 255.255.255.0
GATEWAY = 192.168.1.2
BOOTPROTO = static
ONBOOT = "yes"
3. configure DNS
Command:
Copy codeThe code is as follows: sudo vi/etc/resolv. conf
My configuration is as follows:
Copy codeThe code is as follows: nameserver 202.38.64.1
Of course, this varies from person to person. just add your own DNS server, and my on-campus DNS is used.
4. prevent resolv. conf from being overwritten
The sentence starting with resolv. conf
Copy codeThe code is as follows: # Generated by NetworkManager
The resolv. conf file is also generated by the NetworkManager program, just like Ubuntu 12.10 in reference (1.
For Fedora, there are two methods to prevent it from being overwritten (not the same as Ubuntu ):
Method 1: disable the Network Manager service
Stop the service and then disable it. either of the following methods is feasible.
Copy codeThe code is as follows: chkconfig -- level 345 NetworkManager on
Or
Systemctl stop NetworkManager. service
Systemctl disable NetworkManager. service
If the above method does not work (my method works), try the second method below.
Method 2: Network Manager does not take over DNS
You may have been careful to see the ifcfg-eth0 configuration file has such a configuration:
Copy codeThe code is as follows: NM_CONTROLLED = "yes"
Among them, NM is the Network Manager, which means the DNS service is managed by the Network Manager by default. can we just manage it?
The solution is:
Change NM_CONTROLLED = "yes" in the file to "no", indicating that the Network Manager cannot take over. Then add your own DNS information to resolv. conf. after the network is restarted, it will not be overwritten.
5. restart the network application configuration
Copy codeThe code is as follows: systemctl restart network. service