To set up Internet connection sharing on a CentOS or Red Hat Linux system, you can use the iptables
command to configure Network Address Translation (NAT). NAT allows multiple devices on a private network to share a single public IP address and access the Internet.
To set up NAT, you will need to configure the network interface that connects to the Internet (also known as the "outside" interface) and the network interface that connects to the private network (also known as the "inside" interface).
Here are the steps to set up NAT on a CentOS or Red Hat Linux system:
ip
command to list the available interfaces on your system:ip link show
/etc/sysctl.conf
file:net.ipv4.ip_forward = 1
sysctl -p
iptables
command. Replace eth0
with the name of the outside interface and eth1
with the name of the inside interface:iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables
rules so they will be applied on boot:service iptables save
This will set up NAT on your system and allow devices on the private network to access the Internet.