1、设置IP
使用vim编辑
编辑/etc/sysconfig/network-scripts/ifcfg-eno16777736
[root@ ]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=49886bac-80b9-432a-81a8-7cf7ccdd6d1f
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.40.190
NETMASK=255.255.255.0
GATEWAY=192.168.40.2
DNS1=202.102.134.68
ONBOOT更改为yes
BOOTPROTO更改为static
添加:
IPADDR
NETMASK
GATEWAY
DNS1
更改完毕后重启网络使设置生效。
[root@ ]# service network restart
2、使用ip a命令查看
[root@ ]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:4c:90:01 brd ff:ff:ff:ff:ff:ff
inet 192.168.40.190/24 brd 192.168.40.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe4c:9001/64 scope link
valid_lft forever preferred_lft forever
3、修改防火墙。
查看防火墙systemctl status firewalld
启动防火墙systemctl start firewalld
临时关闭防火墙systemctl stop firewalld
永久关闭防火墙systemctl disable firewalld