Results 1 to 1 of 1
I have few computer labs to manage, so I setup a DHCP server using Linux Fedora Core 3. The DHCP service working after I configured the setting. I configure the ...
- 05-26-2005 #1Just Joined!
- Join Date
- May 2005
- Posts
- 1
IPtables script problem
I have few computer labs to manage, so I setup a DHCP server using Linux Fedora Core 3. The DHCP service working after I configured the setting. I configure the network in one network card with:
Eth0
IP : 10.1.1.1
Netmask : 255.0.0.0
Gateway : 192.168.2.2
Eth0:0
IP : 192.168.2.100
Netmask : 255.255.255.0
All the labs will get the 10.0.1.1 and so on. For lab 1 will get 10.0.1.1 to 10.0.1.20. Lab 2 will get 10.0.2.1 to 10.0.2.20. Lab 3 will get 10.0.3.1 to 10.0.3.20 and so on. All the labs PC can get the IP that assigned by DHCP Server but all cannot connect to internet. So I used ping command at DHCP Server and it was showing response from internet.
My friends said had to write the script to command it to route the line. So I search internet and I found some routing script and put on it and run the script, here the script:
“
echo "1" > /proc/sys/net/ipv4/ip_forward
IFCONFIG="/sbin/ifconfig"
EXTIF="eth0"
EXTIP="`$IFCONFIG $EXTIF | awk /$EXTIF/'{next}//{split ($0,a,":");split (a[2],a," ");print a[1];exit}'`"
echo $EXTIP
iptables -F
iptables -X
iptables -A FORWARD -i eth0 -o $EXTIF -j ACCEPT
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -P FORWARD ACCEPT
“
After I run this script, all the labs can connect to internet. That was good.
Now I want to manage the lab’s internet connection. I don’t want to enable the internet connection to all the labs. Example I got 1 to 5 labs, I only want to enable Lab 1 and Lab3 internet services and other are disable. How should write the script to control it?


Reply With Quote