环境说明
操作系统:CentOS 7.9 minal
节点 | IP | 说明 |
---|---|---|
DHCP-NAT | 192.168.100.100 | 对外服务,可访问互联网 |
10.0.0.2 | 内网ip,内网网卡 | |
内网服务器 | dhcp自动获取 | 内网网卡 |
DHCP服务器搭建
# 安装
yum install dhcp -y
# 配置/etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
subnet 10.0.0.0 netmask 255.255.255.0 { # 网段
range 10.0.0.10 10.0.0.254; # IP范围
option domain-name-servers 61.139.2.69,114.114.114.114; #DNS配置
#option domain-name "internal.example.org";
option routers 10.0.0.2; # 网关
option broadcast-address 10.0.0.255; # 广播地址
default-lease-time 600;
max-lease-time 7200;
}
# 启动dhcp服务
systemctl enable dhcpd --now
开启防火墙伪装
firewall-cmd --permanent --add-masquerade --zone=public
firewall-cmd --reload
firewall-cmd --list-all
测试验证
# 在dhcp服务器上测试访问互联网 访问内网
ping baidu.com
ping 10.0.0.x
# 在内网服务器上测试访问互联网 访问内网其他ip
ping baidu.com
ping 10.0.0.x
相关文章:
CentOS搭建NAT和DHCP服务,实现共享上网_筑梦之路的博客-CSDN博客_vsphere 创建dhcp
ubuntu dhcp iptables 实现共享上网——筑梦之路_筑梦之路的博客-CSDN博客_dhcp iptables