totofugaのブログ

ネットワークとかc言語、perlの話。

2017-10-01から1ヶ月間の記事一覧

ソースルーティング

IPのオプションを指定してLinuxで経路を指定してパケットを出す方法を調べてみた 設定方法 IPのオプションを指定する方法は以下の2通りがある ソケット単位に指定する setsockoptでIP_OPTIONSを指定する パケット単位で設定を変える sendmsgのstruct msghdr-…

カーネルからユーザ空間にnetlinkブロードキャスト

iptablesのULOGを調べててカーネル空間にnetlinkにブロードキャストを送る方法が気になったので書いてみた カーネル空間のプログラム #include <linux/socket.h> #include <net/sock.h> static struct timer_list my_timer; static struct sock *sock; static int seq; MODULE_LICENSE("G</net/sock.h></linux/socket.h>…

iptables勉強(2)

iptablesのtargetrの拡張 iptablesだいぶわかってきたので最小構成のtargetを書いてみた 構成ファイル user空間用とkernel空間用の2種類のファイルを用意する必要がある user空間用ファイル iptablesコマンドを拡張するために /lib64/xtables/libに共有ライ…

iptables勉強

ユーザ空間から IPTablesのチェインの取り出し。 とりあえずなんとなくとれるようになったので今日はここまで。 #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <net/if.h> #include <getopt.h> #include <stdlib.h> #include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4/ip_tables.h> #include </linux/netfilter_ipv4/ip_tables.h></linux/netfilter_ipv4.h></stdlib.h></getopt.h></net/if.h></string.h></netinet/in.h></sys/socket.h></sys/types.h>