You can share the internet by configuring the Cent OS server as a NAT machine and giving private ip addresses to the LAN machines. As in your case, the USB wireless interface is ppp0 and the LAN interface is eth0 on the Cent OS server.
Step-1: Providing private ip addresses to LAN interface on Cent OS and to the other machines in the LAN.
You can give any of the following private ip addresses.
- Class A (10.x.x.x )
- Class B (172.16.x.x to 172.31.x.x)
- Class C (192.168.x.x)
Suppose we select Class B private subnet 172.31.100.0/24 (netmask 255.255.255.0).
Assign 172.31.100.1 to eth0 of Cent OS machine statically. Similarly keep on assigning the private ip 172.31.100.2 , 172.31.100.3, and so on to the other machines in the subnet among whom you want to share the internet.
Check whether all the machines in the LAN are able to ping eth0 interface of Cent OS machine by using ping utility.
From all the machines try the following command:
$ ping 172.31.100.1
If ping reply is coming then configure the next step.
Step-2:
Now next step is to configure the Cent OS machine as Network Address Translator.
You can use iptables to configure the Cent OS machine as NAT machine.
NOTE: Do all the below configurations using root access.
By configuring the following rules you can configure the server as NAT machine:
Flush all the existing rules first:
$ iptables -F
Then give the following commands:
$ iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
$ iptables --append FORWARD --in-interface eth0 -j ACCEPT
You have to configure the Cent OS machine so that it can forward the packets. For this you have to give following command.
$ echo 1 > /proc/sys/net/ipv4/ip_forward
Now every machine in your subnet should be able to access the internet.