I have a CentOS server with twp NICs. One NIC is NAT and connected to the internet and another is for local network:
Code: Select all
# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe2e:5818 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:2e:58:18 txqueuelen 1000 (Ethernet)
RX packets 21664 bytes 12777139 (12.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10376 bytes 1034705 (1010.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::a00:27ff:fe08:ee20 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:08:ee:20 txqueuelen 1000 (Ethernet)
RX packets 3941 bytes 402106 (392.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 627 bytes 65331 (63.7 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<host>
loop txqueuelen 0 (Local Loopback)
RX packets 22 bytes 2408 (2.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 22 bytes 2408 (2.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Code: Select all
TYPE=Ethernet
BOOTPROTO=static
NETMASK=255.255.255.0
TYPE=Ethernet
HWADDR=08:00:27:08:ee:20
IPADDR=192.168.0.2
GATEWAY=192.168.0.2
NAME=enp0s8
DEVICE=enp0s8
ONBOOT=yes
Code: Select all
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.2;
option domain-name-servers 192.168.0.2;
option broadcast-address 192.168.0.255;
range 192.168.0.3 192.168.0.253;
DHCPDARGS="enp0s8";
}
Code: Select all
# nano /etc/sysctl.conf
net.ipv4.ip_forward = 1
Code: Select all
# iptables -A FORWARD -o enp0s3 -i enp0s8 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT
# iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# iptables -t nat -F POSTROUTING
# iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE
What is my problem?
Thank you.