Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up shared Internet access in Linux

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to set up Linux to share the Internet". In the operation of practical cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Environment: a Linux machine single network card, a window machine single network card, a four-port hub. Background: the landlord provided only one Internet connection and limited access to the Internet with only one network card (that is, the network card of my Linux machine). Objective: to bring window machines into the network through Linux shared Internet settings. Methods: use Linux machine to make a DHCP server, and use hub to make a local area network. Then forward the IP request for this segment.

Set up a Linux DHCP server. If it is a Ubuntu system, directly

# apt-get install dhcpd

Change the / etc/dhcpd.conf file after installation and add:

Option domain-name-servers 202.96.134.188202.96.134.133 ETS defaultMutual netmask time 600 maxim Musical time 7200 subnet 192.168.1.0 netmask 255.255.255.0 {range 192.168.1.2 192.168.1.200 option routers 192.168.20.1;}

DHCP is set up. Next, you need to set up one more IP for the Linux host and set the IPtable rules.

Sudo ifconfig eth0:1 192.168.20.1sudo sh-c "echo 1 > / proc/sys/net/ipv4/ip_forward" sudo iptables-A FORWARD-s 192.168.20.0 take 24-j ACCEPTsudo iptables-A FORWARD-I eth0-m state-state ESTABLISHED,RELATED-j ACCEPT

You can write the above statement to a script. If you need to execute it, you can turn on the sharing function.

The window machine only needs to be set to automatically obtain the IP (or set to 192.168.20.x network segment, the gateway is 192.168.20.1). The physical connection is through the hub.

The situation of each person is different, and everyone should modify it according to his own situation.

This is the end of the content of "how to set up Linux to share the Internet". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report