网络配置,IP路由转发,端口查看,ACL权限设置

网络配置相关的文件:                                                                                       
[[email protected] ~]# vim /etc/udev/rules.d/70-persistent-net.rules //克隆出来的虚拟机                      
没有eth0网卡的问题                                                                                      
临时改主机名                                                                                           
[[email protected] ~]# vim /etc/host                                                                   
永久改名                                                                                             
[[email protected] ~]# vim /etc/sysconfig/network                                                      
                                                                                                 
                                                                                                 
/etc/sysconfig/network-scripts/ifcfg-ethX 网卡的局部配置文件                                              
/etc/sysconfig/network 网络的全局配置文件                                                                 
/etc/resolv.conf 域名解析文件(指定dns服务器)                                                                
/etc/hosts 本地域名解析                                                                                
                                                                                                 
配置静态IP地址:                                                                                        
1、图形化工具配置                                                                                        
setup                                                                                            
2、修改配置文件                                                                                         
vim /etc/sysconfig/network-scripts/ifcfg-eth0:1                                                  
                                                                                                 
DEVICE=eth0:1  设备名                                                                               
TYPE=Ethernet  网卡类型                                                                              
HWADDR=40:8d:5c:bb:cc:ff mac地址                                                                   
NM_CONTROLLED=yes 受NetworkManager服务影响;no不影响                                                      
UUID="e4678090-b16d-4225-aa1c-1d91a1329c86"                                                      
ONBOOT=yes 是否激活网卡,yes代表激活;no代表不激活                                                                
BOOTPROTO=none  获取ip地址的方式;dhcp代表动态获取;none和static代表静态ip                                           
IPADDR=10.1.1.11 IP地址                                                                            
NETMASK=255.255.255.0 子网掩码                                                                       
GATEWAY=192.168.0.254 网关                                                                         
DNS1=192.168.0.254 dns服务器                                                                        
IPV6INIT=no 不支持ipv6                                                                              
USERCTL=no  不支持普通用户启动网络                                                                          
3、重启服务                                                                                           
# service network restart                                                                        
                                                                                                 
主机名设定                                                                                            
 FQDN(完全符合规范的主机名)                                                                                
 node1.uplook.com ——>node1(主机头).uplook.com(域)                                                    
 stuxx.example.com                                                                               
 webserver node1 不规范                                                                             
查看主机名:                                                                                           
hostname                                                                                         
uname -n                                                                                         
临时更改主机名:                                                                                         
hostname webdb.uplook.com 退出重新登录,操作系统重启失效                                                        
永久更改主机名:                                                                                         
vim /etc/sysconfig/network                                                                       
                                                                                                 
NETWORKING=yes yes代表网络生效;no代表使用service network restart启动网络无效                                     
HOSTNAME=node1.uplook.com 修改后必须重启操作系统才能生效                                                        
GATEWAY=192.168.0.254 默认网关                                                                       
注意:当该文件和子接口文件里的网关冲突时,以子接口里的网关为准                                                                  
                                                                                                 
hostname stu33.example.com                                                                       
vim /etc/sysconfig/network                                                                       
...                                                                                              
HOSTNAME=stu33.example.com                                                                       
                                                                                                 
域名或主机名的解析:                                                                                       
                                                                                                 
vim /etc/resolv.conf                                                                             
nameserver 192.168.0.254 dns服务器的ip地址                                                             
                                                                                                 
vim /etc/hosts                                                                                   
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4                   
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6                   
以上两行不要修改也不要删除                                                                                    
                                                                                                 
IP选路:                                                                                            
route -n 打印路由表                                                                                   
route del default 删除默认路由                                                                         
route add default gw 192.168.0.254 dev eth0 添加默认网关                                               
route add -net 172.16.0.0 netmask 255.255.0.0 dev eth0 添加一条到目标网络的路由                              
route add -host 10.1.1.110 gw 192.168.0.1 dev eth0 添加一条到目标主机的路由                                  
route del -net 10.1.1.0 netmask 255.255.255.0                                                    
                                                                                                 
实验目的:实现不同网络之间的互通                                                                                 
A:192.168.0.1 开启路由转发的功能                                                                          
B:10.1.1.10                                                                                      
C:172.16.5.1                                                                                     
B主机能ping通C主机                                                                                     
                                                                                                 
步骤:                                                                                              
A主机:                                                                                             
1、开启路由转发功能                                                                                       
# cat /proc/sys/net/ipv4/ip_forward                                                              
0 代表关闭;1代表开启                                                                                     
# echo 1 > /proc/sys/net/ipv4/ip_forward                                                         
# cat /proc/sys/net/ipv4/ip_forward                                                              
1                                                                                                
2、增加到B主机和C主机的网络                                                                                  
                                                                                                 
# route add -net 10.1.1.0 netmask 255.255.255.0 dev eth0                                         
# route add -net 172.16.5.0 netmask 255.255.255.0 dev eth0                                       
# route -n                                                                                       
Kernel IP routing table                                                                          
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface                    
0.0.0.0         192.168.0.254   255.255.255.0   UG    0      0        0 eth0                     
172.16.5.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0                     
192.168.1.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0                     
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0                     
10.1.1.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0                     
                                                                                                 
B主机:                                                                                             
添加默认网关为A主机                                                                                       
# route add -net 192.168.0.0/24 dev eth0                                                         
# route add default gw 192.168.0.1                                                               
                                                                                                 
C主机:                                                                                             
添加默认网关为A主机                                                                                       
# route add -net 192.168.0.0/24 dev eth0                                                         
# route add default gw 192.168.0.1                                                               
                                                                                                 
lsof -i :80   查看端口                                                                             
dos2unix 将windows文件转换成unix文件可以去掉^M                                                              
                                                                                                 
写脚本时想让屏幕上显示启动和关闭                                                                                 
可以调用/bin/true,/bin/false                                                                         
                                                                                                 
清空日志可以使用重定向                                                                                      
> /tmp/tmp.log                                                                                   
                                                                                                 
seq 5                                                                                            
seq 5 10                                                                                         
seq 2 2 10                                                                                       
seq 1 3 10                                                                                       
                                                                                                 
seq -s " " 2 10                                                                                  
seq -s "+" 10                                                                                    
seq -s "+" 100|bc                                                                                
seq -w 2 11                                                                                      
                                                                                                 
查看网站的服务类型                                                                                        
curl -I -s baidu.com                                                                             
curl -I -s --connect-timeout 10 163.com                                                          
                                                                                                 
                                                                                                 
cut -c 1-8  //截取1-8个字符                                                                           
chkconfig --list   ,查看服务开启/关闭状态                                                                  
                                                                                                 
查找文件or字符串                                                                                        
find path -name/type file                                                                        
find path -name/type "*.log"|xargs grep "string"                                                 
                                                                                                 
查看inode节点,每隔文件占用一个节点                                                                             
df -li                                                                                           
                                                                                                 
tail -f //可以跟踪文件末尾的变化                                                                            
                                                                                                 
at 定时命令                                                                                          
定时文件:crontab,                                                                                    
定时服务:crond                                                                                       
                                                                                                 
rpm -aq|grep filename   查看包是否安装                                                                  
                                                                                                 
ssh -p22 [email protected] /sbin/ifconfig eth1 or eth0                                          
ssh 192.168.1.9                                                                                  
                                                                                                 
查看进程,端口的方法                                                                                       
netstat -lnp|grep 端口号(或者服务名)                                                                     
ps -ef|grep 端口号(或者服务名)                                                                           
lsof -i tcp  查看tcp                                                                               
lsof -i tcp:80                                                                                   
lsof -i :80  反查                                                                                  
                                                                                                 
                                                                                                 
rz 是一款很好用的linux虚拟机上传下载工具                                                                         
[[email protected] ~]# yum install lrzsz -y                                                          
[[email protected] ~]# rz                                                                            
                                                                                                 
-----------------------------------------------------------                                      
账户权限设置:                                                                                          
ACL访问控制权限,                                                                                       
由于系统的基本权限是针对文档所有者或其他账户进行控制的,无法针对其某个单独的账户进行控制,                                                    
所以就有了ACL访问控制列表的概念,使用ACL,我们可以针对单一账户设置文档的访问权限。                                                     
                                                                                                 
                                                                                                 
使用getfacl查看文档的ACL权限,使用setfacl来设置文档的ACL权限。                                                        
                                                                                                 
[[email protected] ~]# getfacl install.log                                                             
# file: install.log                                                                              
# owner: root                                                                                    
# group: root                                                                                    
user::rw-                                                                                        
group::r--                                                                                       
mask::r--                                                                                        
other::r--                                                                                       
                                                                                                 
setfacl 设置文档访问控制列表                                                                               
-b  删除所有附加的ACL条目                                                                                 
-k 删除默认的ACL                                                                                      
-m 添加ACL条目                                                                                       
-x 删除制定的ACL条目                                                                                    
-R 递归处理所有的子文件与子目录                                                                                
                                                                                                 
[[email protected] ~]# setfacl -b install.log                                                          
[[email protected] ~]# setfacl -m u:oldboy:rw install.log                                              
[[email protected] ~]# setfacl -m g:oldboy:r install.log                                               
[[email protected] ~]# setfacl -x u:oldboy: install.log

时间: 2024-10-11 15:31:10

网络配置,IP路由转发,端口查看,ACL权限设置的相关文章

centos 7的firewalld防火墙配置IP伪装和端口转发(内附配置案例)

IP地址伪装和端口转发都属于NAT(网络地址转换). 地址伪装和端口转发的区别如下: IP地址伪装:通过地址伪装,NAT设备将经过设备的包转发到指定的接收方,同时将通过的数据包源地址更改为其NAT设备自己的接口地址.当返回的数据包到达时,会将目的地址修改为原始主机的地址并做路由.地址伪装可以实现局域网多个地址共享单一公网地址上网.类似于NAT技术中的端口多路复用(PAT).IP地址伪装仅支持ipv4,不支持ipv6. 端口转发:也可以称之为目的地址转换或端口映射.通过端口转发,将指定IP地址及端

ACL权限设置(转载)

一. 为什么要使用ACL先让我们来简单地复习一下Linux的文件权限. 在 linux下,对一个文件(或者资源)可以进行操作的对象被分为三类: file owner(文件 的拥有者),group(组,注意不一定是文件拥有者所在的组), other (其他)而对于每一类 别又分别定义了read, write and execute/search 权限 (这里不讨论SUID, SGID以及 Sticky bit的设置) 通过ls -l命令就我们就可以列出一个文件的权限 代码: [[email pro

ACL权限设置

有时候一个文件的拥有者,所属组,其他人三种角色对文件的权限并不能完全满足.适合某一个用户所需要对文件的操作权限,这时就需要对特殊的用户单独设置权限,下面举例说明查看home目录中vampire目录的访问权限 1 [[email protected] home]# getfacl vampire 2 # file: vampire 3 # owner: vampire 4 # group: vampire 5 user::rwx 6 group::--- 7 other::--- 可以看到只有用户

ACL权限设置命令setfacl

setfacl setfacl Linux命令--setfacl 命令名 setfacl- 设置文件访问控制列表 setfacl,顾名思义就是设置文件的ACL规则. 而Acl(Access Control List)就是访问控制列表,最初好像是unix里面为了提供更高级的权限管理而搞出来的. 可能是被chmod命令的3个权限控制无法满足,而被迫搞出来的吧! ACL的设置技巧 getfacl:取得某个文件/目录的ACL设置项目 setfacl:设置某个目录/文件的ACL规定 [[email pro

Linux系统管理-(12)-网络配置IP命令

ip命令:         ip [ OPTIONS ] OBJECT { COMMAND | help }        object: link addr route    link :              show [dev name|up] 显示link信息 指定接口 已启动接口                  ip link show                    ip link show dev eth0                    ip link show

鸟哥的Linux私房菜7-------14章 Linux帐号管理与ACL权限设置

1. 用户表示符UID与GID /etc/passwd文件结构: 有几行就代表有几个帐号在你的系统里 每一行用:分割,一共7个字段. 1.帐号名称 2.密码:早起unix用,现在把密码数据放在/etc/shadow文件中了,这里用x表示 3.UID:0代表系统管理员. 1-499:系统帐号 500-65535:一般用户用 4.GID:     /etc/group有关 5.用户信息说明,使用finger时,这个字段能提供很多信息. 6.主文件夹 7.Shell:用户登录系统后取得的一个shell

Linux账号管理与ACL权限设置

一.Linux用户与用户组 1.Linux用户账号位于 /etc/passwd 密码位于 /etc/shadow 用户组账号位于 /etc/group 密码位于 /etc/gshadow 2.groups:查看有效用户组和支持用户组 直接输入命令groups 第一个输出的用户组即为有效用户组 3.newgrp:有效用户组的切换 newgrp 用户组 二.账号管理(系统管理员) 1.useradd:新增账号 user [-u UID] [-g 初始用户组] [-G 次要用户组] [-mM] [-c

第14章 Linux账号管理与ACL权限设置

Linux的账号与用户组 用户标识符:UID与GID 每一个文件都有一个所有者ID和用户组ID,当我们需要查看文件属性时,系统会根据/etc/passwd和/etc/group的内容,找到对应UID和GID对应的账户名和组名. 用户账号 用户的登陆流程如下: 1. 先搜索/etc/passwd里面是否有你输入的账号,如果有则将用户名对应的UID和GID(GID在/etc/group内)读取出来 2. 进入/etc/shadow找到对应账户与UID,核对密码是否正确 /etc/passwd文件结构

linux网络配置命令 ifconfig 、route 、ip 、ip route

ifconfig route ip ip route 一.ifconfig 命令(查看或配置Ip) 1.查看网络连接 # ifconfig  \\ 显示所有活动连接,不包令禁用的设备 或  # ifconfig -a  \\ 显示所有活动及非活动的连接 显示指定接口的连接 # ifconfig eth1 2.配置ip地址 # ifconfig eth1 192.168.0.1 netmask 255.255.255. 或 # ifconfig eth1 192.168.0.1/24 3.启用或禁