Using Linux iptables or ipchains to set up an internet gateway / firewall / router for home or office
Methods of connecting your private network to the internet:
| Block | Range | CIDR Notation | Default Subnet Mask | Number of hosts | |
|---|---|---|---|---|---|
| 24 bit block in class A | 10.0.0.0 | 10.255.255.255 | 10.0.0.0 /8 | 255.0.0.0 | 16,777,216 |
| 20 bit block in class B | 172.16.0.0 | 172.31.255.255 | 172 .16.0.0/12 | 255.240.0.0 | 1,048,576 |
| 16 bit block in class C | 192.168.0.0 | 192.168.255.255 | 1 92.168.0.0/16 | 255.255.0.0 | 65,536 |
| Range | CIDR Notation | Default Subnet Mask | Number of hosts | |
|---|---|---|---|---|
| 10.2.3.0 | 10.2.4.255 | 10.2.3.0/23 | 255.255.254.0 | 512 |
| 172.16.0.0 | 172.17.255.255 | 172.16.0.0/15 | 255.254.0.0 | 132608 |
| 192.168.5.128 | 192.168.5.255 | 192.168.5.128/25 | 255.255.255.128 | 128 |
| Firewall Command | Linux Kernel Version | Red Hat Version |
|---|---|---|
| firewall-cmd | 3.6.10+ | RHEL 7, CentOS7,Fedora 18+ |
| iptables | 2.4.x, 2.6.x, + | 7.1 - 9.0, RHEL 5/6, CentOS 5/6, Fedora 1-17 |
| ipchains | 2.2.x | 6.x, 7.0 |
| ipfwadm | 2.0.x | 5.x |
| Sequence | Command | Description |
|---|---|---|
| 1 | 'gchkconfig --del ipchains | Remove ipchains from system boot/initialization process |
| 2 | 'gchkconfig --add iptables | Add iptables to system boot/initialization process |
| 3 | 'gipchains -F | Flush ipchains rules |
| 4 | 'gservice ipchains stop | Stop ipchains. Also: /etc/init.d/ipchains stop |
| 5 | 'grmmod ipchains | Unload ipchains kernel module. Iptables kernel module can not be loaded if the ipchains module is loaded |
| 6 | 'gservice iptables start | Load iptables kernel module. Also: /etc/init.d/iptables stop |