[Linux/ip] GRE tunnel 생성하기 (ip tunnel 커맨드 이용)
$ sudo modprobe ip_gre
$ lsmod | grep gre
ip tunnel 활용
$ sudo ip tunnel add gre1 mode gre remote 172.168.10.25 local 192.168.233.204 ttl 255
$ ifconfig -a
(ifconfig 로 하면, gre1 device가 보이지 않습니다. 왜냐하면, 아직 up을 하지 않았기 때문입니다.)
(아래의 명령어는 선택사항)
$ ip link set gre0 addrgenmode none (이 명령어는 default link local address 생성을 막기 위해 사용)
$ sudo ip link set gre1 up
$ ifconfig
$ sudo ip addr add 10.10.10.1/24 dev gre1
$ ifconfig
$ ip route show
ip link 활용
$ ip link add name gre1 type gre local LOCAL_IPv4_ADDR remote REMOTE_IPv4_ADDR [seq] key KEY
$ ip link set gre0 up
$ ip addr add 12.12.12.1/24 dev gre0
(# ip link add name vti1 type vti key 3 local 192.168.10.10 remote 192.168.0.2)
알아두면 좋을 지식
ip tunnel은 ioctl 기반이고,
ip link는 netlink를 통해 구현한 것이다.
https://unix.stackexchange.com/questions/383760/where-can-i-find-the-source-code-for-bin-ip