]> git.feebdaed.xyz Git - linuxyz.git/commitdiff
not using gcp
authorseantywork <seantywork@gmail.com>
Tue, 10 Jun 2025 13:16:26 +0000 (22:16 +0900)
committerseantywork <seantywork@gmail.com>
Tue, 10 Jun 2025 13:16:26 +0000 (22:16 +0900)
bgp/2506-03.xyz.md
bgp/bird0/bird.conf [new file with mode: 0644]
bgp/bird1/bird.conf [new file with mode: 0644]
bgp/on0.sh [new file with mode: 0755]
bgp/on1.sh [new file with mode: 0755]

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7dfee91fbbd726e84baa7aec1f22f777c3ec4102 100644 (file)
@@ -0,0 +1,109 @@
+#
+
+```shell
+
+seantywork@birds1:~$ nc -l 10.0.1.5 9999
+
+```
+
+```shell
+seantywork@birds0:~$ nc 10.0.1.5 9999
+qwer
+```
+
+#
+
+```shell
+
+sudo apt update
+sudo apt install bird tshark
+
+sudo systemctl stop bird
+```
+
+#
+
+```shell
+
+./on0.sh
+
+```
+
+```shell
+
+./on1.sh
+
+```
+
+#
+
+```shell
+
+seantywork@birds0:~$ sudo ip a
+...
+3: veth1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
+    link/ether 92:af:e1:bd:1b:cb brd ff:ff:ff:ff:ff:ff link-netns net1
+    inet 10.0.10.1/24 scope global veth1
+       valid_lft forever preferred_lft forever
+    inet6 fe80::3ca0:f4ff:fe14:4e85/64 scope link 
+       valid_lft forever preferred_lft forever
+```
+
+#
+
+```shell
+
+seantywork@birds0:~$ sudo ip netns exec net1 ip a
+1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
+    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
+2: veth2@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
+    link/ether 76:cc:32:53:1f:88 brd ff:ff:ff:ff:ff:ff link-netnsid 0
+    inet 10.0.10.2/24 scope global veth2
+       valid_lft forever preferred_lft forever
+    inet6 fe80::74cc:32ff:fe53:1f88/64 scope link 
+       valid_lft forever preferred_lft forever
+
+
+```
+
+
+#
+
+```shell
+seantywork@birds1:~$ sudo tshark -i veth1
+Running as user "root" and group "root". This could be dangerous.
+Capturing on 'veth1'
+
+```
+
+#
+
+```shell
+seantywork@birds1:~$ sudo ip netns exec net1 nc -l 10.0.11.2 9999
+
+```
+```shell
+
+seantywork@birds0:~$ sudo ip netns exec net1 nc 10.0.11.2 9999
+
+```
+
+#
+
+```shell
+seantywork@birds0:~$ sudo ip route add 10.0.1.5 dev ens4
+seantywork@birds0:~$ sudo ip route add 10.0.11.0/24 via 10.0.1.5 dev ens4
+```
+
+```shell
+seantywork@birds1:~$ sudo ip route add 10.0.1.4 dev ens4
+seantywork@birds1:~$ sudo ip route add 10.0.10.0/24 via 10.0.1.4 dev ens4
+
+```
+
+#
+
+```shell
+vim /etc/bird/bird.conf
+
+```
\ No newline at end of file
diff --git a/bgp/bird0/bird.conf b/bgp/bird0/bird.conf
new file mode 100644 (file)
index 0000000..f80af05
--- /dev/null
@@ -0,0 +1,22 @@
+
+router id 10.0.1.4;
+
+protocol kernel {
+  metric 0;
+  import none;
+  learn;
+  export all;
+}
+
+protocol device {
+}
+
+protocol direct {
+}
+
+protocol bgp b0 {
+  local as 64520;
+  neighbor 10.0.1.5 as 64521;
+  import all;
+  export all;
+}
\ No newline at end of file
diff --git a/bgp/bird1/bird.conf b/bgp/bird1/bird.conf
new file mode 100644 (file)
index 0000000..81b3bb2
--- /dev/null
@@ -0,0 +1,22 @@
+
+router id 10.0.1.5;
+
+protocol kernel {
+  metric 0;
+  import none;
+  learn;
+  export all;
+}
+
+protocol device {
+}
+
+protocol direct {
+}
+
+protocol bgp b1 {
+  local as 64521;
+  neighbor 10.0.1.4 as 64520;
+  import all;
+  export all;
+}
\ No newline at end of file
diff --git a/bgp/on0.sh b/bgp/on0.sh
new file mode 100755 (executable)
index 0000000..9790a3a
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash 
+
+sudo sysctl -w net.ipv4.ip_forward=1
+
+sudo ip netns add net1
+
+sudo ip link add dev veth1 type veth peer name veth2 netns net1
+
+sudo ip link set up veth1
+
+sudo ip netns exec net1 ip link set up veth2
+
+sudo ip addr add 10.0.10.1/24 dev veth1
+
+sudo ip netns exec net1 ip addr add 10.0.10.2/24 dev veth2
+
+sudo ip netns exec net1 ip route add default via 10.0.10.1 dev veth2
\ No newline at end of file
diff --git a/bgp/on1.sh b/bgp/on1.sh
new file mode 100755 (executable)
index 0000000..cbe246e
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+sudo sysctl -w net.ipv4.ip_forward=1
+
+sudo ip netns add net1
+
+sudo ip link add dev veth1 type veth peer name veth2 netns net1
+
+sudo ip link set up veth1
+
+sudo ip netns exec net1 ip link set up veth2
+
+sudo ip addr add 10.0.11.1/24 dev veth1
+
+sudo ip netns exec net1 ip addr add 10.0.11.2/24 dev veth2
+
+sudo ip netns exec net1 ip route add default via 10.0.11.1 dev veth2
\ No newline at end of file