IPv6 address, route, and tunnel configuration in Linux

Source: Internet
Author: User
Today, almost all mainstream operating systems and embedded operating systems provide support for the IPv6 protocol stack. in Windows XP, you can use the IPv6 install command to start the IPv6 protocol stack, in the default Linux environment, you can use modprobe IPv6 to load the IPv6 protocol stack as a module. This article only introduces the IPv6 protocol stack configuration commands under Linux. More detailed Linux and Windows transition mechanisms will be introduced in the future, such as 6to4, Nat-Pt, teredo and other configuration instances.

  1. open or close the interface

1.1 Use "ip"

Usage:

# IP link set Dev Up

# IP link set Dev Down

Example:

# IP link set Dev eth0 up

# IP link set Dev eth0 down

1.2 use "ifconfig"

Usage:

#/Sbin/ifconfig Up

#/Sbin/ifconfig Down

Example:

#/Sbin/ifconfig eth0 up

#/Sbin/ifconfig eth0 down

  2. Configure the IPv6 address

2.1 display existing IPv6 addresses

(1) Use "ip"

Usage:

#/Sbin/IP-6 ADDR show Dev

(2) Use "ifconfig"

Usage:

#/Sbin/ifconfig

2.2 add or delete an IPv6 address

(1) Use "ip"

Usage:

#/Sbin/IP-6 ADDR /

Dev

Example:

#/Sbin/IP-6 ADDR add 3ffe: FFFF: 0: f101 :: 1/64 Dev eth0

(2) Use "ifconfig"

Usage:

#/Sbin/ifconfig Inet6 [Add/del] /

Example:

#/Sbin/ifconfig eth0 inet6 add 3ffe: FFFF: 0: f101: 1/64

  3. Configure IPv6 routes

3.1 display existing routes

(1) Use "ip"

Usage:

#/Sbin/IP-6 route show [Dev]

Example:

#/Sbin/IP-6 route show Dev eth0

3ffe: FFFF: 0: f101:/64 proto kernel metric 256 MTU 1500 advmss 1440

Fe80:/10 proto kernel metric 256 MTU 1500 advmss 1440

Ff00:/8 proto kernel metric 256 MTU 1500 advmss 1440

Default proto kernel metric 256 MTU 1500 advmss 1440

(2) Use "Route"

Usage:

#/Sbin/route-A inet6

Example:

#/Sbin/route-A inet6 | grep-W "eth0"

3ffe: FFFF: 0: f101:/64: UA 256 0 0 eth0 <-interface route for Global Address

Fe80:/10: UA 256 0 0 eth0 <-interface route for Link-local address

Ff00:/8: UA 256 0 0 eth0 <-interface route for all multicast addresses

:/0: UDA 256 0 0 eth0 <-Automatic default route

3.2 add or delete a route entry to a gateway

(1) Use "ip"

Usage:

#/Sbin/IP-6 route /

Via [Dev ]

Example:

#/Sbin/IP-6 route2000:/3 via 3ffe: FFFF: 0: f101: 1

(2) Use "Route"

Usage:

#/Sbin/route-A inet6 add /

GW [Dev ]

If the IPv6 address of the gateway is a link address, add DevParameters.

  4 configure IPv6-in-IPv4Tunnel

4.1 Tunnel Type

(1) static point-to-point tunnel: 6 bone

A point-to-point tunnel is a dedicated tunnel of a terminal (endpoint. To configure such a tunnel, you need to know:

The IPv4 address of your local tunnel terminal must be static and globally unique and accessible.

The Global IPv6 prefix assigned to you

The external tunnel terminal can route your IPv6 prefix to your local tunnel terminal.

(2) Automatic Tunnel

Automatically Generated tunnel. This occurs when the current node has a direct link with another node with an IPv4 address.

(3) 6to4 tunnel

4.2 Display existing tunnels

(1) Use "ip"

Usage:

#/Sbin/IP-6 tunnel show []

Example:

#/Sbin/IP-6 tunnel show

Sit0: IPv6/IP remote any local any TTL 64 nopmtudisc

Sit1: IPv6/IP remote 195.226.187.50 local any TTL 64

(2) Use "Route"

Usage:

#/Sbin/route-A inet6

Example:

#/Sbin/route-A inet6 | grep "/wsit0/W * $"

:/96: U 256 2 0 sit0

2002:/16: UA 256 0 0 sit0

2000:/3: 193.113.58.75 ug 1 0 sit0

Fe80:/10: UA 256 0 0 sit0

Ff00:/8: UA 256 0 0 sit0

4.3 establish a point-to-point Tunnel

There are three possible methods to add or delete point-to-point tunnels.

Add point-to-point tunnels

(1) Use "ip" and "Route"

A common method for creating a small number of tunnels.

Create a tunnel device (to make the configuration take effect immediately afterwards, and because the default TTL value is 0, we also need to specify the TTL value ):

#/Sbin/IP Tunnel addMode sit TTL Remote Local

Three general examples:

#/Sbin/IP Tunnel add sit1 mode sit TTL Remote Local

#/Sbin/ifconfig sit1 up

#/Sbin/route-A inet6 add

Dev sit1

#/Sbin/IP Tunnel add sit2 mode sit TTL Local

#/Sbin/ifconfig sit2 up

#/Sbin/route-A inet6 add

Dev sit2

#/Sbin/IP Tunnel add sit3 mode sit TTL Local

#/Sbin/ifconfig sit3 up

#/Sbin/route-A inet6 add

Dev sit3

(2) Use "ifconfig" and "Route" (not recommended)
There is no problem when adding only one tunnel, but when you build multiple tunnels, the problem arises. At this time, you cannot easily close the previous tunnel while letting other tunnels run.
Usage: (general examples of the three tunnels)

#/Sbin/ifconfig sit0 up

#/Sbin/ifconfig sit0 Tunnel

#/Sbin/ifconfig sit1 up

#/Sbin/route-A inet6 add

Dev sit1

#/Sbin/ifconfig sit0 Tunnel

#/Sbin/ifconfig sit2 up

#/Sbin/route-A inet6 add

Dev sit2

#/Sbin/ifconfig sit0 Tunnel

#/Sbin/ifconfig sit3 up

#/Sbin/route-A inet6 add

Dev sit3

(3) only use "Route"

Usage: (3 general examples)

#/Sbin/ifconfig sit0 up

#/Sbin/route-A inet6 add

GW :: Dev sit0

#/Sbin/route-A inet6 add

GW :: Dev sit0

#/Sbin/route-A inet6 add

GW :: Dev sit0

Delete a point-to-point Tunnel

(1) Use "ip" and "Route"

Usage:

#/Sbin/IP Tunnel del

Here are three common usage examples:

#/Sbin/route-A inet6 del

Dev sit1

#/Sbin/ifconfig sit1 down

#/Sbin/IP Tunnel del sit1

#/Sbin/route-A inet6 del

Dev sit2

#/Sbin/ifconfig sit2 down

#/Sbin/IP Tunnel del sit2

#/Sbin/route-A inet6 del

Dev sit3

#/Sbin/ifconfig sit3 down

#/Sbin/IP Tunnel del sit3

(2) Use "ifconfig" and "Route" (currently not recommended)

Like the tunnel creation command, the method of deleting a tunnel is confusing. The last created tunnel must be deleted first.

Usage: (3 common examples)

#/Sbin/route-A inet6 del

Dev sit3

#/Sbin/ifconfig sit3 down

#/Sbin/route-A inet6 del

Dev sit2

#/Sbin/ifconfig sit2 down

#/Sbin/route-A inet6 add

Dev sit1

#/Sbin/ifconfig sit1 down

#/Sbin/ifconfig sit0 down

(3) Use "Route"

This is a bit like deleting a common ipv6 route.

Usage: (3 common examples)

#/Sbin/route-A inet6 del

GW :: Dev sit0

#/Sbin/route-A inet6 del

GW :: Dev sit0

#/Sbin/route-A inet6 del

GW :: Dev sit0

#/Sbin/ifconfig sit0 down

5.4.4 build a 6to4 tunnel

Add a 6to4 tunnel

(1) Use "ip" and a dedicated tunnel device (recommended)

Create a new tunnel device:

#/Sbin/IP Tunnel add tun6to4 mode sit remote any local

Activate this tunnel interface:

#/Sbin/IP link set Dev tun6to4 up

Add a local 6to4 address to the tunnel Interface

#/Sbin/IP-6 ADDR add /16 Dev tun6to4

Add a (default) vro to the Global IPv6 network using the IPv4 multicast address of the 6to4 router:

#/Sbin/IP-6 route add 2000:/3 via: 192.88.99.1 Dev tun6to4 metric 1

(2) Use "ifconfig" and "Route" and the general (generic) tunnel device "sit0" (not recommended)

Disadvantage: using "sit0" does not allow specific Filtering for each device.

Activate the usual tunnel interface "sit0 ":

#/Sbin/ifconfig sit0 up

Add the local 6to4 address to the interface:

#/Sbin/ifconfig sit0 add /16

Add a (default) vro to the Global IPv6 network using the IPv4 multicast address of the 6to4 router:

#/Sbin/route-A inet6 add 2000:/3 GW: 192.88.99.1 Dev sit0

Delete 6to4 tunnel

(1) Use an IP address and a dedicated Tunneling Device

Delete all routes to the dedicated tunnel device:

#/Sbin/IP-6 route flush Dev tun6to4

Close the interface:

#/Sbin/IP link set Dev tun6to4 down

Delete the created tunnel device:

#/Sbin/IP Tunnel del tun6to4

(2) Use "ifconfig" and "Route" and the usual tunnel device "sit0" (not recommended)

Delete the route entry from the default 6to4 tunnel interface:

#/Sbin/route-A inet6 del 2000:/3 GW: 192.88.99.1 Dev sit0

Delete the local 6to4 address to the interface:

#/Sbin/ifconfig sit0 del /16
Disable "sit0": (Note this step because sit0 may still be used)

#/Sbin/ifconfig sit0 down
 

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.