Centos操作系统(一)-网络配置

Centos操作系统

一、网络配置

1、 网络查看:

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.5.129  netmask 255.255.255.0  broadcast 192.168.5.255
        inet6 fe80::c3e7:caf9:e41a:3c79  prefixlen 64  scopeid 0x20
        ether 00:0c:29:56:19:70  txqueuelen 1000  (Ethernet)
        RX packets 10530  bytes 15059160 (14.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4771  bytes 300971 (293.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1  (Local Loopback)
        RX packets 4  bytes 344 (344.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 344 (344.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2、 修改网络配置

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=957da0b9-6b4f-466a-93dd-eceac8a4b57a
DEVICE=ens33
ONBOOT=yes   #开启自动启用网络连接

3、. 重启网络

[root@localhost ~]# service network restart
Restarting network (via systemctl):                        [  确定  ]

二、安装ssh服务

1、安装ssh

[root@localhost ~]#  yum install openssh-server -y

2、启动ssh

[root@localhost ~]# service sshd start

3、查看ssh

[root@localhost ~]# netstat -an|grep 22

三、防火墙

1、firewalld的基本使用

启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld 
开机禁用  : systemctl disable firewalld
开机启用  : systemctl enable firewalld

2、配置firewalld-cmd

查看版本: firewall-cmd --version
[root@localhost ~]# firewall-cmd --version
0.4.3.2
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息:  firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic

3、开启一个端口

添加
firewall-cmd --zone=public --add-port=80/tcp --permanent    --permanent永久生效,没有此参数重启后失效)
[root@localhost ~]# firewall-cmd --zone=public --add-port=6379/tcp --permanent
success

重新载入
firewall-cmd --reload
[root@localhost ~]# firewall-cmd --reload
success

查看
firewall-cmd --zone= public --query-port=80/tcp
删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent

你可能感兴趣的:(Linux)