【Linux】CentOS操作和问题汇总

1. 设置固定ip

cd /etc/sysconfig/network-scripts
vim ifcfg-ens33

修改为固定ip

BOOTPROTO=static

添加固定ip

IPADDR=192.168.0.152
NETMASK=255.255.255.0
GATEWAY=192.168.0.1

修改dns

vim /etc/resolv.conf

添加或修改

nameserver 8.8.8.8
nameserver 114.114.114.114

重启network

service network restart

检查

[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:f8:aa:cc brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.152/24 brd 192.168.0.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::abb1:4a8a:257f:efec/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

 

上一篇:【linux】虚拟机上的一些问题(ubuntu)


下一篇:【C语言】学习笔记8——结构struct(1)