How Fedora virtual machines set up fixed IP internet

Source: Internet
Author: User

Fedora virtual machine Set fixed IP internet (configure IP, gateway, DNS, prevent resolv.conf to be overridden)

First of all, it is stated that this method works under Fedora 17 and version 18, and that other versions may be different.

1. Virtual Machine Related configuration

If it is not a virtual machine system, this step is not required, if the relevant configuration details please see "Linux series: Ubuntu virtual machine Set fixed IP internet access (configure IP, gateway, DNS, prevent resolv.conf)".

2. Set Static IP address

First choose the network interface you want to configure, you can use the IFCONFIG-A command to see which interfaces are currently available, generally choose Eth0, and then edit the corresponding interface configuration file, take eth0 as an example.

sudo vi/etc/sysconfig/network-scripts/ifcfg-eth0

Modify Bootproto from "DHCP" to "Static" and add IPAddr, NETMASK, and gateway parameters, and ensure that Onboot is "yes". My configuration is as follows, everyone Ann according to their own needs to change.

Uuid= "2be778d0-e42b-4a3e-9ad6-598f1681c4a9"
nm_controlled= "yes"
device= "eth0"
ipaddr=192.168.1.137
netmask=255.255.255.0
gateway=192.168.1.2
bootproto=static
onboot= "yes"

3. Configure DNS

Command: sudo vi/etc/resolv.conf

My configuration is as follows:

NameServer 202.38.64.1

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/virtualization/

Of course, this is different from the individual, plus your own DNS server can be, my is the school DNS.

4. Prevent resolv.conf from being rewritten

From the beginning of Resolv.conf's sentence

# Generated by NetworkManager

I know resolv.conf. This file is also generated by NetworkManager, like Ubuntu 12.10 in the Reference document (1).

For Fedora, there are two ways to prevent it from being rewritten (unlike Ubuntu):

Method One: Prohibit network manager service

The following two methods are available to stop the service first and then disable startup.

Chkconfig--level 345 NetworkManager on

Or

Systemctl Stop Networkmanager.service systemctl disable Networkmanager.service

If the above method doesn't work (I do), try the second method below.

Method Two: Do not take over DNS by network manager

You may have already seen the Ifcfg-eth0 configuration file has this sentence configuration:

Nm_controlled= "Yes"

Where NM is network manager, which means that the DNS service is managed by the network manager by default, wouldn't it be all right if we don't manage it?

The solution is:

Change the nm_controlled= "yes" in the file to "no" to indicate that the network manager is not taking over. Then go to resolv.conf Add your own DNS information, restart the network will not be rewritten.

5. Restart Network application Configuration

Systemctl Restart Network.service

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.