CentOS7.6 虚拟机网络配置

CentOS7.6 虚拟机网络配置

1 配置信息

vi /etc/hosts
vi /etc/hostname
vi /etc/sysconfig/network

192.168.146.221 node221
192.168.146.222 node222
192.168.146.213 node223

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

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=a8fee585-868b-4530-aad7-adb9d67a1e65
DEVICE=eth0
ONBOOT=yes
DNS1=8.8.8.8
IPADDR=192.168.146.221
NETMASK=255.255.255.0
GATEWAY=192.168.146.2

2 重启网络

systemctl restart network
service network restart

systemctl stop NetworkManager
systemctl disable NetworkManager

3 关闭防火墙服务

systemctl disable firewalld
systemctl stop firewalld

4 其他信息

设置DNS:
cat /etc/resolv.conf

查看网卡执行日志:
tail -f /var/log/messages

查看网络状态
systemctl status network.service

添加一个ifcfg-ens33配置里指定的网关
route add default gw 192.168.146.2 ens33

设置主机名:
hostnamectl set-hostname node301

状态信息分析:
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
Active: active (exited) since 日 2020-09-20 04:00:17 EDT; 6min ago
Docs: man:systemd-sysv-generator(8)
Process: 10171 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
Process: 10356 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)

9月 20 04:00:17 node301 network[10356]: Help options:
9月 20 04:00:17 node301 network[10356]: -?, --help Show this help message
9月 20 04:00:17 node301 network[10356]: --usage Display brief usage message
9月 20 04:00:17 node301 network[10356]: arping: 192.168.146.301: Name or service not known
9月 20 04:00:17 node301 network[10356]: Error: any valid prefix is expected rather than “192.168.146.301/24”.
9月 20 04:00:17 node301 network[10356]: ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Error adding address 192.168.146.301 for ens33.
9月 20 04:00:17 node301 network[10356]: arping: 192.168.146.301: Name or service not known
9月 20 04:00:17 node301 network[10356]: Error: any valid prefix is expected rather than “192.168.146.301/24”.
9月 20 04:00:17 node301 network[10356]: [ OK ]
9月 20 04:00:17 node301 systemd[1]: Started LSB: Bring up/down networking.

异常分析:
Sep 20 04:00:17 node301 dnsmasq[7496]: using nameserver 192.168.146.2#53
Sep 20 04:00:17 node301 NET[10574]: /etc/sysconfig/network-scripts/ifup-post : updated /etc/resolv.conf
Sep 20 04:00:17 node301 network: [ OK ]
Sep 20 04:00:17 node301 systemd: Started LSB: Bring up/down networking.
Sep 20 04:00:19 node301 avahi-daemon[6627]: Registering new address record for fe80::20c:29ff:fe77:350b on ens33.*.
Sep 20 04:01:00 node301 journal: g_simple_action_set_enabled: assertion ‘G_IS_SIMPLE_ACTION (simple)’ failed
Sep 20 04:01:01 node301 systemd: Created slice User Slice of root.
Sep 20 04:01:01 node301 systemd: Started Session 4 of user root.
Sep 20 04:03:27 node301 journal: g_simple_action_set_enabled: assertion ‘G_IS_SIMPLE_ACTION (simple)’ failed
Sep 20 04:03:58 node301 journal: g_simple_action_set_enabled: assertion ‘G_IS_SIMPLE_ACTION (simple)’ failed

配置信息:
DEVICE=“eth0”
BOOTPROTO=“static”
HWADDR=“00:0C:29:77:35:0B”
NM_CONTROLLED=“yes”
ONBOOT=“yes”
TYPE=“Ethernet”
UUID=“29de14a7-eb19-4e14-bdb5-43453cb12fab”
IPADDR=“192.168.146.301”
GATEWAY=“192.168.146.2”
NETMASK=“255.255.255.0”
DNS1=“8.8.8.8”
ARPCHECK=no

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=a8fee585-868b-4530-aad7-adb9d67a1e65
DEVICE=eth0
ONBOOT=yes
DNS1=8.8.8.8
IPADDR=192.168.146.221
NETMASK=255.255.255.0
GATEWAY=192.168.146.2

GATEWAY=192.168.146.2
DNS1=8.8.8.8

rm /etc/udev/rules.d/70-persistent-net.rules

restarting network (via systemctl): Job for network.service failed
because the control process exited with error code.
See “systemctl status network.service” and “journalctl -xe” for details.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值