eth0 → eth1, all packets from eth0 go to eth1, In this scenario, the source interface PBR feature is required. I impelement it through change the code.
- create cfg template file:
bash-5.0# pwd
/opt/vyatta/share/vyatta-cfg/templates/policy/route/node.tag/rule/node.tag/source
bash-5.0# tree interface/
interface/
`-- node.def
0 directories, 1 file
bash-5.0# cat interface/node.def
type: txt
help: Source Interface
- change /opt/vyatta/share/perl5/Vyatta/IpTables/AddressFilter.pm
--- /opt/vyatta/share/perl5/Vyatta/IpTables/AddressFilter.pm.bak 2023-06-13 17:08:22.283335668 +0800
+++ /opt/vyatta/share/perl5/Vyatta/IpTables/AddressFilter.pm 2023-06-13 16:40:27.716988204 +0800
@@ -55,6 +55,7 @@
_address_group => undef,
_network_group => undef,
_port_group => undef,
+ _interface => undef,
);
sub new {
@@ -107,6 +108,8 @@
$self->{_network_group} = $config->$func("group network-group");
$self->{_port_group} = $config->$func("group port-group");
+ $self->{_interface} = $config->$func("interface");
+
return 0;
}
@@ -232,6 +235,8 @@
}
$group_ok{address} = 0;
$group_ok{network} = 0;
+ } elsif (defined($self->{_interface})) {
+ $rule .= "-i $self->{_interface} ";
}
$group_ok{port} = 0 if defined $self->{_port};
- configuration commands
set policy route PBR10 rule 100 set table '100'
set policy route PBR10 rule 100 source interface 'eth0'
set protocols static table 100 interface-route 0.0.0.0/0 next-hop-interface eth1
set interfaces ethernet eth0 policy route 'PBR10'