centos 设置静态网络

中心:修改网卡的配置文件为静态地址,需要将自动分配地址修改为静态,然后设置地址信息

操作

1、查看网卡文件:ip addr

2、修改网卡对应的文件: vi /etc/sysconfig/network-scripts/ifcfg-ens33

3、修改参数

centos 设置静态网络

4、重启网络: systemctl restart network

操作记录

7月 04 15:55:24 localhost.localdomain systemd[1]: Started LSB: Bring up/down networking.
[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:5b:54:77 brd ff:ff:ff:ff:ff:ff
    inet 192.168.188.128/24 brd 192.168.188.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::6f70:1de8:27ec:ae87/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.188.128
NETMASK=255.255.255.0
GATEWAY=192.168.188.2
DNS1=8.8.8.8


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=ens33
UUID=85735bdf-f2ef-4fae-8100-4a3bd78bae0a
DEVICE=ens33
ONBOOT=yes
~
~
~
~
Type  :quit<Enter>  to exit Vim
[root@localhost ~]# systemctl restart network
[root@localhost ~]# systemctl status network
● network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
   Active: active (exited) since 日 2021-07-04 16:03:19 CST; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8819 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
  Process: 8998 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)

7月 04 16:03:19 localhost.localdomain systemd[1]: Stopped LSB: Bring up/down networking.
7月 04 16:03:19 localhost.localdomain systemd[1]: Starting LSB: Bring up/down networking...
7月 04 16:03:19 localhost.localdomain network[8998]: 正在打开环回接口: [  确定  ]
7月 04 16:03:19 localhost.localdomain network[8998]: 正在打开接口 ens33: 连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)
7月 04 16:03:19 localhost.localdomain network[8998]: [  确定  ]
7月 04 16:03:19 localhost.localdomain systemd[1]: Started LSB: Bring up/down networking.
[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:5b:54:77 brd ff:ff:ff:ff:ff:ff
    inet 192.168.188.128/24 brd 192.168.188.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::6f70:1de8:27ec:ae87/64 scope link noprefixroute 
       valid_lft forev

上一篇:MYSQL误删除DELETE数据找回


下一篇:墨天轮Oracle免费在线SQL测试平台