linux – Routing/forwarding packets between two interfaces

I need to route my PC network traffic through a VMWare machine. What setup I thought about that is using a vm with two interfaces and forcing the PC to send the traffic to VMNet1 instead of Ethernet (using interface metric or routing). The setup is look like the following picture:

enter image description here

I have enabled ip_forward in `/proc/sys/net/ipv4/’, but seems is’t enough.

In the PC I can access to ens33 and ens37:

  • Pinging 192.168.1.3 from PC is OK
  • Pinging 192.168.1.4 from PC is OK
  • ARP table (arp -a) shows 192.168.1.3-4 in 192.168.1.5’s entry
  • I can’t ping 192.168.1.1 through VMNet1 (ping -S 192.168.1.5 192.168.1.1)

In the vm:

  • Pinging 192.168.1.1 only through ens37 is OK (ping -I ens37 192.168.1.1)

Question
With the above details, I think my problem is routing/forwarding incoming packet from ens33 to ens37in the vm, so how to do this?

Further information:

~$ ip route
default via 192.168.1.1 dev ens37 proto static metric 101 
192.168.1.0/24 dev ens33 proto kernel scope link src 192.168.1.3 metric 100 
192.168.1.0/24 dev ens37 proto kernel scope link src 192.168.1.4 metric 101 

~$ networkctl status -a
● 1: lo
       Link File: /usr/lib/systemd/network/99-default.link
    Network File: n/a
            Type: loopback
           State: carrier (unmanaged)
         Address: 127.0.0.1
                  ::1

● 2: ens33
       Link File: /usr/lib/systemd/network/99-default.link
    Network File: n/a
            Type: ether
           State: routable (unmanaged)
            Path: pci-0000:02:01.0
          Driver: e1000
          Vendor: Intel Corporation
           Model: 82545EM Gigabit Ethernet Controller (Copper) (PRO/1000 MT Single Port Adapter)
      HW Address: 00:0c:29:2e:5e:a0 (VMware, Inc.)
         Address: 192.168.1.3
                  fe80::a71c:e329:2378:4972

● 3: ens37
       Link File: /usr/lib/systemd/network/99-default.link
    Network File: n/a
            Type: ether
           State: routable (unmanaged)
            Path: pci-0000:02:05.0
          Driver: e1000
          Vendor: Intel Corporation
           Model: 82545EM Gigabit Ethernet Controller (Copper) (PRO/1000 MT Single Port Adapter)
      HW Address: 00:0c:29:2e:5e:aa (VMware, Inc.)
         Address: 192.168.1.4
                  fe80::20c:29ff:fe2e:5eaa
         Gateway: 192.168.1.1 (TP-LINK TECHNOLOGIES CO.,LTD.)
                  fe80::1 (TP-LINK TECHNOLOGIES CO.,LTD.)

~$ ip neigh
192.168.1.103 dev ens37 lladdr 3c:bb:fd:3d:25:00 REACHABLE
192.168.1.103 dev ens33  FAILED
192.168.1.1 dev ens37 lladdr 90:f6:52:03:3b:00 STALE
192.168.1.100 dev ens37 lladdr 40:61:86:e2:dd:00 STALE
192.168.1.1 dev ens33  FAILED
192.168.1.5 dev ens33 lladdr 00:50:56:c0:00:00 STALE


C:WINDOWSsystem32>arp -a

Interface: 192.168.1.100 --- 0x10
  Internet Address      Physical Address      Type
  192.168.1.1           90-f6-52-03-3b-00     dynamic
  ...

Interface: 192.168.1.5 --- 0x1e
  Internet Address      Physical Address      Type
  192.168.1.3           00-0c-29-2e-5e-a0     dynamic
  192.168.1.4           00-0c-29-2e-5e-a0     dynamic
  ...

Interfaces – Where are duplicate key exceptions handled in multi-tier applications?

+-------------+         +--------+        +----------+
| repository  +-------->+service +------->+controller|
+-------------+         +-^------+        +------------+
+-------------+           |  +^  ++------>+controller2 |
| repository2 +-----------+  |    |       +------------+
+-------------+              |    +------>+controller3 |
+------------+               |            +------------+
| repository3+---------------+
+------------+

I want to be able to support several different implementations of my repository interface. I use my interface via business service and can choose which implementation I want. So far, so good.

When I try to insert multiple entries with the same key, the db connector throws an exception. In the case of jdbcTemplate this is DuplicateKeyException, in the case of Hibernate this is probably a kind of constraint exception. Not ideal, but still good enough.

I need to be able to tell the service consumer what exactly went wrong, why, if throwing the exception is not good enough (as in answer 500). Become mud.

So my options are either to catch this exception in the controller, which I then have to implement in every controller (which seems muddy to me), or I can raise a kind of exception in the business service (which seems better) and then deal with it in the Control. I think that's better because then I'll get my own exception and I'm sure what's going on.

The problem is that most of my business service implementation is actually an existing interface implementation. This means that I have to overwrite the interface I use with new declarations that contain exceptions. I dont want that.

What is the right way to deal with this type of situation? I use Spring, but I want a more general answer.

C # – Unity-related objects in interfaces

Should I use Unity-related objects in interfaces for code reusability, or is this a bad practice?

For example:

public interface ISomeInterface{
Transform object1 {get;}
GameObject object2 {get;}
}

My main concern is future compatibility.

Bonus points if you link a good read to me.

Linux – Measure packet latency / waste between the input and output interfaces of a rate-limiting pass-through host

Somewhere between my transmitter and receiver there is a host that explicitly limits my transfer rate.

I know it is a linux host. The entry interface for my traffic is eth0 and is the output interface eth1. The rate limiter will most likely be implemented somehow using Linux traffic control (tc), but I don't know the details.

From an earlier offline comparison between PCAP files that were recorded at eth0 and eth1 I know that the rate limiter causes significant packet latency (up to 15 seconds!) And packet loss (up to 16%) when I try push through with as much data as possible iperf.

All traffic is TCP / IP. Source IP, destination IP and destination port are known and constant. Only the source port changes between successive flows.

With given (root) access, is there a way to: a Live measurement the packet latency and drop counter / rates? Or recorded in a file as time series data?

C # – unit test of an existing project by creating interfaces for all public classes (including GUI forms)

This is an existing C # .NET WinForms project. I assume that it was not developed for unit tests right from the start. It uses a model view controller architecture, and the backend is a content repository (a kind of hierarchical database) that I'm not too familiar with since I only touched the front end.

I was asked to create interfaces for each interface public Class, including the forms. These are used for unit tests with NUnit. This is now complete. What is the best approach now? The only thing that comes to mind at the moment is the creation of concrete classes from these interfaces, whereby only the existing classes are implemented again in the application. Other than the fact that unit tests "take care of their own affairs", I don't see what the purpose of rewriting the classes is.

If that's the right approach, it doesn't seem difficult to test things like the model that contains an OOP representation of the database. How should the forms be tested?

Database – How can I create separate interfaces for the same application? How do I let django save a user's location?

I need to build a system that allows users of a particular company's services to pay monthly fees.
The system can be accessed by senior company employees, and these employees should be able to see the profile of the users and see whether they have paid or not (I am creating the website in Django so that I can access the employees Administration side, but I don't want to do it that way).

I also need to enable users (not employees) to register with their location. And every time an employee checks the user's location, Google Maps should show exactly where that person’s home is.

Thirdly, I'm not sure how they should pay online at all and how the database should be constantly updated when a user pays.

The language I use is Python Django and I really need help as this is a school project that I have to submit in a couple of weeks.

Interfaces – Search for the name of this design pattern

I used a pattern in many places (C # & C ++), the name of which I would like to know.

Here is an example of this in C #:

public enum ThingType
{
    A,
    B,
    C
}

public interface IThing
{
    ThingType Type
    { get; }
}

public class ThingA : IThing
{
    public ThingType Type => ThingType.A;
}

public class ThingB : IThing
{
    public ThingType Type => ThingType.B;
}

public class ThingC : IThing
{
    public ThingType Type => ThingType.C;
}

As long as all implementations of IThing If you have a corresponding member in the list, I can certainly convert to the actual type IThing after checking the value of IThing.Type.

public void HandleThing(IThing thing)
{
    switch(thing.Type)
    {
        case ThingType.A:
            ThingA a = (ThingA)thing;
            // Doing something with a...
            break;

        case ThingType.B:
            ThingB b = (ThingB)thing;
            // Doing something with b...
            break;

        case ThingType.C:
            ThingC c = (ThingC)thing;
            // Doing something with c...
            break;
    }
}

I apologize if this question is a duplicate. I searched a few pages of search results for several different search phrases and could not find this question yet.

unity – How FindGameObjectsWithTag then converts the array of GameObjects into an array of interfaces

I have a couple of GameObjects that implement a common interface: IsTree.
I have to call the function doTreeThing () on each of these IsTrees after getting a reference to each of them via FindGameObjectsWithTag ("tree").

This line complains that it cannot implicitly convert from GameObject () to IsTree ().

IsTree() trees = GameObject.FindGameObjectsWithTag("tree");

So I tried running the GameObject () to convert every single object into an IsTree.

GameObject() trees = GameObject.FindGameObjectsWithTag("tree");
        foreach (GameObject tree in trees) {
            IsTree isTree = (IsTree)tree;
            isTree.doTreeThing();
        }

However, this complains that GameObject cannot be converted to IsTree.

Then I got a little desperate and tried to turn my IsTree into a GameObject.

public class IsTree : GameObject {
    public System.DateTime getAge(){
        return null;
    }
}

GameObject is a sealed type. (I don't really know what that means apart from not working)

How can I convert this array of GameObjects into an array of SomeInterface?

Linux – How do I do port forwarding with two interfaces using iptables?

I have a Debian box with two interfaces wan and lan. I have a site that needs to be accessed over the local network. This page must also be accessible from wan: 777. These are my iptables rules:

iptables -A INPUT -i $LAN -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i $WAN --dport 777 -j DNAT --to-destination 192.168.0.1:80
iptables -A FORWARD -p tcp -d 192.168.0.1 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

However, it doesn't work. It only works if I remove -i $LAN by INPUT. I mean like this:

iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i $WAN --dport 777 -j DNAT --to-destination 192.168.0.1:80
iptables -A FORWARD -p tcp -d 192.168.0.1 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

However, it is a bad way. What is my mistake

Network – Use of several interfaces in Centos: Interface not accessible

I have a machine in ESXi that I want to use as a DMZ area.

I connected two interfaces to the machine, one is connected to the internal network (10.0.0.1/8) (ens192) and the other is faced with WAN (ens224).

I wanted to use nginx to transfer the services of the internal network to the outside.

(root@dmz ~)# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens192:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether ######## brd ff:ff:ff:ff:ff:ff
    inet /8 brd 10.255.255.255 scope global noprefixroute dynamic ens192
       valid_lft 5253sec preferred_lft 5253sec
    inet6 ######## scope link noprefixroute
       valid_lft forever preferred_lft forever
3: ens224:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether ######## brd ff:ff:ff:ff:ff:ff
    inet /24 brd 14.36.181.255 scope global noprefixroute dynamic ens224
       valid_lft 3082sec preferred_lft 3082sec
    inet6 ######## scope link noprefixroute
       valid_lft forever preferred_lft forever

I see that ens192 and ens224 are well connected, have their IP and everything.

(root@dmz ~)# sudo firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens192 ens224
  sources:
  services: dhcpv6-client http ssh
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

If I allow http or ssh in the firewall with firewall-cmd, I can easily access these services via the internal network IP. But for some reason, these services are not accessible over the WAN-IP.

(root@external ~)# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default               0.0.0.0         UG    100    0        0 ens192
default         gateway         0.0.0.0         UG    101    0        0 ens224
10.0.0.0        0.0.0.0         255.0.0.0       U     100    0        0 ens192
12.34.56.0     0.0.0.0         255.255.255.0   U     101    0        0 ens224

My routes are like this. What's the problem?