中文网站
  Advanced Search
Read the latest Blogs from IT professionals in the field. Read and write community created documents. Need IT help? Ask our staff. Connect with your peers. Check our Tech Shop for posters, books and software tools. Home

5.5.1.7 Set up a tunnel on a Linux host

The easiest way to set up a tunnel on a Linux host is using the "ip" command. Modern distributions usually include IPv6 functionality not only with this command but in general as well.

To set up an IPv6-in-IPv4 tunnel usually a "sit" interface is created:

# ip tunnel add sit1 remote <IPv4 address of remote tunnel endpoint> \
local <local IPv4 address>

Note that "sit1" is the name of the sit interface. The "local IPv4 address" is the address of the network interface to be used for the incoming IPv4 traffic which contains the encapsulated IPv6 datagrams.

After configuring the interface it has to be brought up:

# ip link set sit1 up

To equip interface sit1 with an IPv6 address other than the autoconfigured link-local address one can use the following command:

# ip add addr <IPv6 address>/<subnet-length> dev sit1

After these commands the output from “ifconfig sit1” should look somewhat like:

sit1 Link encap: IPv6-in-IPv4
inet6 addr: 2001:db8:1::fff0:2/112 Scope:Global
inet6 addr: fe80::80b0:b807/128 Scope:Link
UP POINTOPOINTRUNNING NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors: 0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

Creating tunnels and adding IPv6 addresses can also be achieved with the command "ifconfig", but this is an old fashioned style and should not be used in newer Linux distributions.