In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to achieve a proxy server in Linux, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1. Install Linux, either graphically or stylistically. Choose the minimum installation. You can configure IP and DNS on the public network first (or not) during installation, and all other defaults
After installation, enter the prompt
two。 After entering the prompt, first configure the network card:
The path of eth0 (external network card) configuration file is: / etc/sysconfig/network-scripts/ifcfg-eth0
Use vi / etc/sysconfig/network-scripts/ifcfg-eth0 to modify the contents of eth0. If you install it, you don't need to match it. Just check to see if there is anything wrong.
The content of eth0 is as follows: (note that IP is hypothetical IP, # is comment not to be written)
DEVICE=eth0 # hardware device name
BOOTPROTO=static # configuration method
BROADCAST=218.28.9.255 # broadcast address
IPADDR=218.28.9.123 # is your IP address
NETMASK=255.255.255.0 # Subnet Mask
NETWORK=218.28.9.0 # address of the entire network segment
Whether to enable the network card in ONBOOT=yes # (generally, it is enabled by default)
Eth2 (intranet Nic), the configuration file path is: / etc/sysconfig/network-scripts/ifcfg-eth2
Modify the content of eth0 with vi / etc/sysconfig/network-scripts/ifcfg-eth2
The content of eth2 is:
DEVICE=eth2 # hardware device name
BOOTPROTO=static # configuration method
BROADCAST=192.168.0.255 # broadcast address
IPADDR=192.168.0.1 # is your IP address
NETMASK=255.255.255.0 # Subnet Mask
NETWORK=192.168.0.0 # address of the entire network segment
Whether to enable the network card in ONBOOT=yes # (generally, it is enabled by default)
After the network card is configured, you can use ifconfig life to check whether the network card is mismatched.
3. Now let's set the public network gateway and the DNS provided by ISP
The configuration file path of the gateway is / etc/sysconfig/network edited with vi if this is set up at the time of installation, it does not need to be changed.
The content is:
NETWORKING=yes # what does this mean? by default, yes does not need to be changed.
HOSTNAME=rslinux # your host name does not need to be changed
GATEWAY=218.28.9.120 # your public network gateway
Come down and add DNS. If you set it up during installation, you don't have to change it.
The path to the DNS configuration file is: / etc/resolv.conf edit with vi
The syntax is:
Nameserver 20.2102.224.68 (multiple entries can be added)
After all the above basic work is done, I can use the route command to check the road state. If it reads smoothly, it means no problem.
When I'm done, it's like this.
192.168.0.0 * 255.255.255.0 U 000 eth2
218.28.9.0 * 255.255.255.0 U 000 eth0
169.254.0.0 * 255.255.255.0 U 000 eth2
127.0.0.0 * 255.255.255.0 U 000 lo
Default hn.pds.kd.ADSL 255.255.255.0 U 0 0 0 eth0
3. Using IPTABLES to realize the NAT function of double network card, so as to realize the surfing of proxy server.
After the above work is done, we modify the sysctl.conf, that is, the IP forwarding file. We must use IP forwarding here.
The sysctl.conf path is / etc/sysctl.conf
It can be written like this:
Net.ipv4.ip_forward=1
Net.ipv4.conf.default.rp_filter=1
Kernel.sysrq=0
4. Finally edit the rc.local file
Vi / etc/rc.d/rc.local # edit the startup batch file and add the following lines at the end of the file
Iptables-F # clears the iptables table
Iptables-F-t nat # clears the iptables IP nat table
Iptables-t nat-A POSTROUTING-o eth0-s 192.168.0.0swap 24-j MASQUERADE # disguises the intranet ip as an extranet and even connects to the internet
Echo 1 > / proc/sys/net/ipv4/ip_forward # starts the ip transfer function.
At this point, the proxy server can be used after rebooting the machine.
If you don't want to load so many services, you can use the ntsysv command to remove the services, leaving only iptables services and networks services, and uncheck all other services.
The above is how to implement a proxy server in Linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.