A single Nic redhat7.2linux uses iptables as a simple gateway configuration
Source: Internet
Author: User
Article title: use iptables in a single Nic redhat7.2linux as a simple gateway configuration. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Author: ken
Because the default kernel modules is not installed
The ipchains: Protocol not available error occurs during use. do not think that 7.2 is regressing.
More powerful iptables has been used to build a firewall.
Environment: The intranet is 192.168.2.0, and the Internet DDN is 10.19.78.0. The Internet gateway is 10.19.78.1.
The intranet IP address of the configured gateway server is 192.168.2.170, the Internet IP address is 10.19.78.5, and the two addresses are bound to one
Block Nic (dual Nic is better ).
(2) create a file ifcfg-eth1 under the/etc/sysconfig/network-scripts directory
DEVICE = eth1
USERCTL = no
ONBOOT = yes
BOOTPROTO =
BROADCAST = 10.19.78.7
NETWORK = 10.19.78.0
NETMASK = 255.255.255.255.248
IPADDR = 10.19.78.5 # ip address of the local machine in the upper-level network
(3) use/ect/rc. d/init. d/inet restart to make the IP configuration take effect.
(4) use iptables to write the following script gw. sh:
Iptables-a forward-I eth1-m state -- state ESTABLISHED, RELATED-j ACCEPT
Iptables-t nat-a postrouting-o eth1-s 192.168.2.0/24-j SNAT -- to 10.19.78.5
# End
Change gw. sh to an executable permission to run. other machines can access the internet using the gateway! You can also add
/Ect/rc. d/rc. local is used to run automatically upon startup.
This is the simplest function of using iptables. to build a powerful firewall, you can view it on your own.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.