linux-网络管理

路由器的作用:用来NAT(地址解析)

网关:用于不同的网络互联

在Linux中配置IP地址的方法有以下这么几种:

  • ifconfig命令临时配置IP地址(临时配置IP地址,即当我们重启计算机或重启网络服务后,配置将失效)
  • setup工具永久配置IP地址
  • 修改网络配置文件

ifconfig命令

  ifconfig命令可以查看与配置网络状态,命令结果如下:

使用ifconfig命令还可以临时设置某一网卡的IP地址和子网掩码。如:

 

网关的常用命令

查看网关:route -n

将真机伪装成路由器

重置路由器:firewall-cmd --reload

 

masquerade:yes              标示地址伪装功能开启,真实主机成为路由器

如果是no,则执行命令如下:firewall-cmd --add-masquerade

测试:

显示可以上网

但这个时候只能ping 地址,要想ping 名称,还需配置/etc/sysconfig/network-scripts/下的文件

配置如下:

这时就能直接用地址来ping了,结果显示:

 

dhcp设置

yum install dhcp -y

[root@localhost network-scripts]# yum install dhcp -y
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel7.3                                                  | 4.1 kB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-47.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package       Arch            Version                   Repository        Size
================================================================================
Installing:
 dhcp          x86_64          12:4.2.5-47.el7           rhel7.3          511 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 511 k
Installed size: 1.4 M
Downloading packages:
dhcp-4.2.5-47.el7.x86_64.rpm                               | 511 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 12:dhcp-4.2.5-47.el7.x86_64                                  1/1 
rhel7.3/productid                                        | 1.6 kB     00:00     
  Verifying  : 12:dhcp-4.2.5-47.el7.x86_64                                  1/1 

Installed:
  dhcp.x86_64 12:4.2.5-47.el7                                                   

Complete!
[root@localhost network-scripts]# 

设置客户端网卡工作模式为dhcp

vim /etc/sysconfig/network-scripts/ifcfg-eth3下配置BOOTPROTO =dhcp

重启网络:systemctl  restart  network

配置成功

 

防火墙配置:

开启防火墙:systemctl  start  firewalld

查看防火墙命令:systemctl  status sys firewalld

关闭防火墙:systemctl  stop  firewalld

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值