一,修改网卡
1.配置内网
# 内网IP 配置
IPADDR2=192.168.0.1
PREFIX2=20
2.完整配置参考
TYPE=Ethernet
BOOTPROTO=none
NAME=phy-ext
DEVICE=phy-ext
DEVICETYPE=ovs
ONBOOT=yes
# IPv4 配置
IPADDR=xxx
PREFIX=29
GATEWAY=xxx
DNS1=8.8.8.8
DNS2=8.8.4.4
# 内网IP 配置
IPADDR2=192.168.0.1
PREFIX2=20
# IPv6 配置
IPV6INIT=yes
IPV6ADDR=xxx::2/64
IPV6_AUTOCONF=no
IPV6_DEFAULTGW=xxxx::1
DNS1=2606:4700:4700::1111
DNS2=2606:4700:4700::1001
DEVICETYPE=ovs
TYPE=OVSIntPort
二,设置nat
1.持久化iptables
dnf install iptables-services -y
systemctl enable iptables
systemctl start iptables
注:需要关闭firewalld。
2.设置内网NAt转发
iptables -t nat -A POSTROUTING -s 192.168.0.0/20 -o phy-ext -j MASQUERADE
重启持久化脚本
[root@localhost ~]# cat /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
/usr/bin/php /usr/local/zjmf/php/boot_all_host.php
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -s 192.168.0.0/20 -o phy-ext -j MASQUERADE
基本就完成了,虚拟机走内网可以使用ipv4出站,再单独分配一个ipv6公网。
评论0
暂时没有评论