Ubuntu 11.04 DHCP server and IPv6 memo

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_71d9aee401012bq9.html

 

Two laptops A and B

 

A: Ubuntu 11.04 + wired network adapter (eth0) + wireless network adapter (eth1)

B: Windows 7 + wired network card + wireless network card

Wireless network cards of A and B are connected to the home wireless router. The Gateway is 192.168.0.1 and can be connected to the Internet. A and B are connected directly through the network cable. A acts as the DHCP server and gateway and assigns an IP address to B's wired network card.

 

Step A to install DHCP server:

1. sudo apt-Get install dhcp3-server

2. VI/etc/default/ISC-DHCP-Server

Interfaces = "eth0"

3. Configure IPv4 static address for eth0: 192.168.1.1.

Do not use network connection to configure a static IP address. It does not write the/etc/Network/interfaces file, causing the DHCP server to fail to start automatically.

To enable the DHCP server to automatically start upon startup, add VI/etc/Network/interfaces:

Auto eth0 iface eth0 Inet static address 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255

 

4. VI/etc/DHCP/DHCPD. conf

Subnet 192.168.1.0 netmask 255.255.255.0 {range 192.168.1.10 192.168.1.200; Option broadcast-address 192.168.1.255; Option routers 192.168.1.1; default-lease-time 6000; max-lease-time 8000000 ;}

 

5. sudo/etc/init. d/ISC-DHCP-Server start

If an error occurs, view the/var/log/syslog error message.

 

After a is installed on the DHCP server, B's wired network adapter can be assigned to an IP address. But B cannot access the Internet.

Route print

0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.99 26

0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.10 10

When connected to the Internet, the IP address is routed to 192.168.1.1 with a small number of hops, resulting in a failure to access the Internet.

 

Run the following command to solve the problem:

Route Delete 0.0.0.0

Route add 0.0.0.0 mask 0.0.0.0 192.168.0.1

Route add 192.168.1.0 mask 255.255.255.0 192.168.1.1

 

Experiment 2: B disables the wireless network card and wants to connect to the Internet through a as a router

 

1. Add the DNS server to the configuration file of the DHCP server. In this way, B can use a to know the DNS server address.

VI/etc/DHCP/DHCPD. conf

Subnet 192.168.1.0 netmask 255.255.255.0 {range 192.168.1.10 192.168.1.200; Option broadcast-address 192.168.1.255; Option routers 192.168.1.1;

Option domain-name-servers 180.168.20.18; default-lease-time 6000; max-lease-time 8000000 ;}

 

2.

In a, enable the IP packet forwarding function, VI/etc/sysctl. conf, and delete the comment of the following line.

Net. ipv4.ip _ forward = 1

(SUDO sysctl-P enables the changed configuration to take effect immediately)

Add iptables at the same time (Temporary method, which will expire after restart ):

 

Sudo iptables-T Nat-A postrouting-s 192.168.1.0/24-O eth1-J Masquerade

Sudo iptables-save permanently saved

(-O eth1 specifies the output network interface as eth1)

Experiment 3: A uses radvd (Router Advertisement Daemon) to assign IPv6 addresses to B.

 

Radvd uses Neighbor Discovery Protocol (NDP) as specified in RFC 2461

 

1. sudo apt-Get install radvd

2. VI/etc/radvd. conf (this file needs to be created), as shown in the following lines:

Interface eth0 {minrtradvinterval 3; maxrtradvinterval 10; advlinkmtu 1280; region on; prefix fec0: 1111: 2222:/64 {advonlink on; region on; advvalidlifetime 3333; Limit 86400; advrouteraddr on ;};};

 

3. Open net. ipv6.conf. All. Forwarding = 1 in/etc/sysctl. conf.

 

4. sudo/etc/init. d/radvd start

(If the server is restarted when radvd is running, radvd automatically runs after it is started)

 

5. Run ipconfig on B:

Local Ethernet Adapter connection:

Connection to a specific DNS suffix .......: IPv6 address of the local site .......: fec0: 1111: 2222: 3333: a432: 4f4d: 72bf: ed0a % 1

Local IPv6 address ........: fe80: a432: 4f4d: 72bf: ed0a IPv4 address ............: 192.168.1.10 subnet mask ............: 255.255.255.0 Default Gateway .............: fe80: 211: 43ff: fe76: cb8

 

Note: In Windows, % 1 in fec0: 1111: 2222: 3333: a432: 4f4d: 72bf: ed0a % 1 indicates the network interface number.

 

Ping local address:

C: \> Ping fec0: 1111: 2222: 3333: a432: 4f4d: 72bf: ed0a (local site address)

Ping fec0: 1111: 2222: 3333: a432: 4f4d: 72bf: ed0a data with 32 bytes: From fec0: 1111: 2222: 3333: a432: 4f4d: 72bf: ed0a reply: time <1 ms

 

C: \> Ping fe80: a432: 4f4d: 72bf: ed0a (local link address)

Pinging fe80: a432: 4f4d: 72bf: ed0a data with 32 bytes: response from fe80: a432: 4f4d: 72bf: ed0a: time <1 ms

 

6. Run ifconfig on.

$ Ifconfig

Eth0 link encap: Ethernet hwaddr 00: 11: 43: 76: 0C: B8 Inet ADDR: 192.168.1.1 bcast: 192.168.1.255 mask: 255.255.0 inet6 ADDR: fe80: 211: 43ff: fe76: cb8/64 scope: link up broadcast running Multicast MTU: 1500 Metric: 1 RX packets: 4634 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 1299 errors: 0 dropped: 0 overruns: 0 carrier: 0 Collisions: 0 txqueuelen: 1000 RX Bytes: 677921 (677.9 KB) TX Bytes: 178937 (178.9 KB) interrupt: 18

Ping the local address (note the usage of ping6 on Linux, you must specify the interface ):

$ Ping6-I eth0 fe80: 211: 43ff: fe76: cb8

Ping fe80: 211: 43ff: fe76: cb8 (fe80: 211: 43ff: fe76: cb8) from fe80: 211: 43ff: fe76: cb8 eth0: 56 data bytes 64 bytes from fe80: 211: 43ff: fe76: cb8: icmp_seq = 1 TTL = 64 time = 0.046 MS

7. B ping

C: \> Ping fe80: 211: 43ff: fe76: cb8

Pinging fe80: 211: 43ff: fe76: cb8 with 32 bytes of data: From fe80: 211: 43ff: fe76: cb8 reply: time <1 ms

 

8. A Ping B

$ Ping6-I eth0 fe80: a432: 4f4d: 72bf: ed0a Ping fe80: a432: 4f4d: 72bf: ed0a (fe80: a432: 4f4d: 72bf: ed0a) from fe80: 211: 43ff: fe76: cb8 eth0: 56 data bytes 64 bytes from fe80: a432: 4f4d: 72bf: ed0a: icmp_seq = 1 TTL = 64 time = 0.733 MS

G $ ping6-I eth0 fec0: 1111: 2222: 3333: a432: 4f4d: 72bf: ed0a CONNECT: network is unreachable

A can only ping the local link address of B, but cannot ping the local site address. Because data packets using the local site address as the source or destination address are not forwarded to other sites outside the site (equivalent to a private network, b's local site address can only be used in blocal.

 

Tutorial 4: A uses wide-dhcpv6-server to assign IPv6 addresses to B

1. sudo apt-Get install wide-dhcpv6-server

2. VI/etc/DHCP/dhcpd6.conf

 

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.