Configure your computer as a router under the Linux system

Source: Internet
Author: User


Configure your computer as a router (wired) under 1.ubantu

Prepare two computers PCA:PCA configured as routers, Ubantu system

PCB:PCB as a terminal, Win7 system

(1). Configure two net card information: eth0 (wired Ethernet card) and Wlan0 (wireless card): $/etc/network/interface Edit the following information

Auto Lo

Iface Lo inet Loopback

Auto Wlan0

Iface wlan0 inet Static

Address 192.168.1.102

Gateway 192.168.1.1

Netmask 255.255.0.0

Auto Eth0

Iface eth0 inet Static

Address 192.168.6.1

Netmask 255.255.255.0

Network 192.168.6.0

Broadcast 192.168.6.255


(2). Execute IPv4 forward script router.sh

#!/bin/sh

Echo 1 >/proc/sys/net/ipv4/ip_forward
Cat/proc/sys/net/ipv4/ip_forward
Ifconfig eth0 192.168.6.1 up
Iptables-t nat-f
iptables-t nat-a postrouting-s 192.168.6.0/24-o wlan0-j Masquerade

(3). If PCA is unable to surf the internet at this time, see if you are configuring a default gateway: $ route-n

If you do not have a default gateway, add a default gateway: Route Add-default GW 192.168.1.1


(4). Use a network cable to connect the PCA and PCB, disable the wireless PCB, ready to test whether the PCB through the PCA Internet

Manually modify the IP address of the PCB: 192.168.6.10

Gateway: 192.168.6.1

Subnet Mask: 255.255.255.0

dns:8.8.8.8 (if the above configured PCB still can not surf the internet, may be a DNS resolution problem )

(5). Building a DHCP server on PCA

In step (4), we always need to manually configure the IP for the PCB, it is more troublesome, we can get it automatically by DHCP to obtain the IP, the method is as follows:

Install DHCP server: $sudo apt-get install Isc-dhcp-common isc-dhcp-server

(i) Modify/etc/default/isc-dhcp-Server

interfaces= "eth0"

(ii) Modification of/etc/dhcp/dhcpd.conf

Subnet 192.168.6.0 netmask 255.255.255.0 {

Range 192.168.6.100 192.168.6.200;

option routers 192.168.6.1;

option broadcast-address 192.168.6.255;

Default-lease-time 600;

max-lease-time 7200;

  }

Reference Blog: http://www.blogjava.net/canvas/articles/router-dhcp.html


2.ubantu Configure the computer as a router (wireless hotspot mode) to be updated ...


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Configure your computer as a router under the Linux system

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.