主機獲取不到ip的解決方法

原因由於配置文件ONBOOT="no"導致主機獲取不到ip

1 查看配置文件
$ cat /etc/sysconfig/network-scripts/ifcfg-eno1
DEVICE="eno1"
NAME="eno1"
ONBOOT="yes"
TYPE=Ethernet
HWADDR="24:be:05:0c:1e:92"
BRIDGE="switch"
BOOTPROTO="none"
HOTPLUG="no"
NM_CONTROLED="no"

$ cat /etc/sysconfig/network-scripts/ifcfg-switch
DEVICE="switch"
NAME="switch"
ONBOOT="no"
TYPE=Bridge
BOOTPROTO="dhcp"
NM_CONTROLED="no"
DELAY=0

2 更改文件,將ONBOOT="no"改為 ONBOOT="yes"
[root@dhcp-8-118 ~]# vim /etc/sysconfig/network-scripts/ifcfg-switch

DEVICE="switch"
NAME="switch"
ONBOOT="yes"
TYPE=Bridge
BOOTPROTO="dhcp"
NM_CONTROLED="no"
DELAY=0

3 重新啟動網卡
[root@dhcp-8-118 ~]# systemctl restart network

4 查看獲取到的ip
[root@dhcp-8-118 ~]# ip a s
1: lo: mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno1: mtu 1500 qdisc fq_codel master switch state UP qlen 1000
    link/ether 24:be:05:0c:1e:92 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::26be:5ff:fe0c:1e92/64 scope link
       valid_lft forever preferred_lft forever
4: virbr0: mtu 1500 qdisc noqueue state DOWN
    link/ether 52:54:00:15:59:94 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
5: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN qlen 500
    link/ether 52:54:00:15:59:94 brd ff:ff:ff:ff:ff:ff
6: switch: mtu 1500 qdisc noqueue state UP
    link/ether 24:be:05:0c:1e:92 brd ff:ff:ff:ff:ff:ff
    inet 10.66.8.118/22 brd 10.66.11.255 scope global dynamic switch
       valid_lft 86398sec preferred_lft 86398sec
    inet6 fe80::26be:5ff:fe0c:1e92/64 scope link
       valid_lft forever preferred_lft forever

你可能感兴趣的:(linux)