/etc/hosts – a list of IP addresses and their assigned names.
/etc/resolv.conf – specifies DNS servers (e.g., nameserver 192.168.1.1)
/proc/sys/net/ipv4/ip_forward – enables routing between interfaces. Enable it by writing "1" to this file:
#echo '1' > /proc/sys/net/ipv4/ip_forward
Enable packet forwarding. To do this, edit /etc/sysctl.conf. Add the following line:
net.ipv4.ip_forward=1
Run the command:
sysctl -w net.ipv4.ip_forward="1"
/etc/sysconfig/network-scripts/ifcfg-* – describes network interface settings:
1) Example of an interface configured using DHCP:
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR= 00-19-DB-AD-19-99
ONBOOT=yes
2) Example of an interface configured with manually specified parameters:
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR= 00-19-DB-AD-19-99
IPADDR=192.168.1.2
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
GATEWAY=192.168.1.1
ONBOOT=yes
Restart all interfaces:
# service network restart or /etc/init.d/network restart
Check interface configuration:
#ifconfig or ip a
Restart interfaces individually:
#ifdown eth0 – disable
#ifup eth0 – enable
Static route for an interface (persists after OS reboot):
vim /etc/sysconfig/network-scripts/route-eth0
192.168.0.0/16 via 192.168.1.1
Static route for an interface (does not persist after OS reboot):
#route add -net 192.168.0.0/16 gw 192.168.1.1
View routing information:
#netstat -r
############################## IPTABLES script
yum install dnsmasq
# Example iptables configuration script
#
# Flush all current rules from iptables
#
iptables -F
#
# Allow SSH connections on TCP port 22
# This is essential when working on remote servers via SSH to prevent locking yourself out of the system
#
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#
# Set default policies for INPUT, FORWARD, and OUTPUT chains
#
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
#
# Set access for localhost
#
iptables -A INPUT -i lo -j ACCEPT
#
# Accept packets belonging to established and related connections
#
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#
# Save settings
#
/sbin/service iptables save
########################## iptables for internet sharing
Article taken from the website
