文章目录
  1. 1. 将linux系统的ip地址设置为静态
    1. 1.1. Disable Network Manager
    2. 1.2. Set the Static Address
    3. 1.3. Configure DNS
      1. 1.3.1. 遇到的问题

将linux系统的ip地址设置为静态

参考这里

Disable Network Manager

  1. First stop and disable the gnome network manager from running on boot.

     systemctl stop NetworkManagerservice
    
     systemctl disable NetworkManagerservice
    
  2. Now start and enable the network service to run on boot.

     systemctl restart networkservice
    
     systemctl enable networkservice
    

Set the Static Address

  1. Check which interface(s) you want to set as static.
  1. Next edit the config file for the required interface.

sysconfignetworkscriptsifcfg

  1. Edit the config file to look similar to the following.

Change the BOOTPROTO from “dhcp” to “static”. Also adding IPADDR, NETMASK, BROADCAST and NETWORK variables and make sure ONBOOT is set to yes.

"e88f1292-1f87-4576-97aa-bb8b2be34bd3"
NM_CONTROLLED"yes"
HWADDR"D8:D3:85:AE:DD:4C"
BOOTPROTO"static"
DEVICE"em1"
ONBOOT"yes"
IPADDR192.168
NETMASK255.255255.0
BROADCAST192.1681.255
NETWORK192.168
GATEWAY192.168

Apply the Settings

Restart the network service to apply the settings.

systemctl restart networkservice

Configure DNS

Make sure the correct DNS servers are configured to allow Fedora to resolve domains.

resolv

nameserver 192.168
nameserver

遇到的问题

在进行 Disable Network Manager 操作的第二步restart时出现一个错误:

[root@aleks network-scripts]# systemctl restart network.service 
Job failed. See system journal and 'systemctl status' for details.

出现这个问题的原因是:

网络配置器 em1 中的mac地址与硬件的mac地址不一样导致的
执行:

 ip address show

与网络配置文件比较一下

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

如果不一样,将配置文件的的 HWADDR 项的值改成一样的

然后再执行,

ifup em1

好了以后再执行

systemctl restart networkservice

搞定。。。。。

文章目录
  1. 1. 将linux系统的ip地址设置为静态
    1. 1.1. Disable Network Manager
    2. 1.2. Set the Static Address
    3. 1.3. Configure DNS
      1. 1.3.1. 遇到的问题