LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2022, 03:56 PM   #1
curious877
LQ Newbie
 
Registered: Oct 2022
Posts: 1

Rep: Reputation: 0
routing using netplan


Hi there. I'm not sure whether it's newbie question or isn't but post here.

using vagrant file i have created 2 virtual machines both ubuntu 22.04. All network interfaces are private. All subnets /24

vm2 has apache2. i want to make curl from from vm1 192.168.100.2 to vm2 192.168.102.4 how can i redirect traffic (using netplan) ? as far i got i need to use address 192.168.100.4 ? do i need to use bridge mode or something like that?

i will appreciate any practical or theoretical suggestions

first vm has two private lan:
172.16.0.2
192.168.100.2

second vm has two private lan:
192.168.100.4
192.168.102.4

vm1 /etc/netplan/50-vagrant.yaml
---
Code:
network:
  version: 2
  renderer: networkd
  ethernets:
    eth1:
      dhcp4: true
    eth2:
      addresses:
      - 172.16.0.2/24
    eth3:
      addresses:
      - 192.168.100.2/24
      routes:
      - to: 192.168.102.4/24
        via: 192.168.100.4/24
        on-link: true
vm2 /etc/netplan/50-vagrant.yaml

Code:
---
network:
  version: 2
  renderer: networkd
  ethernets:
    eth1:
      addresses:
      - 192.168.100.4/24
      routes:
      - to: 192.168.102.4/24
        via: 192.168.100.4/24


    eth2:
      addresses:
      - 192.168.102.4/24
      routes:
      - to: 192.168.100.2/24
        via: 192.168.102.4/24

vm1 ip a
Code:
1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:64:75:a1 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet 10.0.2.15/24 metric 100 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 82499sec preferred_lft 82499sec
    inet6 fe80::a00:27ff:fe64:75a1/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:4b:26:37 brd ff:ff:ff:ff:ff:ff
    altname enp0s8
    inet 192.168.1.153/24 metric 100 brd 192.168.1.255 scope global dynamic eth1
       valid_lft 82500sec preferred_lft 82500sec
    inet6 fe80::a00:27ff:fe4b:2637/64 scope link
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:e0:24:e6 brd ff:ff:ff:ff:ff:ff
    altname enp0s9
    inet 172.16.0.2/24 brd 172.16.0.255 scope global eth2
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fee0:24e6/64 scope link
       valid_lft forever preferred_lft forever
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:0a:3c:a5 brd ff:ff:ff:ff:ff:ff
    altname enp0s10
    inet 192.168.100.2/24 brd 192.168.100.255 scope global eth3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe0a:3ca5/64 scope link
       valid_lft forever preferred_lft forever

vm2 ip a
Code:
1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:44:7b:c6 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet 10.0.2.15/24 metric 100 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 83125sec preferred_lft 83125sec
    inet6 fe80::a00:27ff:fe44:7bc6/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:59:63:fa brd ff:ff:ff:ff:ff:ff
    altname enp0s8
    inet 192.168.100.4/24 brd 192.168.100.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe59:63fa/64 scope link
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:d2:6c:9f brd ff:ff:ff:ff:ff:ff
    altname enp0s9
    inet 192.168.102.4/24 brd 192.168.102.255 scope global eth2
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fed2:6c9f/64 scope link
       valid_lft forever preferred_lft forever

Last edited by curious877; 10-04-2022 at 04:21 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using netplan sniper8752 Linux - Networking 3 12-10-2020 07:15 AM
LXer: Configuring static and dynamic IP Addresses in Ubuntu using Netplan LXer Syndicated Linux News 0 02-18-2020 04:24 AM
How to set a static IP using netplan? (running Ubuntu Bionic server) mrjayviper Linux - Networking 4 03-21-2019 05:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration